]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Disable commit timestamps during bootstrap REL_17_STABLE github/REL_17_STABLE
authorMichael Paquier <michael@paquier.xyz>
Fri, 4 Jul 2025 06:10:19 +0000 (15:10 +0900)
committerMichael Paquier <michael@paquier.xyz>
Fri, 4 Jul 2025 06:10:19 +0000 (15:10 +0900)
Attempting to use commit timestamps during bootstrapping leads to an
assertion failure, that can be reached for example with an initdb -c
that enables track_commit_timestamp.  It makes little sense to register
a commit timestamp for a BootstrapTransactionId, so let's disable the
activation of the module in this case.

This problem has been independently reported once by each author of this
commit.  Each author has proposed basically the same patch, relying on
IsBootstrapProcessingMode() to skip the use of commit_ts during
bootstrap.  The test addition is a suggestion by me, and is applied down
to v16.

Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Author: Andy Fan <zhihuifan1213@163.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/OSCPR01MB14966FF9E4C4145F37B937E52F5102@OSCPR01MB14966.jpnprd01.prod.outlook.com
Discussion: https://postgr.es/m/87plejmnpy.fsf@163.com
Backpatch-through: 13

src/backend/access/transam/commit_ts.c
src/test/modules/commit_ts/t/001_base.pl

index 77e1899d7ad218501fa993301993e78657e93871..86a295ca9b19583ddb73a919f3cd6c61113b589b 100644 (file)
@@ -707,6 +707,13 @@ ActivateCommitTs(void)
        TransactionId xid;
        int64           pageno;
 
+       /*
+        * During bootstrap, we should not register commit timestamps so skip the
+        * activation in this case.
+        */
+       if (IsBootstrapProcessingMode())
+               return;
+
        /* If we've done this already, there's nothing to do */
        LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
        if (commitTsShared->commitTsActive)
index e608ec67704afbcb77cfca7f14d422a8c9b6e88f..638e3f15cec9df7e09fbcd347a5d732ae4b25212 100644 (file)
@@ -11,8 +11,7 @@ use Test::More;
 use PostgreSQL::Test::Cluster;
 
 my $node = PostgreSQL::Test::Cluster->new('foxtrot');
-$node->init;
-$node->append_conf('postgresql.conf', 'track_commit_timestamp = on');
+$node->init(extra => [ '-c', "track_commit_timestamp=on" ]);
 $node->start;
 
 # Create a table, compare "now()" to the commit TS of its xmin