From 8898a056761b56cd62c78f2749b64b3ea1fc9e88 Mon Sep 17 00:00:00 2001
From: Hou Zhijie <houzj.fnst@cn.fujitsu.com>
Date: Thu, 15 Feb 2024 11:17:43 +0800
Subject: [PATCH v3 1/3] Add a log if remote slot didn't catch up to locally
 reserved position

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

diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c
index 0aa1bf1ad2..03536fe273 100644
--- a/src/backend/replication/logical/slotsync.c
+++ b/src/backend/replication/logical/slotsync.c
@@ -361,7 +361,18 @@ update_and_persist_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid)
 		 * current location when recreating the slot in the next cycle. It may
 		 * take more time to create such a slot. Therefore, we keep this slot
 		 * and attempt the synchronization in the next cycle.
+		 *
+		 * XXX should this be changed to elog(DEBUG1) perhaps?
 		 */
+		ereport(LOG,
+				errmsg("could not sync slot information as remote slot precedes local slot:"
+					   " remote slot \"%s\": LSN (%X/%X), catalog xmin (%u) local slot: LSN (%X/%X), catalog xmin (%u)",
+					   remote_slot->name,
+					   LSN_FORMAT_ARGS(remote_slot->restart_lsn),
+					   remote_slot->catalog_xmin,
+					   LSN_FORMAT_ARGS(slot->data.restart_lsn),
+					   slot->data.catalog_xmin));
+
 		return;
 	}
 
-- 
2.34.1

