From def54f2c6a73aec74aebde9b687612f65a8bcdd5 Mon Sep 17 00:00:00 2001
From: Andy Fan <zhihuifan1213@163.com>
Date: Wed, 2 Jul 2025 01:23:34 +0000
Subject: [PATCH v2 1/1] Don't record commit_ts in bootstarp mode.

This case would raise Assert failure in TransactionIdSetCommitTs  when
initdb with track_commit_timestamp=on.

Another option might be allowing BooststrapTransactionId in
TransactionIdSetCommitTs, but this adds a new change in
commit_ts module, which risk could be avoided easily with current
solution.
---
 src/backend/access/transam/commit_ts.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 113fae1437a..1aa2dc450f5 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -157,6 +157,12 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
 	if (!commitTsShared->commitTsActive)
 		return;
 
+	/*
+	 * Don't bother to record commit_ts for Booststrap mode.
+	 */
+	if (IsBootstrapProcessingMode())
+		return;
+
 	/*
 	 * Figure out the latest Xid in this batch: either the last subxid if
 	 * there's any, otherwise the parent xid.
-- 
2.45.1

