!6170 修复主机重启后延迟备建连慢的问题

Merge pull request !6170 from 胡正超/startwalrecv
This commit is contained in:
opengauss_bot
2024-09-02 02:16:14 +00:00
committed by Gitee

View File

@ -8174,6 +8174,28 @@ static bool CheckApplyDelayReady(void)
return true;
}
static void KeepWalrecvAliveWhenRecoveryDelay()
{
static TimestampTz lastTestWalrecvTime = (TimestampTz)0;
TimestampTz now = GetCurrentTimestamp();
if (!TimestampDifferenceExceeds(lastTestWalrecvTime, now, 1000)) { // 1s
return;
}
lastTestWalrecvTime = now;
if (WalRcvInProgress()) {
return;
}
if (g_instance.pid_cxt.BarrierPreParsePID != 0) {
return;
}
/* wake up walrecv by pre-parse thread */
g_instance.csn_barrier_cxt.pre_parse_started = false;
}
/*
* When recovery_min_apply_delay is set, we wait long enough to make sure
* certain record types are applied at least that interval behind the master.
@ -8199,6 +8221,8 @@ static bool RecoveryApplyDelay(const XLogReaderState *record)
return false;
}
KeepWalrecvAliveWhenRecoveryDelay();
/*
* Is it a COMMIT record?
* We deliberately choose not to delay aborts since they have no effect on
@ -8234,6 +8258,8 @@ static bool RecoveryApplyDelay(const XLogReaderState *record)
/* might change the trigger file's location */
RedoInterruptCallBack();
KeepWalrecvAliveWhenRecoveryDelay();
if (CheckForFailoverTrigger() || CheckForSwitchoverTrigger() || CheckForStandbyTrigger()) {
break;
}