From: Andy Fan <zhihuifan1213@163.com>
To: Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: A assert failure when initdb with track_commit_timestamp=on
Date: Thu, 03 Jul 2025 13:31:23 +0000
Message-ID: <87o6u19z9w.fsf@163.com> (raw)
In-Reply-To: <OSCPR01MB14966207D000875CA4F4C9FEAF543A@OSCPR01MB14966.jpnprd01.prod.outlook.com>
References: <87plejmnpy.fsf@163.com>
<1f8f703d-72e8-4d05-ab16-ff0403a1d19d@oss.nttdata.com>
<aGXZL0oraweaENrF@paquier.xyz>
<OSCPR01MB14966207D000875CA4F4C9FEAF543A@OSCPR01MB14966.jpnprd01.prod.outlook.com>
"Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com> writes:
> Dear Michael, Fujii-san,
>
>> Ah, indeed, so it was reported a couple of months ago. I am not sure
>> that the argument about all the other GUCs potentially impacted holds
>> much value; we are talking about a specific code path.
>
> Yeah, I did report but sadly it was missed by others :-(. To clarify,
> The current patch looks good to me.
Then I'd thank Michael to watch the maillist closely this time.
I checked the fix suggested by Hayato, I think his patch is better than
me because his patch checks at the startup time while my patch checks at
each time of RecordTransactionCommit. So v3 takes his patch. v3 also
added the testcase suggested by Michael for test coverage, it clearly
proves the bug is fixed now.
--
Best Regards
Andy Fan
Attachments:
[text/x-diff] v3-0001-Avoid-activating-commit_ts-while-bootstrap.patch (2.2K, ../87o6u19z9w.fsf@163.com/2-v3-0001-Avoid-activating-commit_ts-while-bootstrap.patch)
download | inline diff:
From dab43830af019896ef1811aeeeb5d1e4e2bcccea Mon Sep 17 00:00:00 2001
From: Andy Fan <zhihuifan1213@163.com>
Date: Thu, 3 Jul 2025 13:04:02 +0000
Subject: [PATCH v3 1/1] Avoid activating commit_ts while bootstrap.
TransactionIdSetCommitTs had an Assert failure when initdb with
track_commit_timestamp=on before this commit because it thought all the
provided xids are normal xid. So avoiding the activating commit_ts in
bootstrap mode could fix this issue. Test case is also enhanced to
discover this issue.
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Author: Andy Fan <zhihuifan1213@163.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Discussion: https://postgr.es/m/OSCPR01MB14966FF9E4C4145F37B937E52F5102@OSCPR01MB14966.jpnprd01.prod.outlook.com
Discussion: https://postgr.es/m/87plejmnpy.fsf%40163.com
---
src/backend/access/transam/commit_ts.c | 7 +++++++
src/test/modules/commit_ts/t/001_base.pl | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.cindex 113fae1437a..15078698cf9 100644--- a/src/backend/access/transam/commit_ts.c+++ b/src/backend/access/transam/commit_ts.c@@ -707,6 +707,13 @@ ActivateCommitTs(void)
TransactionId xid;
int64 pageno;
+ /*+ * commit_ts assumes that we are not in the bootstrap mode: skip the+ * activation.+ */+ if (IsBootstrapProcessingMode())+ return;+
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
if (commitTsShared->commitTsActive)
diff --git a/src/test/modules/commit_ts/t/001_base.pl b/src/test/modules/commit_ts/t/001_base.plindex 1953b18f6b3..91983fc5179 100644--- a/src/test/modules/commit_ts/t/001_base.pl+++ b/src/test/modules/commit_ts/t/001_base.pl@@ -11,7 +11,7 @@ use Test::More;
use PostgreSQL::Test::Cluster;
my $node = PostgreSQL::Test::Cluster->new('foxtrot');
-$node->init;+$node->init(extra => ['-c', "track_commit_timestamp=on"]);
$node->append_conf('postgresql.conf', 'track_commit_timestamp = on');
$node->start;
--
2.45.1
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-hackers@postgresql.org
Cc: zhihuifan1213@163.com, kuroda.hayato@fujitsu.com, michael@paquier.xyz, masao.fujii@oss.nttdata.com
Subject: Re: A assert failure when initdb with track_commit_timestamp=on
In-Reply-To: <87o6u19z9w.fsf@163.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox