From 6ae789072f616d228dec9cdc604c2fd6cfb83790 Mon Sep 17 00:00:00 2001 From: xue_meng_en <1836611252@qq.com> Date: Tue, 7 Mar 2023 22:15:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E6=AD=A5=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=9C=BA=E5=88=B6=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storage/replication/syncrep.cpp | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/gausskernel/storage/replication/syncrep.cpp b/src/gausskernel/storage/replication/syncrep.cpp index 77fa9a0c63..fca22170b7 100755 --- a/src/gausskernel/storage/replication/syncrep.cpp +++ b/src/gausskernel/storage/replication/syncrep.cpp @@ -733,32 +733,25 @@ void SetXactLastCommitToSyncedStandby(XLogRecPtr recptr) } #endif -static SyncStandbyNumState check_sync_standbys_num(const SyncRepStandbyData* sync_standbys, int num_standbys) +static SyncStandbyNumState check_sync_standbys_num(const SyncRepStandbyData* sync_standbys, const int num_standbys) { - int i; - int* num_group_standbys; - const SyncRepStandbyData* stby = sync_standbys; - - SyncStandbyNumState res = STANDBIES_ENOUGH; - - - if (t_thrd.syncrep_cxt.SyncRepConfig == NULL) + if (t_thrd.syncrep_cxt.SyncRepConfig == NULL) { return STANDBIES_ENOUGH; + } - - if(num_standbys == 0) { + if (num_standbys == 0) { return STANDBIES_EMPTY; } - num_group_standbys = (int*)palloc0(t_thrd.syncrep_cxt.SyncRepConfigGroups * sizeof(int)); - - for(i = 0; i < num_standbys; i++) { - stby = sync_standbys + i; - (*(num_group_standbys + stby->sync_standby_group))++; + int *num_group_standbys = (int*)palloc0(t_thrd.syncrep_cxt.SyncRepConfigGroups * sizeof(int)); + for(int i = 0; i < num_standbys; ++i) { + int group = sync_standbys[i].sync_standby_group; + ++num_group_standbys[group]; } - for(i = 0; i < t_thrd.syncrep_cxt.SyncRepConfigGroups; i++) { - if((*(num_group_standbys + stby->sync_standby_group)) < t_thrd.syncrep_cxt.SyncRepConfig[i]->num_sync) { + SyncStandbyNumState res = STANDBIES_ENOUGH; + for(int i = 0; i < t_thrd.syncrep_cxt.SyncRepConfigGroups; ++i) { + if(num_group_standbys[i] < t_thrd.syncrep_cxt.SyncRepConfig[i]->num_sync) { res = STANDBIES_NOT_ENOUGH; break; } @@ -1397,8 +1390,10 @@ int SyncRepGetSyncStandbys(SyncRepStandbyData** sync_standbys, List** catchup_st if (t_thrd.syncrep_cxt.SyncRepConfig == NULL) return 0; + SyncRepStandbyData *sync_standbys_cur = *sync_standbys; for(int i = 0; i < t_thrd.syncrep_cxt.SyncRepConfigGroups; i++) { - num_sync += SyncRepGetSyncStandbysInGroup(sync_standbys, i,catchup_standbys); + sync_standbys_cur = *sync_standbys + num_sync; + num_sync += SyncRepGetSyncStandbysInGroup(&sync_standbys_cur, i, catchup_standbys); } return num_sync; -- Gitee