]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Harden TAP tests that intentionally corrupt page checksums.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 25 Mar 2022 18:23:26 +0000 (14:23 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 25 Mar 2022 18:23:26 +0000 (14:23 -0400)
commit3d263b09058a6ea90ed0f6143fafbb92892c7ba8
treec3ada7bc278d8251a9e24e3ab5cc7ebb81d5b6c4
parent118f1a332b0094a04264c2aedc428c826ac24b7f
Harden TAP tests that intentionally corrupt page checksums.

The previous method for doing that was to write zeroes into a
predetermined set of page locations.  However, there's a roughly
1-in-64K chance that the existing checksum will match by chance,
and yesterday several buildfarm animals started to reproducibly
see that, resulting in test failures because no checksum mismatch
was reported.

Since the checksum includes the page LSN, test success depends on
the length of the installation's WAL history, which is affected by
(at least) the initial catalog contents, the set of locales installed
on the system, and the length of the pathname of the test directory.
Sooner or later we were going to hit a chance match, and today is
that day.

Harden these tests by specifically inverting the checksum field and
leaving all else alone, thereby guaranteeing that the checksum is
incorrect.

In passing, fix places that were using seek() to set up for syswrite(),
a combination that the Perl docs very explicitly warn against.  We've
probably escaped problems because no regular buffered I/O is done on
these filehandles; but if it ever breaks, we wouldn't deserve or get
much sympathy.

Although we've only seen problems in HEAD, now that we recognize the
environmental dependencies it seems like it might be just a matter
of time until someone manages to hit this in back-branch testing.
Hence, back-patch to v11 where we started doing this kind of test.

Discussion: https://postgr.es/m/3192026.1648185780@sss.pgh.pa.us
src/bin/pg_basebackup/t/010_pg_basebackup.pl
src/test/perl/PostgresNode.pm