Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uWmQp-001K9v-21 for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Jul 2025 01:38:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uWmQm-009C9f-HC for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Jul 2025 01:38:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uWmQl-009C9F-Ih for pgsql-hackers@lists.postgresql.org; Wed, 02 Jul 2025 01:38:36 +0000 Received: from m16.mail.163.com ([220.197.31.3]) by makus.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1uWmQf-005354-06 for pgsql-hackers@postgresql.org; Wed, 02 Jul 2025 01:38:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version: Content-Type; bh=sQNplTqgnQI3s6BxsgOvGxh2IitCCHQHJlXpYmhHp+Y=; b=IOodYZmnmyqw+EXYiSrtNeKsE5P/6vBjkpkz7Jkpjq8mVL3yArmpC2luMX3KTE FeMMZZhf7tseIYYM8sI6dyJk+gFYc398ZGmBxbgft0zCNfPOCDhgfwLeTH0PY7B9 Oa+wS0PZy1fZtemsG4lFAN3Hq6vhbFjsQzg2+Li3CbxFM= Received: from lovely-coding (unknown []) by gzga-smtp-mtada-g1-0 (Coremail) with SMTP id _____wDnQAuKjWRor34ZCA--.61128S3; Wed, 02 Jul 2025 09:38:19 +0800 (CST) From: Andy Fan To: Michael Paquier Cc: PostgreSQL Hackers Subject: Re: A assert failure when initdb with track_commit_timestamp=on In-Reply-To: (Michael Paquier's message of "Wed, 2 Jul 2025 09:46:42 +0900") References: <87plejmnpy.fsf@163.com> Date: Wed, 02 Jul 2025 01:38:18 +0000 Message-ID: <87ikkbmkxh.fsf@163.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-CM-TRANSID: _____wDnQAuKjWRor34ZCA--.61128S3 X-Coremail-Antispam: 1Uf129KBjvJXoWruF4DXr1DCF43XFW3ZF18Xwb_yoW8Jr15pa y2yw1jgr1vqrWIqrn7Ga18XF40yrn7XrW3ZFy5tryDC3yrCFy0kFsYqryYyFyj9FZ5Aay2 qF1vyryrC398ZaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRFeHPUUUUU= X-Originating-IP: [113.250.190.7] X-CM-SenderInfo: x2klx3xlid0iqsrtqiywtou0bp/xtbBhQF+U2hkhtKgnAAAsN List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain Michael Paquier writes: Hi, > On Wed, Jul 02, 2025 at 12:38:01AM +0000, Andy Fan wrote: >> However this is not true in BootstrapMode, this failure is masked by >> default because TransactionTreeSetCommitTsData returns fast when >> track_commit_timestamp is off. > > Agreed that there is no point in registering a commit timestamp in > the cases of a frozen and bootstrap XIDs. I would recommend to keep > the assertion in TransactionIdSetCommitTs(), though, that still looks > useful to me for the many callers of this routine, at least as a > sanity check. Yes, The assert also guard the InvalidTransactionId. So I removed this solution in v2. Another reason for this is: if we allowed BooststrapTransactionId in the commit_ts, it introduces something new to this module when initdb with track_commit_timestamp=on. This risk might be very low, but it can be avoided easily with the another solution. > > I did not check, but usually we apply filters based on > IsBootstrapProcessingMode() for code paths that we do not want to > reach while in bootstrap mode. Could the same be done here? I think you are right. so I used IsBootstrapProcessingMode in v2. -- Best Regards Andy Fan --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0001-Don-t-record-commit_ts-in-bootstarp-mode.patch From def54f2c6a73aec74aebde9b687612f65a8bcdd5 Mon Sep 17 00:00:00 2001 From: Andy Fan 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 --=-=-=--