From ec386db3974d90c38d2206d967cb8ce322e912f7 Mon Sep 17 00:00:00 2001 From: luozihao <1165977584@qq.com> Date: Tue, 14 Dec 2021 19:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dswitchover=E5=A4=87=E5=8D=87?= =?UTF-8?q?=E4=B8=BB=E6=96=B0=E4=B8=BB=E6=9C=BAcore=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/process/postmaster/pgarch.cpp | 9 +++++++++ src/gausskernel/process/postmaster/postmaster.cpp | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gausskernel/process/postmaster/pgarch.cpp b/src/gausskernel/process/postmaster/pgarch.cpp index 93032cfe..327e823a 100644 --- a/src/gausskernel/process/postmaster/pgarch.cpp +++ b/src/gausskernel/process/postmaster/pgarch.cpp @@ -430,6 +430,15 @@ static void pgarch_MainLoop(void) if (time_to_stop) { continue; } + + /* + * cannot send archive task if we don't acquire an archive slot. + */ + if (t_thrd.slot_cxt.MyReplicationSlot == NULL) { + ereport(LOG, (errmsg("there is no slot to flush, exit the archvier"))); + break; + } + gettimeofday(&curtime, NULL); const long time_diff = TIME_GET_MILLISEC(curtime) - t_thrd.arch.last_arch_time; XLogRecPtr receivePtr; diff --git a/src/gausskernel/process/postmaster/postmaster.cpp b/src/gausskernel/process/postmaster/postmaster.cpp index 7a0bfbd2..93f720d0 100755 --- a/src/gausskernel/process/postmaster/postmaster.cpp +++ b/src/gausskernel/process/postmaster/postmaster.cpp @@ -2788,7 +2788,8 @@ static int ServerLoop(void) if (g_instance.pid_cxt.PgArchPID == 0 && !dummyStandbyMode) { obs_slot = getObsReplicationSlot(); if ((XLogArchivingActive() && pmState == PM_RUN) || - ((pmState == PM_RUN || pmState == PM_HOT_STANDBY) && obs_slot != NULL)) { + ((pmState == PM_RUN || pmState == PM_HOT_STANDBY) && obs_slot != NULL && + get_local_dbstate() == NORMAL_STATE)) { g_instance.pid_cxt.PgArchPID = pgarch_start(); } } @@ -5420,7 +5421,8 @@ static void reaper(SIGNAL_ARGS) if (g_instance.pid_cxt.PgArchPID == 0 && !dummyStandbyMode) { obs_slot = getObsReplicationSlot(); if ((XLogArchivingActive() && pmState == PM_RUN) || - ((pmState == PM_RUN || pmState == PM_HOT_STANDBY) && obs_slot != NULL)) { + ((pmState == PM_RUN || pmState == PM_HOT_STANDBY) && obs_slot != NULL && + get_local_dbstate() == NORMAL_STATE)) { g_instance.pid_cxt.PgArchPID = pgarch_start(); } }