0001-add-comments-for-txns-without-base-snapshot.patch

application/octet-stream

Filename: 0001-add-comments-for-txns-without-base-snapshot.patch
Type: application/octet-stream
Part: 0
Message: RE: long-standing data loss bug in initial sync of logical replication

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0001
Subject: add comments for txns without base snapshot
File+
src/backend/replication/logical/snapbuild.c 9 0
From 8e26f5f06124aba8f12d89e549e47ada7aa6329e Mon Sep 17 00:00:00 2001
From: Hou Zhijie <houzj.fnst@cn.fujitsu.com>
Date: Thu, 27 Feb 2025 16:06:11 +0800
Subject: [PATCH] add comments for txns without base snapshot

---
 src/backend/replication/logical/snapbuild.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index 1716340799b..6917ca27181 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -752,6 +752,15 @@ SnapBuildDistributeSnapshotAndInval(SnapBuild *builder, XLogRecPtr lsn, Transact
 		 * transaction which in turn implies we don't yet need a snapshot at
 		 * all. We'll add a snapshot when the first change gets queued.
 		 *
+		 * Moreover, distributing invalidations to this transaction at this
+		 * stage is unnecessary. Once a base snapshot is built, it will
+		 * naturally include the xids of committed transactions that have
+		 * modified the catalog, thus reflecting the new catalog contents. The
+		 * existing catalog cache will have already been invalidated after
+		 * processing the invalidations in the transaction that modified
+		 * catalogs, ensuring that a fresh cache is constructed during
+		 * decoding.
+		 *
 		 * NB: This works correctly even for subtransactions because
 		 * ReorderBufferAssignChild() takes care to transfer the base snapshot
 		 * to the top-level transaction, and while iterating the changequeue
-- 
2.30.0.windows.2