diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c index 3217bd8929d..80ea90048ee 100644 --- a/src/backend/replication/logical/slotsync.c +++ b/src/backend/replication/logical/slotsync.c @@ -535,13 +535,13 @@ drop_local_obsolete_slots(List *remote_slot_list) /* * Reserve WAL for the currently active local slot using the specified WAL - * location (restart_lsn). + * location (restart_lsn on the remote). * * If the given WAL location has been removed or is at risk of being removed, * reserve WAL using the oldest segment that is non-removable. */ static void -reserve_wal_for_local_slot(XLogRecPtr restart_lsn) +reserve_wal_for_local_slot(XLogRecPtr restart_lsn_on_remote) { XLogRecPtr slot_min_lsn; XLogRecPtr min_safe_lsn; @@ -558,14 +558,14 @@ reserve_wal_for_local_slot(XLogRecPtr restart_lsn) * first, the checkpoint must wait for the restart_lsn update before * calculating the minimum LSN. * - * Note: Unlike in ReplicationSlotReserveWal(), this lock does not protect a - * newly synced slot if a concurrent checkpoint has invoked + * Note: Unlike in ReplicationSlotReserveWal(), this lock does not protect + * a newly synced slot if a concurrent checkpoint has invoked * CheckPointReplicationSlots() before the WAL reservation here. This is * because the initial restart_lsn received from the remote server may be * outdated, preceding the redo pointer. Therefore, when selecting the * initial restart_lsn, we might use the redo pointer or the minimum slot - * LSN (if those values are greater than the remote restart_lsn) instead of - * relying solely on the remote value. + * LSN (if those values are greater than the remote restart_lsn) instead + * of relying solely on the remote value. */ LWLockAcquire(ReplicationSlotAllocationLock, LW_EXCLUSIVE); @@ -580,14 +580,14 @@ reserve_wal_for_local_slot(XLogRecPtr restart_lsn) min_safe_lsn = slot_min_lsn; /* - * If the minimum safe LSN is greater than the given restart_lsn, use it as - * the initial restart_lsn for the newly synced slot. + * If the minimum safe LSN is greater than the given restart_lsn on the + * remote, use it as the initial restart_lsn for the newly synced slot. */ - if (min_safe_lsn > restart_lsn) - restart_lsn = min_safe_lsn; + if (min_safe_lsn > restart_lsn_on_remote) + min_safe_lsn = restart_lsn_on_remote; SpinLockAcquire(&slot->mutex); - slot->data.restart_lsn = restart_lsn; + slot->data.restart_lsn = min_safe_lsn; SpinLockRelease(&slot->mutex); ReplicationSlotsComputeRequiredLSN();