]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Recheck checksum state before file_copy during CREATE DATABASE
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Tue, 28 Jul 2026 19:52:24 +0000 (21:52 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Tue, 28 Jul 2026 19:52:24 +0000 (21:52 +0200)
commit153ca22a3a71ccaa55f27a4686202bce8f8de759
tree7c7d9791ab5042b8294d520e23543da89da614c5
parentacaa100f9a0c8dbd20ef48b3ce8b94bb773d6acc
Recheck checksum state before file_copy during CREATE DATABASE

The file_copy strategy check in createdb() runs during option
validation, before the transaction has an XID and before the
pg_database row exists, so the datachecksumsworker launcher
can start in that window and see neither the new database nor
the transaction creating it.  It then raw-copies a template
that was not processed yet, and those files stay unchecksummed,
failing verification from then on.

Recheck the state in CreateDatabaseUsingFileCopy(): the XID is
assigned by then, so a launcher starting after this point waits
for the transaction and finds the new database, and the copy
errors out instead. Add an injection point before the catalog
insert to test the window.

Backpatch to v19 where online checksums were introduced.

Author: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAN4CZFPEBsz8JeY4ixQ1V4ZL_xOY6pJaZS8ZLGH7R+wF--pEtg@mail.gmail.com
Backpatch-through: 19
src/backend/commands/dbcommands.c
src/test/modules/test_checksums/t/005_injection.pl