0001-Fix-stale-snapshot-issue.patch
application/octet-stream
Filename: 0001-Fix-stale-snapshot-issue.patch
Type: application/octet-stream
Part: 0
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: Fix stale snapshot issue
| File | + | − |
|---|---|---|
| src/backend/replication/logical/snapbuild.c | 13 | 0 |
From 4be607984333427111af1bb289d7762ba4082537 Mon Sep 17 00:00:00 2001
From: Ajin Cherian <itsajin@gmail.com>
Date: Fri, 20 Jun 2025 03:37:40 -0400
Subject: [PATCH] Fix stale snapshot issue
Make sure logical replication does not use snapshots that are built prior to becoming
consistent to avoid stale snapshots causing catalog lookup errors.
---
src/backend/replication/logical/snapbuild.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index adf18c3..642c986 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -677,6 +677,19 @@ SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
builder->snapshot);
}
+ /*
+ * Forget snapshots built before the SNAPBUILD_CONSISTENT state,
+ * so that we rebuild them when we become consistent.
+ */
+ if (builder->state == SNAPBUILD_FULL_SNAPSHOT)
+ {
+ if (builder->snapshot)
+ {
+ SnapBuildSnapDecRefcount(builder->snapshot);
+ builder->snapshot = NULL;
+ }
+ }
+
return true;
}
--
1.8.3.1