From c0763abbbb568181686ee9fff9651b7dfb78f0fa Mon Sep 17 00:00:00 2001 From: hadson Date: Thu, 26 Dec 2024 11:07:26 +0800 Subject: [PATCH] =?UTF-8?q?switchover=E6=97=B6=E5=80=99=E5=A4=87=E6=9C=BA?= =?UTF-8?q?=E5=9B=9E=E6=94=BE=E5=AE=8C=E5=86=8D=E5=88=87=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interface/dms_api.h | 4 +++- src/rc/dms_reform.h | 1 + src/rc/dms_reform_judge_switch.c | 2 ++ src/rc/dms_reform_proc.c | 18 ++++++++++++++++++ src/rc/dms_reform_proc_stat.c | 1 + 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/interface/dms_api.h b/src/interface/dms_api.h index ddca4e5..c2aa02c 100644 --- a/src/interface/dms_api.h +++ b/src/interface/dms_api.h @@ -36,7 +36,7 @@ extern "C" { #define DMS_LOCAL_MINOR_VER_WEIGHT 1000 #define DMS_LOCAL_MAJOR_VERSION 0 #define DMS_LOCAL_MINOR_VERSION 0 -#define DMS_LOCAL_VERSION 175 +#define DMS_LOCAL_VERSION 176 #define DMS_SUCCESS 0 #define DMS_ERROR (-1) @@ -999,6 +999,7 @@ typedef int (*dms_az_switchover_demote_approve)(void *db_handle); typedef int (*dms_az_switchover_demote_phase2)(void *db_handle); typedef int (*dms_az_switchover_promote_prepare)(void *db_handle); typedef int (*dms_az_switchover_promote_phase1)(void *db_handle); +typedef int (*dms_az_switchover_promote_switch_log)(void *db_handle); typedef int (*dms_az_switchover_promote_phase2)(void *db_handle); typedef void (*dms_dyn_log)(void *db_handle, long long dyn_log_time); @@ -1198,6 +1199,7 @@ typedef struct st_dms_callback { dms_az_switchover_demote_phase2 az_switchover_demote_phase2; dms_az_switchover_promote_prepare az_switchover_promote_prepare; dms_az_switchover_promote_phase1 az_switchover_promote_phase1; + dms_az_switchover_promote_switch_log az_switchover_promote_switch_log; dms_az_switchover_promote_phase2 az_switchover_promote_phase2; dms_az_failover_promote_phase1 az_failover_promote_phase1; dms_az_failover_promote_resetlog az_failover_promote_resetlog; diff --git a/src/rc/dms_reform.h b/src/rc/dms_reform.h index 08b7df4..4a4702d 100644 --- a/src/rc/dms_reform.h +++ b/src/rc/dms_reform.h @@ -188,6 +188,7 @@ typedef enum en_reform_step { DMS_REFORM_STEP_AZ_FAILOVER_PROMOTE_RESETLOG, // for Gauss100, AZ FAILOVER standby to primary DMS_REFORM_STEP_AZ_FAILOVER_PROMOTE_PHASE2, // for Gauss100, AZ FAILOVER standby to primary DMS_REFORM_STEP_RELOAD_TXN, + DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_SWITCH_LOG, // for Gauss100, AZ SWITCHOVER standby to primary DMS_REFORM_STEP_COUNT } reform_step_t; diff --git a/src/rc/dms_reform_judge_switch.c b/src/rc/dms_reform_judge_switch.c index a89a374..fb24bda 100644 --- a/src/rc/dms_reform_judge_switch.c +++ b/src/rc/dms_reform_judge_switch.c @@ -78,6 +78,8 @@ void dms_reform_judgement_az_promote_phase1(void) dms_reform_add_step(DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_PREPARE); dms_reform_add_step(DMS_REFORM_STEP_SYNC_WAIT); dms_reform_add_step(DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_PHASE1); + dms_reform_add_step(DMS_REFORM_STEP_SYNC_WAIT); + dms_reform_add_step(DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_SWITCH_LOG); share_info->promote_id = (uint8)g_dms.inst_id; } diff --git a/src/rc/dms_reform_proc.c b/src/rc/dms_reform_proc.c index b9ce442..6196a10 100644 --- a/src/rc/dms_reform_proc.c +++ b/src/rc/dms_reform_proc.c @@ -433,6 +433,22 @@ static int dms_reform_az_switchover_promote_phase1(void) return DMS_SUCCESS; } +static int dms_reform_az_switchover_promote_switch_log(void) +{ + int ret = DMS_SUCCESS; + + LOG_RUN_FUNC_ENTER; + ret = g_dms.callback.az_switchover_promote_switch_log(g_dms.reform_ctx.handle_normal); + if (ret != DMS_SUCCESS) { + LOG_RUN_FUNC_FAIL; + return ret; + } + + LOG_RUN_FUNC_SUCCESS; + dms_reform_next_step(); + return DMS_SUCCESS; +} + static int dms_reform_az_switchover_promote_phase2(void) { int ret = DMS_SUCCESS; @@ -1951,6 +1967,8 @@ dms_reform_proc_t g_dms_reform_procs[DMS_REFORM_STEP_COUNT] = { [DMS_REFORM_STEP_AZ_FAILOVER_PROMOTE_PHASE2] = { "AZ_FAILOVER_PROMOTE_PHASE2", dms_reform_az_failover_promote_phase2, NULL, CM_FALSE }, [DMS_REFORM_STEP_RELOAD_TXN] = { "RELOAD_TXN", dms_reform_reload_txn, NULL, CM_FALSE }, + [DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_SWITCH_LOG] = { "AZ_SWITCH_PROMOTE_SWITCH_LOG", + dms_reform_az_switchover_promote_switch_log, NULL, CM_FALSE }, }; static int dms_reform_proc_inner(void) diff --git a/src/rc/dms_reform_proc_stat.c b/src/rc/dms_reform_proc_stat.c index 606da7d..6276211 100644 --- a/src/rc/dms_reform_proc_stat.c +++ b/src/rc/dms_reform_proc_stat.c @@ -273,6 +273,7 @@ drps_desc_t g_drps_desc_t[] = { {DMS_REFORM_STEP_AZ_FAILOVER_PROMOTE_RESETLOG, DRPS_LEVEL_TOP, "AZ_FAILOVER_PROMOTE_RESETLOG"}, {DMS_REFORM_STEP_AZ_FAILOVER_PROMOTE_PHASE2, DRPS_LEVEL_TOP, "AZ_FAILOVER_PROMOTE_PHASE2"}, {DMS_REFORM_STEP_RELOAD_TXN, DRPS_LEVEL_TOP, "RELOAD_TXN"}, + {DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_SWITCH_LOG, DRPS_LEVEL_TOP, "AZ_SWITCH_PROMOTE_SWITCH_LOG"}, }; -- Gitee