v84_0001_amit_1.patch.txt

text/plain

Filename: v84_0001_amit_1.patch.txt
Type: text/plain
Part: 0
Message: Re: Synchronizing slots from primary to standby
diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c
index b925c7fe7d..06103d6837 100644
--- a/src/backend/replication/logical/slotsync.c
+++ b/src/backend/replication/logical/slotsync.c
@@ -80,8 +80,8 @@ typedef struct RemoteSlot
 } RemoteSlot;
 
 /*
- * If necessary, update local synced slot metadata based on the data from the
- * remote slot.
+ * If necessary, update the local synced slot's metadata based on the data
+ * from the remote slot.
  *
  * If no update was needed (the data of the remote slot is the same as the
  * local slot) return false, otherwise true.
@@ -99,7 +99,8 @@ update_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid)
 	xmin_changed = (remote_slot->catalog_xmin != slot->data.catalog_xmin);
 	restart_lsn_changed = (remote_slot->restart_lsn != slot->data.restart_lsn);
 
-	if (!xmin_changed && !restart_lsn_changed &&
+	if (!xmin_changed &&
+		!restart_lsn_changed &&
 		remote_dbid == slot->data.database &&
 		remote_slot->two_phase == slot->data.two_phase &&
 		remote_slot->failover == slot->data.failover &&
@@ -131,7 +132,7 @@ update_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid)
 }
 
 /*
- * Get the list of local logical slots which are synchronized from the
+ * Get the list of local logical slots that are synchronized from the
  * primary server.
  */
 static List *
@@ -302,7 +303,7 @@ reserve_wal_for_local_slot(XLogRecPtr restart_lsn)
 		 * Normally, we can determine it by using the last removed segment
 		 * number. However, if no WAL segment files have been removed by a
 		 * checkpoint since startup, we need to search for the oldest segment
-		 * file currently existing in XLOGDIR.
+		 * file from the current timeline existing in XLOGDIR.
 		 */
 		oldest_segno = XLogGetLastRemovedSegno() + 1;
 
@@ -353,7 +354,7 @@ update_and_persist_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid)
 		 * We do not drop the slot because the restart_lsn can be ahead of the
 		 * 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 wait and synchronization in the next cycle.
+		 * and attempt the synchronization in the next cycle.
 		 */
 		return;
 	}
@@ -736,7 +737,7 @@ validate_primary_slot_name(WalReceiverConn *wrconn)
 
 /*
  * Check all necessary GUCs for slot synchronization are set
- * appropriately, otherwise raise ERROR.
+ * appropriately, otherwise, raise ERROR.
  */
 void
 ValidateSlotSyncParams(void)
@@ -768,10 +769,7 @@ ValidateSlotSyncParams(void)
 				errmsg("bad configuration for slot synchronization"),
 				errhint("\"%s\" must be enabled.", "hot_standby_feedback"));
 
-	/*
-	 * Logical decoding requires wal_level >= logical and we currently only
-	 * synchronize logical slots.
-	 */
+	/* Logical slot sync/creation requires wal_level >= logical. */
 	if (wal_level < WAL_LEVEL_LOGICAL)
 		ereport(ERROR,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 04738ab764..7df22a0251 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -738,7 +738,7 @@ ReplicationSlotAlter(const char *name, bool failover)
 
 	/*
 	 * Do not allow users to enable failover for temporary slots as we do not
-	 * support sync temporary slots to the standby.
+	 * support syncing temporary slots to the standby.
 	 */
 	if (failover && MyReplicationSlot->data.persistency == RS_TEMPORARY)
 		ereport(ERROR,