agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: Recheck checksum state before file_copy during CREATE DATABASE
2+ messages / 1 participants
[nested] [flat]

* pgsql: Recheck checksum state before file_copy during CREATE DATABASE
@ 2026-07-28 19:58  Daniel Gustafsson <dgustafsson@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Daniel Gustafsson @ 2026-07-28 19:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/153ca22a3a71ccaa55f27a4686202bce8f8de759

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Recheck checksum state before file_copy during CREATE DATABASE
@ 2026-07-28 19:59  Daniel Gustafsson <dgustafsson@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Daniel Gustafsson @ 2026-07-28 19:59 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(+)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-07-28 19:59 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-28 19:58 pgsql: Recheck checksum state before file_copy during CREATE DATABASE Daniel Gustafsson <dgustafsson@postgresql.org>
2026-07-28 19:59 pgsql: Recheck checksum state before file_copy during CREATE DATABASE Daniel Gustafsson <dgustafsson@postgresql.org>

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