From 2fc8dc66a5c77a3b86f25daefdbbc8015dd7ac2f Mon Sep 17 00:00:00 2001
From: Zhijie Hou <houzj.fnst@fujitsu.com>
Date: Tue, 25 Nov 2025 16:08:35 +0800
Subject: [PATCH v1] Fix a BF failure where a replication slot was not released
 in time

The commit 76b7872 did not release the replication slot in the slotsync worker
when a cycle of slot synchronization was skipped due to the required WAL not
being received and flushed on the standby server. This commit fixes that
issue.
---
 src/backend/replication/logical/slotsync.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c
index 7e9dc7f18bd..1f4f06d467b 100644
--- a/src/backend/replication/logical/slotsync.c
+++ b/src/backend/replication/logical/slotsync.c
@@ -725,6 +725,8 @@ synchronize_one_slot(RemoteSlot *remote_slot, Oid remote_dbid)
 						   remote_slot->name,
 						   LSN_FORMAT_ARGS(latestFlushPtr)));
 
+			ReplicationSlotRelease();
+
 			return slot_updated;
 		}
 
@@ -824,6 +826,8 @@ synchronize_one_slot(RemoteSlot *remote_slot, Oid remote_dbid)
 						   remote_slot->name,
 						   LSN_FORMAT_ARGS(latestFlushPtr)));
 
+			ReplicationSlotRelease();
+
 			return false;
 		}
 
-- 
2.51.1.windows.1

