diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c index 79d7a57d67..e8b76b2f20 100644 --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@ -999,6 +999,7 @@ ReplicationSlotReserveWal(void) while (true) { XLogSegNo segno; + XLogRecPtr restart_lsn; /* * For logical slots log a standby snapshot and start logical decoding @@ -1016,8 +1017,9 @@ ReplicationSlotReserveWal(void) XLogRecPtr flushptr; /* start at current insert position */ + restart_lsn = GetXLogInsertRecPtr(); SpinLockAcquire(&slot->mutex); - slot->data.restart_lsn = GetXLogInsertRecPtr(); + slot->data.restart_lsn = restart_lsn; SpinLockRelease(&slot->mutex); /* make sure we have enough information to start */ @@ -1028,8 +1030,9 @@ ReplicationSlotReserveWal(void) } else { + restart_lsn = GetRedoRecPtr(); SpinLockAcquire(&slot->mutex); - slot->data.restart_lsn = GetRedoRecPtr(); + slot->data.restart_lsn = restart_lsn; SpinLockRelease(&slot->mutex); }