pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedFrom: Andy Fan <zhihuifan1213@163.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: A assert failure when initdb with track_commit_timestamp=on
Date: Wed, 02 Jul 2025 00:38:01 +0000
Message-ID: <87plejmnpy.fsf@163.com> (raw)
Hi,
When working with the commit_ts module, I find the following issue:
After configure with --enable-cassert option, then initdb with:
initdb -D x2 -c track_commit_timestamp=on
Then we can get the following core dump:
0 in raise of /lib/x86_64-linux-gnu/libc.so.6
1 in abort of /lib/x86_64-linux-gnu/libc.so.6
2 in ExceptionalCondition of assert.c:66
3 in TransactionIdSetCommitTs of commit_ts.c:257
4 in SetXidCommitTsInPage of commit_ts.c:236
5 in TransactionTreeSetCommitTsData of commit_ts.c:192
6 in RecordTransactionCommit of xact.c:1468
7 in CommitTransaction of xact.c:2365
8 in CommitTransactionCommandInternal of xact.c:3202
9 in CommitTransactionCommand of xact.c:3163
10 in BootstrapModeMain of bootstrap.c:390
11 in main of main.c:210
The reason are TransactionIdSetCommitTs think the given xid must be
normal
static void
TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno)
{
...
Assert(TransactionIdIsNormal(xid));
}
However this is not true in BootstrapMode, this failure is masked by
default because TransactionTreeSetCommitTsData returns fast when
track_commit_timestamp is off.
void
TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz timestamp,
RepOriginId nodeid)
{
/*
* No-op if the module is not active.
*
*/
if (!commitTsShared->commitTsActive)
return;
..
}
I can't think out a meaningful reason to record the commit timestamp for a
BootstrapTransactionId or FrozenTransactionId, so I think bypass it in
TransactionTreeSetCommitTsData could be a solution. Another solution is
just removing the Assert in TransactionIdSetCommitTs, it works during
initdb test at least.
I include both fixes in the attachment, I think just one of them could
be adopted however.
--
Best Regards
Andy Fan
Attachments:
[text/x-diff] v1-0001-Fix-the-Assert-failure-when-initdb-with-track_com.patch (1.3K, ../87plejmnpy.fsf@163.com/2-v1-0001-Fix-the-Assert-failure-when-initdb-with-track_com.patch)
download | inline diff:
From b5e921ef42763dbb1126d60313b25ae40f8ec140 Mon Sep 17 00:00:00 2001
From: Andy Fan <zhihuifan1213@163.com>
Date: Tue, 1 Jul 2025 23:50:37 +0000
Subject: [PATCH v1 1/1] Fix the Assert failure when initdb with
track_commit_timestamp=on
the real commit message depends on which solution is adopted.
---
src/backend/access/transam/commit_ts.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 113fae1437a..da8bfb7167c 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -157,6 +157,13 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
if (!commitTsShared->commitTsActive)
return;
+ /*
+ * There is no point to record a commit_ts for BootStrapCommitTs or
+ * FrozenTransactionId.
+ */
+ if (unlikely(xid == BootstrapTransactionId || xid == FrozenTransactionId))
+ return;
+
/*
* Figure out the latest Xid in this batch: either the last subxid if
* there's any, otherwise the parent xid.
@@ -252,8 +259,6 @@ TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
int entryno = TransactionIdToCTsEntry(xid);
CommitTimestampEntry entry;
- Assert(TransactionIdIsNormal(xid));
-
entry.time = ts;
entry.nodeid = nodeid;
--
2.45.1
view thread (28+ messages) latest in thread
Message-ID: <87plejmnpy.fsf@163.com>
Permalink: ../87plejmnpy.fsf@163.com/
Also on: postgresql.org/message-id/87plejmnpy.fsf@163.com
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-hackers@postgresql.org
Cc: zhihuifan1213@163.com
Subject: Re: A assert failure when initdb with track_commit_timestamp=on
In-Reply-To: <87plejmnpy.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