agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Daniel Gustafsson <dgustafsson@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Recheck checksum state before file_copy during CREATE DATABASE
Date: Tue, 28 Jul 2026 19:59:30 +0000
Message-ID: <E1wonxa-00000000hhE-3L4k@gemulon.postgresql.org> (raw)

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

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9eb77f9fc80db071b434aea58681ed2adb9038d3

Modified Files
--------------
src/backend/commands/dbcommands.c                  | 28 +++++++++
src/test/modules/test_checksums/t/005_injection.pl | 68 ++++++++++++++++++++++
2 files changed, 96 insertions(+)



view thread (2+ messages)

Message-ID: <E1wonxa-00000000hhE-3L4k@gemulon.postgresql.org>
Permalink:  ../E1wonxa-00000000hhE-3L4k@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wonxa-00000000hhE-3L4k@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: dgustafsson@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Recheck checksum state before file_copy during CREATE DATABASE
  In-Reply-To: <E1wonxa-00000000hhE-3L4k@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox