修复switchover备升主新主机core的bug

This commit is contained in:
luozihao 2021-12-14 19:31:59 +08:00
parent ee30a37bb3
commit ec386db397
2 changed files with 13 additions and 2 deletions

View File

@ -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;

View File

@ -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();
}
}