diff --git a/src/gausskernel/storage/replication/logical/logical.cpp b/src/gausskernel/storage/replication/logical/logical.cpp index 127c6e69d..3924db918 100644 --- a/src/gausskernel/storage/replication/logical/logical.cpp +++ b/src/gausskernel/storage/replication/logical/logical.cpp @@ -825,6 +825,14 @@ void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr re */ void LogicalConfirmReceivedLocation(XLogRecPtr lsn) { + /* + * Check if the slot is not moving backwards. Logical slots have confirmed + * consumption up to confirmed_lsn, meaning that data older than that is + * not available anymore. + */ + if (XLByteLE(lsn, t_thrd.slot_cxt.MyReplicationSlot->data.confirmed_flush)) + return; + Assert(!XLByteEQ(lsn, InvalidXLogRecPtr)); (void)LWLockAcquire(LogicalReplicationSlotPersistentDataLock, LW_EXCLUSIVE); /* Do an unlocked check for candidate_lsn first. */