standardize in_flushcopy usage

This commit is contained in:
dongning12
2023-03-08 15:05:53 +08:00
parent d03f486c24
commit b3827665cd
3 changed files with 9 additions and 8 deletions

View File

@ -1329,16 +1329,16 @@ static int CBRecoveryPrimary(void *db_handle, int inst_id)
static int CBFlushCopy(void *db_handle, char *pageid)
{
if (SS_REFORM_REFORMER && !g_instance.dms_cxt.SSRecoveryInfo.in_flushcopy) {
g_instance.dms_cxt.SSRecoveryInfo.in_flushcopy = true;
smgrcloseall();
}
// only 1) primary restart 2) failover need flush_copy
if (SS_REFORM_REFORMER && g_instance.dms_cxt.dms_status == DMS_STATUS_IN && !SS_STANDBY_FAILOVER) {
return GS_SUCCESS;
}
if (SS_REFORM_REFORMER && !g_instance.dms_cxt.SSRecoveryInfo.in_flushcopy) {
g_instance.dms_cxt.SSRecoveryInfo.in_flushcopy = true;
smgrcloseall();
}
BufferTag* tag = (BufferTag*)pageid;
Buffer buffer;
SegSpace *spc = NULL;
@ -1476,6 +1476,7 @@ static void CBReformStartNotify(void *db_handle, dms_role_t role, unsigned char
ss_reform_info_t *reform_info = &g_instance.dms_cxt.SSReformInfo;
g_instance.dms_cxt.SSClusterState = NODESTATE_NORMAL;
g_instance.dms_cxt.SSRecoveryInfo.reform_ready = false;
g_instance.dms_cxt.SSRecoveryInfo.in_flushcopy = false;
g_instance.dms_cxt.resetSyscache = true;
if (ss_reform_type == DMS_REFORM_TYPE_FOR_FAILOVER_OPENGAUSS) {
g_instance.dms_cxt.SSRecoveryInfo.in_failover = true;
@ -1542,6 +1543,7 @@ static int CBReformDoneNotify(void *db_handle)
g_instance.dms_cxt.SSReformInfo.in_reform = false;
g_instance.dms_cxt.SSRecoveryInfo.startup_reform = false;
g_instance.dms_cxt.SSRecoveryInfo.restart_failover_flag = false;
Assert(g_instance.dms_cxt.SSRecoveryInfo.in_flushcopy == false);
ereport(LOG,
(errmodule(MOD_DMS),
errmsg("[SS reform/SS switchover/SS failover] Reform success, instance:%d is running.",

View File

@ -148,7 +148,7 @@ typedef enum SSReformType {
DMS_REFORM_TYPE_FOR_BUILD,
DMS_REFORM_TYPE_FOR_FAILOVER,
DMS_REFORM_TYPE_FOR_SWITCHOVER,
DMS_REFORM_TYPE_FOR_OPENGAUSS,
DMS_REFORM_TYPE_FOR_NORMAL_OPENGAUSS,
DMS_REFORM_TYPE_FOR_FAILOVER_OPENGAUSS,
DMS_REFORM_TYPE_FOR_SWITCHOVER_OPENGAUSS,
DMS_REFORM_TYPE_FOR_FULL_CLEAN,

View File

@ -55,8 +55,7 @@ typedef struct ss_recovery_info {
bool startup_reform; // used to judge DB first start, when first reform finshed set false
bool restart_failover_flag; // used to indicate do failover when DB start
bool reform_ready;
bool in_failover; // used to judge this is failover, this tag will combine with failover_triggered later
// in failover Scenario,before failover_triggered become true, this node knows itself will become new primary
bool in_failover; // used to detemin failover scenario, especially for the non-promoting node
bool in_flushcopy;
bool no_backend_left;
} ss_recovery_info_t;