Re: [Patch] Make pg_checksums skip foreign tablespace directories
Bernd Helmle <mailings@oopsware.de>
From: Bernd Helmle <mailings@oopsware.de>
To: Michael Paquier <michael@paquier.xyz>
Cc: Michael Banck <michael.banck@credativ.de>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2020-02-20T16:38:15Z
Lists: pgsql-hackers
Attachments
- 0001-Make-scanning-pg_tblspc-more-robust.patch (text/x-patch) patch 0001
Am Dienstag, den 18.02.2020, 15:15 +0900 schrieb Michael Paquier: > Fair point. Now, while the proposed patch is right to use > TABLESPACE_VERSION_DIRECTORY, shouldn't we use strncmp based on the > length of TABLESPACE_VERSION_DIRECTORY instead of de->d_name? It > seems also to me that the code as proposed is rather fragile, and > that > we had better be sure that the check only happens when we are > scanning > entries within pg_tblspc. > Yes, after thinking and playing around with it a little i share your position. You can still easily cause pg_checksums to error out by just having arbitrary files around in the reference tablespace locations. Though i don't think this is something of a big issue, it looks strange and misleading if pg_checksums just complains about files not belonging to the scanned PostgreSQL data directory (even we explicitly note in the docs that even tablespace locations are somehow taboo for DBAs to put other files and/or directories in there). So i propose a different approach like the attached patch tries to implement: instead of just blindly iterating over directory contents and filter them out, reference the tablespace location and TABLESPACE_VERSION_DIRECTORY directly. This is done by a new function scan_tablespaces() which is specialized in just follow the symlinks/junctions in pg_tblspc and call scan_directory() with just what it has found there. It will also honour directories, just in case an experienced DBA has copied over the tablespace into pg_tblspc directly. > The issue with pg_internal.init.XX is quite different, so I think > that > it would be better to commit that separately first. Agreed. Thanks, Bernd
Commits
-
Skip foreign tablespaces when running pg_checksums/pg_verify_checksums
- 8f9aba1874ec 11.8 landed
- f6e8e8b3809b 12.3 landed
- 428a2609ef64 13.0 landed
-
Add prefix checks in exclude lists for pg_rewind, pg_checksums and base backups
- da2a7180aa0e 11.8 landed
- a8beece956eb 12.3 landed
- bf883b211eae 13.0 landed