Re: Do we want to avoid checksumming extra files in the datadir? [was: BUG #19647]
Re: Do we want to avoid checksumming extra files in the datadir? [was: BUG #19647]
On Thu, Sep 3, 2026 at 10:29 AM Tom Lane wrote: > Daniel Gustafsson writes: > > I'm not sure I have a strong preference, keeping it in sync with pg_basebackup > > seems like a pretty good strategy to make it easier for users. > > It looks to me like there was a fair amount of consensus behind > 025584a16, so I think we should conclude that pg_basebackup's new > behavior (ignore stray files) is the right thing and it was an > oversight that pg_checksums wasn't adjusted similarly. Sounds good, thanks both! Attached is the simplest thing that could fix the reported problem (and nothing else), but I'd rather look into moving parse_filename_for_nontemp_relation() to common/relfile.c so it can be used directly. I probably won't have time for that today. --Jacob
Re: Do we want to avoid checksumming extra files in the datadir? [was: BUG #19647]
On Thu, Sep 3, 2026 at 11:30 AM Jacob Champion wrote: > Sounds good, thanks both! Attached is the simplest thing that could > fix the reported problem (and nothing else), but I'd rather look into > moving parse_filename_for_nontemp_relation() to common/relfile.c so it > can be used directly. I probably won't have time for that today. Here's a v2 to do that, which I like much better. The --filenode argument now filters via integer equality rather than a string comparison. I think there are two main side effects (let me know if either is unacceptable): 1) we now prohibit `pg_checksums --filenode 0`, which IIUC isn't ever helpful in practice, and 2) leading zeroes in the --filenode arg are now ignored, rather than causing pg_checksums to match nothing. I.e. `--filenode 001260` will now match relfile 1260. Are there are any corner cases I've missed where you want pg_checksums to check a temporary relation's relfiles? Even if a clean shutdown and startup somehow left them around, they still wouldn't be used, right? Thanks, --Jacob
Re: Do we want to avoid checksumming extra files in the datadir? [was: BUG #19647]
От:
Rui Zhao <zhaorui126@gmail.com>
Дата:
Hi Jacob, > Are there are any corner cases I've missed where you want pg_checksums > to check a temporary relation's relfiles? Skipping them looks right to me. A normal server restart removes leftover temporary files, and after a backend crash they are also removed by default. I set remove_temp_files_after_crash = off to retain them, created temporary tables in pg_default and a separate tablespace, then sent SIGKILL (kill -9) to the backend that created both tables. After automatic recovery, I cleanly shut down the server. Both temporary relation files were still present. With v2, pg_checksums --check --verbose skipped both files. The next postmaster startup removed them even with remove_temp_files_after_crash still off. The --filenode changes look fine too. Zero is not a valid filenode, so rejecting it is reasonable. Numeric comparison also makes sense: adding leading zeroes to the argument does not identify a different relation. In my test, --filenode 0016385 checked the same three files as --filenode 16385. After I deliberately corrupted a page checksum in that relation, --filenode 0016385 reported the checksum failure. --filenode 0 was rejected. Could we add a leading-zero --filenode case to check_relation_corruption() in src/bin/pg_checksums/t/002_actions.pl? After corrupt_page_checksum(), using "00$relfilenode_corrupted" should still report one bad checksum and exit 1. Checking only for success would also pass with the old behavior of matching no files. Could 0003's commit message also mention the change from string to numeric comparison for --filenode, including the leading-zero behavior? The core regression, pg_checksums and pg_basebackup tests passed, as did t/014_unlogged_reinit.pl and t/022_crash_temp_files.pl in src/test/recovery. I didn't find a functional issue with v2. Regards, Rui
Re: Do we want to avoid checksumming extra files in the datadir? [was: BUG #19647]
От:
Shubhra Jain <shubhra.jain@ksolves.com>
Дата:
Hi Jacob, all,
I applied v2-0001..0003 on top of master (e40b509c08) and tested them.
- pg_checksums (77 tests) and pg_basebackup (352 tests) TAP tests pass.
- With stray files in global/ ("foreign_file" with 4 bytes and
"foreign.conf"), unpatched pg_checksums fails ("could not read block
0 ... read 4 of 8192"; the dotted name gave "invalid segment number
0"), while v2 exits 0.
- On a cluster with a table, an index and an unlogged table, patched
and unpatched report identical counts (956 files, 9362 blocks).
- "--filenode 0" is rejected with "must be in range 1..2147483647".
Two things I noticed while reviewing:
1. doc/src/sgml/ref/pg_checksums.sgml still says that when verifying
checksums "every file in the cluster is scanned". With 0003 that is
no longer accurate; it could say "every relation file" and mention
that other files are ignored.
2. Per Rui's review, the 0003 commit message could mention that
--filenode is now compared numerically, and a leading-zero
--filenode case is not yet in check_relation_corruption().
I'm happy to write the docs and test changes if you'd like.
Thanks,
Shubhra
I applied v2-0001..0003 on top of master (e40b509c08) and tested them.
- pg_checksums (77 tests) and pg_basebackup (352 tests) TAP tests pass.
- With stray files in global/ ("foreign_file" with 4 bytes and
"foreign.conf"), unpatched pg_checksums fails ("could not read block
0 ... read 4 of 8192"; the dotted name gave "invalid segment number
0"), while v2 exits 0.
- On a cluster with a table, an index and an unlogged table, patched
and unpatched report identical counts (956 files, 9362 blocks).
- "--filenode 0" is rejected with "must be in range 1..2147483647".
Two things I noticed while reviewing:
1. doc/src/sgml/ref/pg_checksums.sgml still says that when verifying
checksums "every file in the cluster is scanned". With 0003 that is
no longer accurate; it could say "every relation file" and mention
that other files are ignored.
2. Per Rui's review, the 0003 commit message could mention that
--filenode is now compared numerically, and a leading-zero
--filenode case is not yet in check_relation_corruption().
I'm happy to write the docs and test changes if you'd like.
Thanks,
Shubhra
On Wed, Oct 7, 2026 at 4:32 PM Jacob Champion <jacob.champion@enterprisedb.com> wrote:
On Thu, Sep 3, 2026 at 11:30 AM Jacob Champion
<jacob.champion@enterprisedb.com> wrote:
> Sounds good, thanks both! Attached is the simplest thing that could
> fix the reported problem (and nothing else), but I'd rather look into
> moving parse_filename_for_nontemp_relation() to common/relfile.c so it
> can be used directly. I probably won't have time for that today.
Here's a v2 to do that, which I like much better.
The --filenode argument now filters via integer equality rather than a
string comparison. I think there are two main side effects (let me
know if either is unacceptable):
1) we now prohibit `pg_checksums --filenode 0`, which IIUC isn't ever
helpful in practice, and
2) leading zeroes in the --filenode arg are now ignored, rather than
causing pg_checksums to match nothing. I.e. `--filenode 001260` will
now match relfile 1260.
Are there are any corner cases I've missed where you want pg_checksums
to check a temporary relation's relfiles? Even if a clean shutdown and
startup somehow left them around, they still wouldn't be used, right?
Thanks,
--Jacob