From: ocean_li_996 <ocean_li_996@163.com>
To: cca5507 <cca5507@qq.com>
Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re:Re: [BUG] Incorrect historic snapshot may be serialized to disk during fast-forwarding
Date: Sun, 23 Nov 2025 14:33:14 +0800 (CST)
Message-ID: <5669a88e.eee.19aaf6aa83a.Coremail.ocean_li_996@163.com> (raw)
In-Reply-To: <tencent_95D13240784107B9768CA1DD851DB5B52908@qq.com>
References: <tencent_3A071B760AA1A38540B57F297332B7781C08@qq.com>
<1f1c51f3.4ed.19aae7e9de0.Coremail.ocean_li_996@163.com>
<tencent_95D13240784107B9768CA1DD851DB5B52908@qq.com>
Hi ChangAo,
At 2025-11-23 13:31:49, "cca5507" <cca5507@qq.com> wrote:
>> The patch in attachment is better for me. What do you think?
>
>The v2-0001 LGTM.
>
>A small suggestion:
>
>We should move the 'break' out of the 'if', because we don't want it fall through to XLOG_HEAP2_REWRITE if we are fast-forwarding.
Fair. The patch updated is provided in attachment.
Best regards,
Haiyang Li
Attachments:v3-0001-Handle-XLOG_HEAP2_NEW_CID-in-fast-forward.patch (application/octet-stream, 1.6K) downloaddiff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.cindex cc03f0706e9..4f5704354a6 100644--- a/src/backend/replication/logical/decode.c+++ b/src/backend/replication/logical/decode.c@@ -429,15 +429,23 @@ heap2_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
DecodeMultiInsert(ctx, buf);
break;
case XLOG_HEAP2_NEW_CID:
+ /*+ * we only log new_cid's if a catalog tuple was modified, so mark the+ * transaction as containing catalog modifications.+ * + * Note: we do this even in fast-forward mode, as we need to maintain+ * the snapshot correctly.+ */+ ReorderBufferXidSetCatalogChanges(ctx->reorder, xid, buf->origptr);+
if (!ctx->fast_forward)
{
xl_heap_new_cid *xlrec;
xlrec = (xl_heap_new_cid *) XLogRecGetData(buf->record);
SnapBuildProcessNewCid(builder, xid, buf->origptr, xlrec);
-- break;
}
+ break;
case XLOG_HEAP2_REWRITE:
/*
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.cindex 6e18baa33cb..9f78a881444 100644--- a/src/backend/replication/logical/snapbuild.c+++ b/src/backend/replication/logical/snapbuild.c@@ -691,12 +691,6 @@ SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
{
CommandId cid;
- /*- * we only log new_cid's if a catalog tuple was modified, so mark the- * transaction as containing catalog modifications- */- ReorderBufferXidSetCatalogChanges(builder->reorder, xid, lsn);-
ReorderBufferAddNewTupleCids(builder->reorder, xlrec->top_xid, lsn,
xlrec->target_locator, xlrec->target_tid,
xlrec->cmin, xlrec->cmax,
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: ocean_li_996@163.com, cca5507@qq.com
Subject: Re: [BUG] Incorrect historic snapshot may be serialized to disk during fast-forwarding
In-Reply-To: <5669a88e.eee.19aaf6aa83a.Coremail.ocean_li_996@163.com>
References: <tencent_3A071B760AA1A38540B57F297332B7781C08@qq.com> <1f1c51f3.4ed.19aae7e9de0.Coremail.ocean_li_996@163.com> <tencent_95D13240784107B9768CA1DD851DB5B52908@qq.com> <5669a88e.eee.19aaf6aa83a.Coremail.ocean_li_996@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