From ef48e48294d4cda2365d119fd717a3aa79c6bba7 Mon Sep 17 00:00:00 2001 From: maxiang Date: Sat, 29 May 2021 10:17:14 +0800 Subject: [PATCH 1/2] update src/gausskernel/storage/replication/walsender.cpp. --- src/gausskernel/storage/replication/walsender.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/gausskernel/storage/replication/walsender.cpp b/src/gausskernel/storage/replication/walsender.cpp index f184ed514..e1cfbb739 100644 --- a/src/gausskernel/storage/replication/walsender.cpp +++ b/src/gausskernel/storage/replication/walsender.cpp @@ -1419,7 +1419,6 @@ static void AdvanceLogicalReplication(AdvanceReplicationCmd *cmd) { StringInfoData buf; XLogRecPtr flushRecPtr; - XLogRecPtr minLsn; char xpos[MAXFNAMELEN]; int rc = 0; @@ -1450,19 +1449,6 @@ static void AdvanceLogicalReplication(AdvanceReplicationCmd *cmd) Assert(OidIsValid(t_thrd.slot_cxt.MyReplicationSlot->data.database)); - /* - * 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. - */ - minLsn = t_thrd.slot_cxt.MyReplicationSlot->data.confirmed_flush; - if (XLByteLT(cmd->confirmed_flush, minLsn)) { - ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move slot to %X/%X, minimum is %X/%X", - (uint32)(cmd->confirmed_flush >> 32), (uint32)cmd->confirmed_flush, - (uint32)(minLsn >> 32), (uint32)(minLsn)))); - } - LogicalConfirmReceivedLocation(cmd->confirmed_flush); /* Advance the restart_lsn in primary. */ From 6f90fd61ef37610a9ed768d9883d6652dc1d8024 Mon Sep 17 00:00:00 2001 From: maxiang Date: Sat, 29 May 2021 10:18:28 +0800 Subject: [PATCH 2/2] update src/gausskernel/storage/replication/logical/logical.cpp. --- src/gausskernel/storage/replication/logical/logical.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) 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. */