From ffd3ded9868b90a7d9b4b0d87917d233b6450ce6 Mon Sep 17 00:00:00 2001 From: gentle_hu Date: Thu, 29 Aug 2024 15:16:19 +0800 Subject: [PATCH] delay redo connect --- .../storage/access/transam/xlog.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/gausskernel/storage/access/transam/xlog.cpp b/src/gausskernel/storage/access/transam/xlog.cpp index 800ea10ca..e0b76b320 100755 --- a/src/gausskernel/storage/access/transam/xlog.cpp +++ b/src/gausskernel/storage/access/transam/xlog.cpp @@ -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; }