!1001 修复JDBC连接备机解码,lsn回推问题

Merge pull request !1001 from maxiang/2.0.0
This commit is contained in:
opengauss-bot 2021-05-29 18:10:51 +08:00 committed by Gitee
commit e8cfcb6913
2 changed files with 8 additions and 14 deletions

View File

@ -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. */

View File

@ -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. */