Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8f9aba1

Browse files
committed
Skip foreign tablespaces when running pg_checksums/pg_verify_checksums
Attempting to use pg_checksums (pg_verify_checksums in 11) on a datafolder which includes tablespace paths used across multiple majorversions would cause pg_checksums to scan all directories present inpg_tblspc, and not only marked with TABLESPACE_VERSION_DIRECTORY. Thiscould lead to failures when for example running sanity checks on anupgraded instance with --check. Even worse, it was possible to rewriteon-disk pages with --enable for a cluster potentially online.This commit makes pg_checksums skip any directories not namedTABLESPACE_VERSION_DIRECTORY, similarly to what is done for basebackups.Reported-by: Michael BanckAuthor: Michael Banck, Bernd HelmleDiscussion:https://postgr.es/m/62031974fd8e941dd8351fbc8c7eff60d59c5338.camel@credativ.debackpatch-through: 11
1 parent83bd732 commit8f9aba1

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

‎src/bin/pg_verify_checksums/pg_verify_checksums.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include"catalog/pg_control.h"
1717
#include"common/controldata_utils.h"
18+
#include"common/relpath.h"
1819
#include"getopt_long.h"
1920
#include"pg_getopt.h"
2021
#include"storage/bufpage.h"
@@ -238,7 +239,51 @@ scan_directory(const char *basedir, const char *subdir)
238239
#else
239240
elseif (S_ISDIR(st.st_mode)||pgwin32_is_junction(fn))
240241
#endif
241-
scan_directory(path,de->d_name);
242+
{
243+
/*
244+
* If going through the entries of pg_tblspc, we assume to operate
245+
* on tablespace locations where only TABLESPACE_VERSION_DIRECTORY
246+
* is valid, resolving the linked locations and dive into them
247+
* directly.
248+
*/
249+
if (strncmp("pg_tblspc",subdir,strlen("pg_tblspc"))==0)
250+
{
251+
chartblspc_path[MAXPGPATH];
252+
structstattblspc_st;
253+
254+
/*
255+
* Resolve tablespace location path and check whether
256+
* TABLESPACE_VERSION_DIRECTORY exists. Not finding a valid
257+
* location is unexpected, since there should be no orphaned
258+
* links and no links pointing to something else than a
259+
* directory.
260+
*/
261+
snprintf(tblspc_path,sizeof(tblspc_path),"%s/%s/%s",
262+
path,de->d_name,TABLESPACE_VERSION_DIRECTORY);
263+
264+
if (lstat(tblspc_path,&tblspc_st)<0)
265+
{
266+
fprintf(stderr,_("%s: could not stat file \"%s\": %s\n"),
267+
progname,tblspc_path,strerror(errno));
268+
exit(1);
269+
}
270+
271+
/*
272+
* Move backwards once as the scan needs to happen for the
273+
* contents of TABLESPACE_VERSION_DIRECTORY.
274+
*/
275+
snprintf(tblspc_path,sizeof(tblspc_path),"%s/%s",
276+
path,de->d_name);
277+
278+
/* Looks like a valid tablespace location */
279+
scan_directory(tblspc_path,
280+
TABLESPACE_VERSION_DIRECTORY);
281+
}
282+
else
283+
{
284+
scan_directory(path,de->d_name);
285+
}
286+
}
242287
}
243288
closedir(dir);
244289
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp