clear_candidate_fields.patch

application/octet-stream

Filename: clear_candidate_fields.patch
Type: application/octet-stream
Part: 3
Message: Re: WAL segments removed from primary despite the fact that logical replication slot needs it.

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: unified
File+
src/backend/replication/slot.c 9 0
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index f286918f69..18b4abbb4c 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -560,6 +560,15 @@ ReplicationSlotRelease(void)
 		ReplicationSlotDropAcquired();
 	}
 
+	/*
+	 * Clear the candidate_xxx fields so we don't use the old values
+	 * in the next time.
+	 */
+	slot->candidate_catalog_xmin = InvalidTransactionId;
+	slot->candidate_xmin_lsn = InvalidXLogRecPtr;
+	slot->candidate_restart_valid = InvalidXLogRecPtr;
+	slot->candidate_restart_lsn = InvalidXLogRecPtr;
+
 	/*
 	 * If slot needed to temporarily restrain both data and catalog xmin to
 	 * create the catalog snapshot, remove that temporary constraint.