pgsql: Recheck checksum state before file_copy during CREATE DATABASE - Mailing list pgsql-committers

From Daniel Gustafsson
Subject pgsql: Recheck checksum state before file_copy during CREATE DATABASE
Date
Msg-id E1wonxa-00000000hhE-3L4k@gemulon.postgresql.org
Whole thread
List pgsql-committers
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(+)


pgsql-committers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: pgsql: Recheck checksum state before file_copy during CREATE DATABASE
Next
From: Tom Lane
Date:
Subject: pgsql: Fix planner's nullability/strictness logic for ScalarArrayOpExpr