dr switchover hadr_num check fix

Offering: openGaussDev

More detail: 可选

Match-id-574e112e6d668adeb6d802a4a773b48952149bb2
This commit is contained in:
openGaussDev
2023-08-07 20:09:36 +08:00
committed by yanghao
parent cbd421ece5
commit 2e41c8d417

View File

@ -2046,6 +2046,23 @@ Datum gs_streaming_dr_in_switchover(PG_FUNCTION_ARGS)
Datum gs_streaming_dr_service_truncation_check(PG_FUNCTION_ARGS)
{
#ifndef ENABLE_LITE_MODE
int dr_sender_num = 0;
for (int i = 1; i < MAX_REPLNODE_NUM; i++) {
ReplConnInfo *replConnInfo = NULL;
replConnInfo = t_thrd.postmaster_cxt.ReplConnArray[i];
/* Number of DR replconninfo */
if (replConnInfo != NULL && replConnInfo->isCrossRegion) {
dr_sender_num++;
}
}
if (IS_PGXC_COORDINATOR) {
g_instance.streaming_dr_cxt.hadrWalSndNum = dr_sender_num;
} else {
g_instance.streaming_dr_cxt.hadrWalSndNum = dr_sender_num > 0 ? 1 : 0;
}
for (int i = 0; i < g_instance.attr.attr_storage.max_wal_senders; i++) {
/* use volatile pointer to prevent code rearrangement */
volatile WalSnd *walsnd = &t_thrd.walsender_cxt.WalSndCtl->walsnds[i];
@ -2057,7 +2074,6 @@ Datum gs_streaming_dr_service_truncation_check(PG_FUNCTION_ARGS)
SpinLockAcquire(&walsnd->mutex);
if (walsnd->interactiveState == SDRS_DEFAULT) {
walsnd->interactiveState = SDRS_INTERACTION_BEGIN;
g_instance.streaming_dr_cxt.hadrWalSndNum++;
}
SpinLockRelease(&walsnd->mutex);
}