diff --git a/CMakeLists.txt b/CMakeLists.txt index 09f420da95f54d86f326190dcf779715ccdf1213..3a2d31f85dc2a82b577d36b033b85a74b62dc8bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,7 @@ set(DMS_INTERFACE_PATH ${PROJECT_SOURCE_DIR}/src/interface) set(DMS_OCK_PATH ${PROJECT_SOURCE_DIR}/src/ock) set(DMS_FI_PATH ${PROJECT_SOURCE_DIR}/src/fi) set(DMS_PARAM_PATH ${PROJECT_SOURCE_DIR}/src/param) +set(DMS_CMPT_PATH ${PROJECT_SOURCE_DIR}/src/cmpt) ## other dependency include set(DMS_SECUREC_INC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/library/huawei_security/include") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0ca5dbf7215aae0f0bc3709b4454ba0a0c7c6c2c..ee5c9c02d0e683154798a9bc9e401037d817dcd9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,7 @@ include_directories(${DMS_INTERFACE_PATH}) include_directories(${DMS_OCK_PATH}) include_directories(${DMS_FI_PATH}) include_directories(${DMS_PARAM_PATH}) +include_directories(${DMS_CMPT_PATH}) aux_source_directory(${DMS_COMMON_PATH} COMMON_SRC) aux_source_directory(${DMS_DCS_PATH} DCS_SRC) @@ -31,8 +32,9 @@ aux_source_directory(${DMS_RC_PATH} RC_SRC) aux_source_directory(${DMS_OCK_PATH} OCK_SRC) aux_source_directory(${DMS_FI_PATH} FI_SRC) aux_source_directory(${DMS_PARAM_PATH} PARAM_SRC) +aux_source_directory(${DMS_CMPT_PATH} CMPT_SRC) -set(SRC_DMS_LIST ${COMMON_SRC} ${DCS_SRC} ${DLS_SRC} ${DRC_SRC} ${DMS_SRC} ${RC_SRC} ${OCK_SRC} ${FI_SRC} ${PARAM_SRC}) +set(SRC_DMS_LIST ${COMMON_SRC} ${DCS_SRC} ${DLS_SRC} ${DRC_SRC} ${DMS_SRC} ${RC_SRC} ${OCK_SRC} ${FI_SRC} ${PARAM_SRC} ${CMPT_SRC}) add_library(dms SHARED ${SRC_DMS_LIST}) diff --git a/src/dms/dms_msg_command.h b/src/cmpt/cmpt_msg_cmd.h similarity index 59% rename from src/dms/dms_msg_command.h rename to src/cmpt/cmpt_msg_cmd.h index f0ef8999dcbe017cc0c65f127f9d3251c6f360c4..78c1ac55f8a4ff758cbc2c5b00ef95266ca3f862 100644 --- a/src/dms/dms_msg_command.h +++ b/src/cmpt/cmpt_msg_cmd.h @@ -13,16 +13,16 @@ * See the Mulan PSL v2 for more details. * ------------------------------------------------------------------------- * - * dms_msg_command.h + * cmpt_msg_cmd.h * * * IDENTIFICATION - * src/common/dms_msg_command.h + * src/cmpt/cmpt_msg_cmd.h * * ------------------------------------------------------------------------- */ -#ifndef __DMS_MSG_COMMAND_H__ -#define __DMS_MSG_COMMAND_H__ +#ifndef __CMPT_MSG_CMD_H__ +#define __CMPT_MSG_CMD_H__ #ifdef __cplusplus extern "C" { @@ -103,70 +103,72 @@ typedef enum en_msg_command { MSG_REQ_CHECK_OWNERSHIP = 70, MSG_REQ_END, - MSG_ACK_BEGIN = 128, + MSG_ACK_BEGIN = 32768, MSG_ACK_CHECK_VISIBLE = MSG_ACK_BEGIN, - MSG_ACK_PAGE_OWNER_ID = 129, - MSG_ACK_BROADCAST = 130, - MSG_ACK_BROADCAST_WITH_MSG = 131, - MSG_ACK_PAGE_READY = 132, - MSG_ACK_GRANT_OWNER = 133, - MSG_ACK_ALREADY_OWNER = 134, - MSG_ACK_CR_PAGE = 135, - MSG_ACK_TXN_WAIT = 136, - MSG_ACK_LOCK = 137, - MSG_ACK_TXN_INFO = 138, - MSG_ACK_TXN_SNAPSHOT = 139, - MSG_ACK_WAIT_TXN = 140, - MSG_ACK_AWAKE_TXN = 141, - MSG_ACK_MASTER_CKPT_EDP = 142, - MSG_ACK_OWNER_CKPT_EDP = 143, - MSG_ACK_MASTER_CLEAN_EDP = 144, - MSG_ACK_OWNER_CLEAN_EDP = 145, - MSG_ACK_ERROR = 146, - MSG_ACK_RELEASE_PAGE_OWNER = 147, - MSG_ACK_INVLDT_SHARE_COPY = 148, - MSG_ACK_BOC = 149, - MSG_ACK_SMON_DLOCK_INFO = 150, - MSG_ACK_SMON_DEADLOCK_SQL = 151, - MSG_ACK_SMON_DEADLOCK_ITL = 152, - MSG_ACK_SMON_BROADCAST = 153, - MSG_ACK_SMON_TLOCK_BY_TID = 154, - MSG_ACK_SMON_TLOCK_BY_RM = 155, - MSG_ACK_OPENGAUSS_TXN_STATUS = 156, - MSG_ACK_OPENGAUSS_TXN_SNAPSHOT = 157, - MES_ACK_RELEASE_OWNER_BATCH = 158, - MSG_ACK_OPENGAUSS_TXN_UPDATE_XID = 159, - MSG_ACK_OPENGAUSS_XID_CSN = 160, - MSG_ACK_OPENGAUSS_LOCK_BUFFER = 161, - MSG_ACK_SMON_ALOCK_BY_DRID = 162, - MSG_ACK_CHECK_OWNERSHIP = 163, - MSG_ACK_REFORM_COMMON = 164, - MSG_ACK_CONFIRM_CVT = 165, - MSG_ACK_MAP_INFO = 166, - MSG_ACK_REFORM_GCV_SYNC = 167, - MSG_ACK_INVLD_OWNER = 168, - MSG_ACK_ASK_RES_OWNER_ID = 169, - MSG_ACK_OPENGAUSS_ONDEMAND_REDO = 170, - MSG_ACK_OPENGAUSS_TXN_SWINFO = 171, - MSG_ACK_OPENGAUSS_PAGE_STATUS = 172, - MSG_ACK_SEND_OPENGAUSS_OLDEST_XMIN = 173, - MSG_ACK_PROTOCOL_VERSION_NOT_MATCH = 174, - MSG_ACK_NODE_FOR_BUF_INFO = 175, - MSG_ACK_CREATE_GLOBAL_XA_RES = 176, - MSG_ACK_DELETE_GLOBAL_XA_RES = 177, - MSG_ACK_ASK_XA_OWNER_ID = 178, - MSG_ACK_END_XA = 179, - MSG_ACK_XA_IN_USE = 180, - MSG_ACK_OPENGAUSS_IMMEDIATE_CKPT = 181, + MSG_ACK_PAGE_OWNER_ID = 32769, + MSG_ACK_BROADCAST = 32770, + MSG_ACK_BROADCAST_WITH_MSG = 32771, + MSG_ACK_PAGE_READY = 32772, + MSG_ACK_GRANT_OWNER = 32773, + MSG_ACK_ALREADY_OWNER = 32774, + MSG_ACK_CR_PAGE = 32775, + MSG_ACK_TXN_WAIT = 32776, + MSG_ACK_LOCK = 32777, + MSG_ACK_TXN_INFO = 32778, + MSG_ACK_TXN_SNAPSHOT = 32779, + MSG_ACK_WAIT_TXN = 32780, + MSG_ACK_AWAKE_TXN = 32781, + MSG_ACK_MASTER_CKPT_EDP = 32782, + MSG_ACK_OWNER_CKPT_EDP = 32783, + MSG_ACK_MASTER_CLEAN_EDP = 32784, + MSG_ACK_OWNER_CLEAN_EDP = 32785, + MSG_ACK_ERROR = 32786, + MSG_ACK_RELEASE_PAGE_OWNER = 32787, + MSG_ACK_INVLDT_SHARE_COPY = 32788, + MSG_ACK_BOC = 32789, + MSG_ACK_SMON_DLOCK_INFO = 32790, + MSG_ACK_SMON_DEADLOCK_SQL = 32791, + MSG_ACK_SMON_DEADLOCK_ITL = 32792, + MSG_ACK_SMON_BROADCAST = 32793, + MSG_ACK_SMON_TLOCK_BY_TID = 32794, + MSG_ACK_SMON_TLOCK_BY_RM = 32795, + MSG_ACK_OPENGAUSS_TXN_STATUS = 32796, + MSG_ACK_OPENGAUSS_TXN_SNAPSHOT = 32797, + MES_ACK_RELEASE_OWNER_BATCH = 32798, + MSG_ACK_OPENGAUSS_TXN_UPDATE_XID = 32799, + MSG_ACK_OPENGAUSS_XID_CSN = 32800, + MSG_ACK_OPENGAUSS_LOCK_BUFFER = 32801, + MSG_ACK_SMON_ALOCK_BY_DRID = 32802, + MSG_ACK_CHECK_OWNERSHIP = 32803, + MSG_ACK_REFORM_COMMON = 32804, + MSG_ACK_CONFIRM_CVT = 32805, + MSG_ACK_MAP_INFO = 32806, + MSG_ACK_REFORM_GCV_SYNC = 32807, + MSG_ACK_INVLD_OWNER = 32808, + MSG_ACK_ASK_RES_OWNER_ID = 32809, + MSG_ACK_OPENGAUSS_ONDEMAND_REDO = 32810, + MSG_ACK_OPENGAUSS_TXN_SWINFO = 32811, + MSG_ACK_OPENGAUSS_PAGE_STATUS = 32812, + MSG_ACK_SEND_OPENGAUSS_OLDEST_XMIN = 32813, + MSG_ACK_PROTOCOL_VERSION_NOT_MATCH = 32814, + MSG_ACK_NODE_FOR_BUF_INFO = 32815, + MSG_ACK_CREATE_GLOBAL_XA_RES = 32816, + MSG_ACK_DELETE_GLOBAL_XA_RES = 32817, + MSG_ACK_ASK_XA_OWNER_ID = 32818, + MSG_ACK_END_XA = 32819, + MSG_ACK_XA_IN_USE = 32820, + MSG_ACK_OPENGAUSS_IMMEDIATE_CKPT = 32821, MSG_ACK_END, MSG_CMD_CEIL = MSG_ACK_END } msg_command_t; -#define DMS_CMD_SIZE (MSG_CMD_CEIL - (MSG_ACK_BEGIN - MSG_REQ_END)) -#define MSG_REQ_REFORM_TLOCK_TYPE(cmd) ((cmd) == MSG_REQ_TLOCK_REBUILD || (cmd) == MSG_REQ_TLOCK_VALIDATE) +/* msg_command_t size */ +#define DMS_REQ_CMD_SIZE (MSG_REQ_END - MSG_REQ_BEGIN) +#define DMS_ACK_CMD_SIZE (MSG_ACK_END - MSG_ACK_BEGIN) +#define DMS_CMD_SIZE (DMS_REQ_CMD_SIZE + DMS_ACK_CMD_SIZE) #ifdef __cplusplus } #endif -#endif // __DMS_MSG_COMMAND_H__ +#endif // __CMPT_MSG_CMD_H__ diff --git a/src/cmpt/cmpt_msg_common.h b/src/cmpt/cmpt_msg_common.h new file mode 100644 index 0000000000000000000000000000000000000000..47d435fb050be575c41d42ed19062f53170d626a --- /dev/null +++ b/src/cmpt/cmpt_msg_common.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * DMS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * ------------------------------------------------------------------------- + * + * cmpt_msg_common.h + * + * + * IDENTIFICATION + * src/cmpt/cmpt_msg_common.h + * + * ------------------------------------------------------------------------- + */ +#ifndef __CMPT_MSG_COMMON_H__ +#define __CMPT_MSG_COMMON_H__ + +#include "cm_types.h" +#include "dms_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define DMS_MSG_HEAD_UNUSED_SIZE 24 +typedef struct st_dms_message_head { + unsigned int msg_proto_ver; + unsigned int sw_proto_ver; + unsigned int cmd; + unsigned int flags; + unsigned long long ruid; + unsigned char src_inst; + unsigned char dst_inst; + unsigned short size; + unsigned int cluster_ver; + unsigned short src_sid; + unsigned short dst_sid; + unsigned short tickets; + unsigned short unused; + union { + struct { + long long judge_time; // for message used in reform, check if it is the same round of reform + }; + struct { + unsigned long long seq; + }; + unsigned char reserved[DMS_MSG_HEAD_UNUSED_SIZE]; /* 64 bytes total */ + }; +} dms_message_head_t; + +typedef enum en_msg_flags { + MSG_FLAG_DIRTY_PAGE = 0x01, // sent local dirty page, owner has edp + MSG_FLAG_REMOTE_DIRTY_PAGE = 0x02, // sent remote dirty page, owner has edp + MSG_FLAG_SHARED_PAGE = 0x04, // sent page is shared copy + MSG_FLAG_NO_PAGE = 0x08, // requester has shared copy, no page sent + MSG_FLAG_CEIL = 0x80 +} msg_flags_t; + +#define DCS_ACK_PAGE_IS_DIRTY(msg) ((((msg)->head->flags & MSG_FLAG_DIRTY_PAGE) != 0) ? CM_TRUE : CM_FALSE) +#define DCS_ACK_PAGE_IS_REMOTE_DIRTY(msg) (((msg)->head->flags & MSG_FLAG_REMOTE_DIRTY_PAGE) ? CM_TRUE : CM_FALSE) + +typedef struct st_msg_error { + dms_message_head_t head; + int32 code; +} msg_error_t; + +typedef struct st_dms_common_ack { + dms_message_head_t head; + int32 ret; +} dms_common_ack_t; + +#ifdef __cplusplus +} +#endif + +#endif // __CMPT_MSG_COMMON_H__ \ No newline at end of file diff --git a/src/dcs/dcs_msg.c b/src/cmpt/cmpt_msg_drm.h similarity index 80% rename from src/dcs/dcs_msg.c rename to src/cmpt/cmpt_msg_drm.h index 0cfa6c3f5e1da1969a2013a065e70dde45a077c7..10e4e290aab980161d6845bf0f816e1cd3433828 100644 --- a/src/dcs/dcs_msg.c +++ b/src/cmpt/cmpt_msg_drm.h @@ -13,22 +13,29 @@ * See the Mulan PSL v2 for more details. * ------------------------------------------------------------------------- * - * dcs_msg.c + * cmpt_msg_drm.h * * * IDENTIFICATION - * src/dcs/dcs_msg.c + * src/cmpt/cmpt_msg_drm.h * * ------------------------------------------------------------------------- */ +#ifndef __CMPT_MSG_DRM_H__ +#define __CMPT_MSG_DRM_H__ -#include "dcs_msg.h" +#include "cmpt_msg_common.h" +#include "drc.h" #ifdef __cplusplus extern "C" { #endif + + #ifdef __cplusplus } -#endif \ No newline at end of file +#endif + +#endif // __CMPT_MSG_DRM_H__ \ No newline at end of file diff --git a/src/cmpt/cmpt_msg_lock.h b/src/cmpt/cmpt_msg_lock.h new file mode 100644 index 0000000000000000000000000000000000000000..f8ca01b1db15c5b620a9bd02262f3e840dd3ac6c --- /dev/null +++ b/src/cmpt/cmpt_msg_lock.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * DMS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * ------------------------------------------------------------------------- + * + * cmpt_msg_lock.h + * + * + * IDENTIFICATION + * src/cmpt/cmpt_msg_lock.h + * + * ------------------------------------------------------------------------- + */ +#ifndef __CMPT_MSG_LOCK_H__ +#define __CMPT_MSG_LOCK_H__ + +#include "cmpt_msg_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#pragma pack(4) +typedef struct st_dms_smon_deadlock_alock_req { + dms_message_head_t head; + alockid_t alockid; +} dms_smon_deadlock_alock_req_t; + +typedef struct st_dms_smon_deadlock_alock_rsp { + dms_message_head_t head; + uint32 ret_code; + uint32 data_size; + char data[0]; +} dms_smon_deadlock_alock_rsp_t; +#pragma pack() + +typedef struct st_dcs_req_tlock_by_rm { + uint32 type; + uint16 sid; + uint16 rmid; +} dcs_req_tlock_by_rm_t; + +typedef struct st_dcs_req_tlock_by_tid { + char tlock[DMS_SMON_TLOCK_MSG_MAX_LEN]; +} dcs_req_tlock_by_tid_t; + +#ifdef __cplusplus +} +#endif + +#endif // __CMPT_MSG_LOCK_H__ \ No newline at end of file diff --git a/src/cmpt/cmpt_msg_mesi.h b/src/cmpt/cmpt_msg_mesi.h new file mode 100644 index 0000000000000000000000000000000000000000..cb85db7e96a1a2f7d45589f8ea51750ca32785fa --- /dev/null +++ b/src/cmpt/cmpt_msg_mesi.h @@ -0,0 +1,267 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * DMS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * ------------------------------------------------------------------------- + * + * cmpt_msg_mesi.h + * + * + * IDENTIFICATION + * src/cmpt/cmpt_msg_mesi.h + * + * ------------------------------------------------------------------------- + */ +#ifndef __CMPT_MSG_MESI_H__ +#define __CMPT_MSG_MESI_H__ + +#include "cmpt_msg_common.h" +#include "drc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct st_msg_owner_clean_req { + dms_message_head_t head; + dms_lock_mode_t req_mode; + char pageid[DMS_PAGEID_SIZE]; +} msg_owner_clean_req_t; + +typedef struct st_msg_ack_owner_id { + dms_message_head_t head; + uint32 owner_id; +} msg_ack_owner_id_t; + +typedef struct st_msg_rls_owner_req { + dms_message_head_t head; + uint64 owner_lsn; + uint64 owner_scn; + dms_session_e sess_type; + char pageid[DMS_PAGEID_SIZE]; +} msg_rls_owner_req_t; + +typedef struct st_msg_rls_owner_ack { + dms_message_head_t head; + bool8 released; +} msg_rls_owner_ack_t; + +typedef struct st_dms_ask_res_req { + dms_message_head_t head; + union { + struct { + uint8 inst_id; /* the instance that the request comes from */ + uint8 curr_mode; /* current holding lock mode in request instance */ + uint8 req_mode; /* the expected lock mode that request instance wants */ + uint8 is_try; /* if is try request */ + uint8 intercept_type; + uint8 is_upgrade; /* used for table lock upgrade */ + uint16 sess_id; /* the session id that the request comes from */ + uint64 ruid; /* request packet ruid */ + uint32 srsn; + date_t req_time; + uint32 req_proto_ver; + dms_session_e sess_type; /* session type */ + }; + drc_request_info_t drc_reg_info; + }; + uint16 len; + uint8 res_type; + uint8 unused; + uint64 scn; /* sync SCN to remote instance */ + char resid[DMS_RESID_SIZE]; +} dms_ask_res_req_t; + +// msg for notifying instance load page from disk +typedef struct st_dms_ask_res_ack_load { + dms_message_head_t head; + uint64 master_lsn; + uint64 scn; + bool8 master_grant; + uint8 node_count; +} dms_ask_res_ack_ld_t; + +typedef struct st_dms_ask_res_ack_load_wrapper { + dms_ask_res_ack_ld_t ack; + uint64 node_lfn[DMS_MAX_INSTANCES]; +} dms_ask_res_ack_ld_wrapper_t; + +// msg for notifying instance is already resource owner +typedef struct st_dms_already_owner_ack { + dms_message_head_t head; + uint64 scn; +} dms_already_owner_ack_t; + +typedef struct st_dms_ask_res_ack { + dms_message_head_t head; + uint64 lsn; + uint64 scn; + uint64 edp_map; +#ifdef OPENGAUSS + uint8 seg_fileno; + uint32 seg_blockno; + bool8 need_check_pincount; + uint64 lsn_on_disk; +#endif + bool8 enable_cks; // enable checksum + uint8 unused; + uint16 checksum; +#ifndef OPENGAUSS + uint8 node_id; + uint8 node_cnt; + uint64 node_lfn; +#endif +} dms_ask_res_ack_t; + +typedef struct st_dms_ask_res_ack_wrapper { + dms_ask_res_ack_t res_ack; + uint64 data[DMS_MAX_INSTANCES + 1]; /* index 0: timestamp, other: node_lfn */ +} dms_ask_res_ack_wrapper; + +typedef struct st_dms_claim_owner_req { + dms_message_head_t head; + dms_lock_mode_t req_mode; + dms_session_e sess_type; + bool8 has_edp; // previous owner has earlier dirty page + uint8 res_type; + uint16 len; + uint64 lsn; + char resid[DMS_RESID_SIZE]; + uint32 srsn; +} dms_claim_owner_req_t; + +typedef struct st_dms_invld_req { + dms_message_head_t head; + uint64 scn; /* sync SCN to remote instance */ + uint8 is_try; + uint8 res_type; + uint16 len; + bool32 invld_owner; + dms_session_e sess_type; + char resid[DMS_RESID_SIZE]; +} dms_invld_req_t; + +typedef struct st_dms_ask_res_owner_id_req { + dms_message_head_t head; + dms_session_e sess_type; + uint16 len; + uint8 res_type; + uint8 intercept_type; + uint64 lsn; + char resid[DMS_RESID_SIZE]; +} dms_ask_res_owner_id_req_t; + +typedef struct st_dms_ask_res_owner_id_ack { + dms_message_head_t head; + uint8 owner_id; + uint8 unused[3]; +} dms_ask_res_owner_id_ack_t; + +typedef struct st_dms_res_req_info { + uint8 req_id; + uint8 owner_id; + uint8 res_type; + bool8 is_try; + uint8 unused; + uint8 intercept_type; + uint16 req_sid; + dms_session_e sess_type; + uint64 req_ruid; + uint32 len; + dms_lock_mode_t req_mode; + dms_lock_mode_t curr_mode; + char resid[DMS_RESID_SIZE]; + uint32 req_proto_ver; + uint64 seq; +} dms_res_req_info_t; + +typedef struct st_dms_cancel_request_res { + dms_message_head_t head; + union { + struct { + uint8 inst_id; /* the instance that the request comes from */ + uint8 curr_mode; /* current holding lock mode in request instance */ + uint8 req_mode; /* the expected lock mode that request instance wants */ + uint8 is_try; /* if is try request */ + uint8 intercept_type; + uint8 is_upgrade; /* used for table lock upgrade */ + uint16 sess_id; /* the session id that the request comes from */ + uint64 ruid; /* request packet ruid */ + uint32 srsn; + date_t req_time; + uint32 req_proto_ver; + dms_session_e sess_type; /* session type */ + }; + drc_request_info_t drc_reg_info; + }; + uint16 len; + uint8 res_type; + uint8 unused; + char resid[DMS_RESID_SIZE]; +} dms_cancel_request_res_t; + +typedef struct st_dms_confirm_cvt_req { + dms_message_head_t head; + uint8 res_type; + uint8 cvt_mode; + char resid[DMS_RESID_SIZE]; +}dms_confirm_cvt_req_t; + +typedef enum en_confirm_result { + CONFIRM_NONE = 0, + CONFIRM_READY = 1, + CONFIRM_CANCEL = 2 +}confirm_result_t; + +typedef struct st_dms_confirm_cvt_ack { + dms_message_head_t head; + uint32 result; + uint64 lsn; + uint64 edp_map; + uint8 lock_mode; +}dms_confirm_cvt_ack_t; + +typedef struct st_dms_query_owner_req { + dms_message_head_t head; + char resid[DMS_RESID_SIZE]; +} dms_query_owner_req_t; + +typedef struct st_dms_query_owner_ack { + dms_message_head_t head; + uint8 owner_id; +} dms_query_owner_ack_t; + +typedef struct st_dms_invld_ack { + dms_common_ack_t common_ack; + uint64 scn; + uint64 lfn; +} dms_invld_ack_t; + +typedef struct st_dms_chk_ownership_req { + dms_message_head_t head; + char resid[DMS_RESID_SIZE]; + uint16 len; + uint8 inst_id; + uint8 curr_mode; +} dms_chk_ownership_req_t; + +typedef enum en_req_flags { + REQ_FLAG_DEFAULT = 0x00, + REQ_FLAG_REFORM_SESSION = 0x01, + REQ_FLAG_CEIL = 0x80, +} req_flags_t; + +#ifdef __cplusplus +} +#endif + +#endif // __CMPT_MSG_MESI_H__ \ No newline at end of file diff --git a/src/cmpt/cmpt_msg_misc.h b/src/cmpt/cmpt_msg_misc.h new file mode 100644 index 0000000000000000000000000000000000000000..9711dbe98624d046602f8dd10b637ea04cdf0bb9 --- /dev/null +++ b/src/cmpt/cmpt_msg_misc.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * DMS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * ------------------------------------------------------------------------- + * + * cmpt_msg_misc.h + * + * + * IDENTIFICATION + * src/cmpt/cmpt_msg_misc.h + * + * ------------------------------------------------------------------------- + */ +#ifndef __CMPT_MSG_MISC_H__ +#define __CMPT_MSG_MISC_H__ + +#include "cmpt_msg_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +* The following structs are used for communication +* between Primary and Standby to obtain relevant +* information about buffers on other nodes. +*/ +typedef struct st_dms_req_buf_info { + dms_message_head_t head; + unsigned long long copy_insts; + unsigned char claimed_owner; + unsigned char master_id; + unsigned char from_inst; + char resid[DMS_RESID_SIZE]; +} dms_req_buf_info_t; + +typedef struct st_dms_ack_buf_info { + dms_message_head_t head; + stat_buf_info_t buf_info; +} dms_ack_buf_info_t; + +typedef struct st_dcs_boc_req { + dms_message_head_t head; + uint64 commit_scn; + uint64 min_scn; + uint32 inst_id; + uint64 lsn; +} dcs_boc_req_t; + +#ifdef __cplusplus +} +#endif + +#endif // __CMPT_MSG_MISC_H__ \ No newline at end of file diff --git a/src/cmpt/cmpt_msg_pcr.h b/src/cmpt/cmpt_msg_pcr.h new file mode 100644 index 0000000000000000000000000000000000000000..835a39428961f4bac54f6ca544658cf9b4660d2c --- /dev/null +++ b/src/cmpt/cmpt_msg_pcr.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * DMS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * ------------------------------------------------------------------------- + * + * cmpt_msg_pcr.h + * + * + * IDENTIFICATION + * src/cmpt/cmpt_msg_pcr.h + * + * ------------------------------------------------------------------------- + */ +#ifndef __CMPT_MSG_PCR_H__ +#define __CMPT_MSG_PCR_H__ + +#include "cmpt_msg_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum en_cr_type { + CR_TYPE_HEAP, + CR_TYPE_BTREE, +} cr_type_t; + +typedef struct st_msg_pcr_request { + dms_message_head_t head; + uint8 cr_type; + bool8 force_cvt; // force convert + uint32 ssn; + uint64 query_scn; + char pageid[DMS_PAGEID_SIZE]; + char xid[DMS_XID_SIZE]; + dms_session_e sess_type; +} msg_pcr_request_t; + +typedef struct st_msg_pcr_ack { + dms_message_head_t head; + bool8 force_cvt; +} msg_pcr_ack_t; + +typedef struct st_msg_index_pcr_request { + msg_pcr_request_t pcr_request; + char entry[DMS_PAGEID_SIZE]; + char profile[DMS_INDEX_PROFILE_SIZE]; +} msg_index_pcr_request_t; + +typedef struct st_msg_cr_check { + dms_message_head_t head; + uint64 query_scn; + uint32 ssn; + char xid[DMS_XID_SIZE]; + char rowid[DMS_ROWID_SIZE]; +} msg_cr_check_t; + +typedef struct st_msg_cr_check_ack { + dms_message_head_t head; + bool8 is_found; +} msg_cr_check_ack_t; + +#ifdef __cplusplus +} +#endif + +#endif // __CMPT_MSG_PCR_H__ \ No newline at end of file diff --git a/src/cmpt/cmpt_msg_reform.h b/src/cmpt/cmpt_msg_reform.h new file mode 100644 index 0000000000000000000000000000000000000000..a7f67b7bbd537ee50ce1b987c78456978ef0b74c --- /dev/null +++ b/src/cmpt/cmpt_msg_reform.h @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * DMS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * ------------------------------------------------------------------------- + * + * cmpt_msg_reform.h + * + * + * IDENTIFICATION + * src/cmpt/cmpt_msg_reform.h + * + * ------------------------------------------------------------------------- + */ +#ifndef __CMPT_MSG_REFORM_H__ +#define __CMPT_MSG_REFORM_H__ + +#include "cmpt_msg_common.h" +#include "cmpt_msg_version.h" +#include "cmpt_reform_step.h" +#include "dms_cm.h" +#include "drc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct st_dms_reform_ack_common { + dms_message_head_t head; + int result; // proc result + uint8 last_fail; // for ack MSG_REQ_REFORM_PREPARE + union { + uint8 dms_status; // for ack MSG_REQ_DATABASE_STATUS + uint8 has_ddl_2phase; + }; + uint8 lock_mode; + bool8 is_edp; + uint64 lsn; + uint64 start_time; + uint64 bitmap_has_xa; + uint8 db_is_readwrite; +} dms_reform_ack_common_t; + +typedef struct st_dms_reform_req_sync_step { + dms_message_head_t head; + uint64 scn; + uint64 start_time; + uint8 last_step; + uint8 curr_step; + uint8 next_step; +} dms_reform_req_sync_step_t; + +typedef struct st_dms_reform_req_partner_status { + dms_message_head_t head; + uint64 lsn; + driver_ping_info_t driver_ping_info; +} dms_reform_req_partner_status_t; + +typedef struct st_dms_reform_req_prepare { + dms_message_head_t head; + bool8 last_fail; +} dms_reform_req_prepare_t; + +typedef struct st_dms_reform_req_gcv_sync { + dms_message_head_t head; + bool8 pushing; +} dms_reform_req_gcv_sync_t; + +typedef struct st_dms_reform_ack_gcv_sync { + dms_message_head_t head; + bool8 updated; +} dms_reform_ack_gcv_sync_t; + +typedef struct st_dms_reform_req_migrate { + dms_message_head_t head; + uint32 part_id; + uint32 res_num; + bool8 is_part_end; + uint8 res_type; +} dms_reform_req_migrate_t; + +typedef struct st_dms_reform_req_rebuild { + dms_message_head_t head; + uint32 offset; +} dms_reform_req_rebuild_t; + +typedef enum dms_reform_req_page_action { + DMS_REQ_FLUSH_COPY, +} page_action_t; + +typedef struct st_dms_reform_req_switchover { + dms_message_head_t head; + uint64 start_time; +} dms_reform_req_switchover_t; + +typedef struct st_repair_item { + char page_id[DMS_PAGEID_SIZE]; + uint32 action; +} repair_item_t; + +typedef struct st_migrate_task { + uint8 export_inst; + uint8 import_inst; + uint8 part_id; + uint8 unused; +} migrate_task_t; + +typedef struct st_migrate_info { + migrate_task_t migrate_task[DRC_MAX_PART_NUM]; + uint8 migrate_task_num; + uint8 unused[3]; +} migrate_info_t; + +typedef struct st_remaster_info { + drc_part_t part_map[DRC_MAX_PART_NUM]; + drc_inst_part_t inst_part_tbl[DMS_MAX_INSTANCES]; + uint8 deposit_map[DMS_MAX_INSTANCES]; +} remaster_info_t; + +typedef struct st_dms_reform_ack_map { + dms_message_head_t head; + remaster_info_t remaster_info; +} dms_reform_ack_map_t; + +typedef struct st_dms_reform_req_opengauss_ondemand_redo { + dms_message_head_t head; + uint16 len; +} dms_reform_req_opengauss_ondemand_redo_t; + +typedef struct st_dms_reform_req_group { + dms_message_head_t head; + uint32 offset; +} dms_reform_req_group_t; + +typedef struct st_dms_reform_req_az_switchover { + dms_message_head_t head; + uint64 start_time; +} dms_reform_req_az_switchover_t; + +typedef struct st_dms_reform_req_az_failover { + dms_message_head_t head; + uint64 start_time; +} dms_reform_req_az_failover_t; + +typedef struct st_version_info { + uint64 start_time; + uint8 inst_id; + uint8 unused[3]; +} version_info_t; + +typedef enum en_inst_list_type { + INST_LIST_OLD_BASE = 0, + INST_LIST_OLD_OUT = INST_LIST_OLD_BASE + DMS_ONLINE_STATUS_OUT, + INST_LIST_OLD_JOIN = INST_LIST_OLD_BASE + DMS_ONLINE_STATUS_JOIN, + INST_LIST_OLD_REFORM = INST_LIST_OLD_BASE + DMS_ONLINE_STATUS_REFORM, + INST_LIST_OLD_IN = INST_LIST_OLD_BASE + DMS_ONLINE_STATUS_IN, + INST_LIST_OLD_REMOVE, + INST_LIST_NEW_BASE, + INST_LIST_NEW_OUT = INST_LIST_NEW_BASE + DMS_ONLINE_STATUS_OUT, + INST_LIST_NEW_JOIN = INST_LIST_NEW_BASE + DMS_ONLINE_STATUS_JOIN, + INST_LIST_NEW_REFORM = INST_LIST_NEW_BASE + DMS_ONLINE_STATUS_REFORM, + INST_LIST_NEW_IN = INST_LIST_NEW_BASE + DMS_ONLINE_STATUS_IN, + INST_LIST_TYPE_COUNT +} inst_list_type_t; + +#pragma pack(4) +/* Tips: Byte alignment is required, padding is not allowed */ +typedef struct st_share_info { + /* ============= start version 1 =================*/ + reform_step_t reform_step[DMS_REFORM_STEP_TOTAL_COUNT]; + reform_phase_t reform_phase[DMS_REFORM_PHASE_TOTAL_COUNT]; + instance_list_t list_stable; + instance_list_t list_online; + instance_list_t list_offline; + instance_list_t list_reconnect; + instance_list_t list_disconnect; + instance_list_t list_clean; + instance_list_t list_rebuild; + instance_list_t list_recovery; + instance_list_t list_withdraw; + instance_list_t list_rollback; + uint64 bitmap_stable; + uint64 bitmap_online; + uint64 bitmap_reconnect; + uint64 bitmap_disconnect; + uint64 bitmap_clean; + uint64 bitmap_recovery; + uint64 bitmap_in; + uint64 bitmap_remove; + remaster_info_t remaster_info; + migrate_info_t migrate_info; + version_info_t reformer_version; // record reformer version, find reformer restart in time + version_info_t switch_version; // in reform of switchover, there is another reformer + dms_reform_type_t reform_type; + uint8 reform_step_count; + uint8 reform_phase_count; + bool8 full_clean; + uint8 reformer_id; // current reformer id + uint8 promote_id; // instance promote to primary + uint8 demote_id; // instance demote to standy; + uint8 last_reformer; // last reformer + bool8 catalog_centralized; + uint64 version_num; + dw_recovery_info_t dw_recovery_info; + uint64 start_times[DMS_MAX_INSTANCES]; + date_t judge_time; + uint32 proto_version; + /* ============= end version 1 =================*/ + + /* ============= start version 2 =================*/ + uint64 inst_bitmap[INST_LIST_TYPE_COUNT]; + /* ============= end version 2 =================*/ +} share_info_t; +#pragma pack() + +extern dms_proto_version_attr g_req_share_info_version_ctrl[DMS_PROTO_VER_NUMS]; + +typedef struct st_dms_reform_req_sync_share_info { + dms_message_head_t head; + share_info_t share_info; +} dms_reform_req_sync_share_info_t; + +#ifdef __cplusplus +} +#endif + +#endif // __CMPT_MSG_REFORM_H__ \ No newline at end of file diff --git a/src/dcs/dcs_msg.h b/src/cmpt/cmpt_msg_tran.h similarity index 59% rename from src/dcs/dcs_msg.h rename to src/cmpt/cmpt_msg_tran.h index cd0b53cfebc9c29e0786c48a50b6d6c8201c63c1..8c5d42135258c2a18d45bb915a774658edbf45c7 100644 --- a/src/dcs/dcs_msg.h +++ b/src/cmpt/cmpt_msg_tran.h @@ -13,100 +13,110 @@ * See the Mulan PSL v2 for more details. * ------------------------------------------------------------------------- * - * dcs_msg.h + * cmpt_msg_tran.h * * * IDENTIFICATION - * src/dcs/dcs_msg.h + * src/cmpt/cmpt_msg_tran.h * * ------------------------------------------------------------------------- */ -#ifndef __DCS_MSG_H__ -#define __DCS_MSG_H__ +#ifndef __CMPT_MSG_TRAN_H__ +#define __CMPT_MSG_TRAN_H__ -#include "cm_atomic.h" -#include "dms.h" -#include "mes_interface.h" -#include "dms_mfc.h" -#include "dms_msg.h" +#include "cmpt_msg_common.h" #ifdef __cplusplus extern "C" { #endif -typedef enum en_msg_flags { - MSG_FLAG_DIRTY_PAGE = 0x01, // sent local dirty page, owner has edp - MSG_FLAG_REMOTE_DIRTY_PAGE = 0x02, // sent remote dirty page, owner has edp - MSG_FLAG_SHARED_PAGE = 0x04, // sent page is shared copy - MSG_FLAG_NO_PAGE = 0x08, // requester has shared copy, no page sent - MSG_FLAG_CEIL = 0x80 -}msg_flags_t; +typedef struct st_msg_txn_wait { + dms_message_head_t head; + char wxid[DMS_XID_SIZE]; +}msg_txn_wait_t; -#define DCS_ACK_PAGE_IS_DIRTY(msg) ((((msg)->head->flags & MSG_FLAG_DIRTY_PAGE) != 0) ? CM_TRUE : CM_FALSE) -#define DCS_ACK_PAGE_IS_REMOTE_DIRTY(msg) (((msg)->head->flags & MSG_FLAG_REMOTE_DIRTY_PAGE) ? CM_TRUE : CM_FALSE) +typedef struct st_msg_txn_info_request { + dms_message_head_t head; + uint64 xid; + uint64 scn; + bool32 is_scan; +} msg_txn_info_request_t; -typedef enum en_cr_type { - CR_TYPE_HEAP, - CR_TYPE_BTREE, -} cr_type_t; +typedef struct st_msg_txn_wait_request { + dms_message_head_t head; + uint64 xid; +} msg_txn_wait_request_t; -typedef struct st_msg_owner_clean_req { +typedef struct st_msg_txn_wait_ack { dms_message_head_t head; - dms_lock_mode_t req_mode; - char pageid[DMS_PAGEID_SIZE]; -} msg_owner_clean_req_t; + int32 status; + uint64 scn; +} msg_txn_wait_ack_t; -typedef struct st_msg_pcr_request { +typedef struct st_msg_txn_awake_request { dms_message_head_t head; - uint8 cr_type; - bool8 force_cvt; // force convert - uint32 ssn; - uint64 query_scn; - char pageid[DMS_PAGEID_SIZE]; - char xid[DMS_XID_SIZE]; - dms_session_e sess_type; -} msg_pcr_request_t; + uint64 xid; + uint64 scn; +} msg_txn_awake_request_t; -typedef struct st_msg_pcr_ack { +typedef struct st_msg_txn_snapshot { dms_message_head_t head; - bool8 force_cvt; -} msg_pcr_ack_t; + uint32 xmap; +} msg_txn_snapshot_t; -typedef struct st_msg_index_pcr_request { - msg_pcr_request_t pcr_request; - char entry[DMS_PAGEID_SIZE]; - char profile[DMS_INDEX_PROFILE_SIZE]; -} msg_index_pcr_request_t; +typedef enum en_dms_xa_oper_type { + DMS_XA_OPER_CREATE = 0, + DMS_XA_OPER_DELETE = 1 +} dms_xa_oper_type_t; -typedef struct st_msg_txn_wait { +typedef struct st_dms_xa_res_req { dms_message_head_t head; - char wxid[DMS_XID_SIZE]; -}msg_txn_wait_t; + uint8 undo_set_id; + drc_global_xid_t xa_xid; + dms_xa_oper_type_t oper_type; +} dms_xa_res_req_t; -typedef struct st_msg_cr_check { +typedef struct st_dms_xa_res_ack { dms_message_head_t head; - uint64 query_scn; - uint32 ssn; - char xid[DMS_XID_SIZE]; - char rowid[DMS_ROWID_SIZE]; -} msg_cr_check_t; + uint32 return_code; +} dms_xa_res_ack_t; -typedef struct st_msg_cr_check_ack { +typedef struct st_dms_ask_xa_owner_req { dms_message_head_t head; - bool8 is_found; -} msg_cr_check_ack_t; + dms_session_e sess_type; + drc_global_xid_t xa_xid; +} dms_ask_xa_owner_req_t; -typedef struct st_msg_ack_owner_id { +typedef struct st_dms_ask_xa_owner_ack { dms_message_head_t head; - uint32 owner_id; -} msg_ack_owner_id_t; + uint8 owner_id; + uint8 unused[3]; +} dms_ask_xa_owner_ack_t; -typedef struct st_msg_txn_info_request { +typedef struct st_dms_ask_xa_inuse_req { dms_message_head_t head; - uint64 xid; - uint64 scn; - bool32 is_scan; -} msg_txn_info_request_t; + dms_session_e sess_type; + drc_global_xid_t xa_xid; +} dms_ask_xa_inuse_req_t; + +typedef struct st_dms_ask_xa_inuse_ack { + dms_message_head_t head; + bool8 inuse; + uint8 unused[3]; +} dms_ask_xa_inuse_ack_t; + +typedef struct st_dms_end_xa_req { + dms_message_head_t head; + drc_global_xid_t xa_xid; + bool8 is_commit; + uint64 flags; + uint64 commit_scn; +} dms_end_xa_req_t; + +typedef struct st_dms_end_xa_ack { + dms_message_head_t head; + int32 return_code; +} dms_end_xa_ack_t; typedef struct st_msg_opengauss_xid_csn_request { dms_message_head_t head; @@ -142,23 +152,6 @@ typedef struct st_msg_opengauss_page_status_request { unsigned long int page_map[8]; } msg_opengauss_page_status_request_t; -typedef struct st_msg_txn_wait_request { - dms_message_head_t head; - uint64 xid; -} msg_txn_wait_request_t; - -typedef struct st_msg_txn_wait_ack { - dms_message_head_t head; - int32 status; - uint64 scn; -} msg_txn_wait_ack_t; - -typedef struct st_msg_txn_awake_request { - dms_message_head_t head; - uint64 xid; - uint64 scn; -} msg_txn_awake_request_t; - typedef struct st_msg_opengauss_txn_snapshot { dms_message_head_t head; } msg_opengauss_txn_snapshot_t; @@ -168,32 +161,6 @@ typedef struct st_msg_opengauss_txn_swinfo { uint32 proc_slot; } msg_opengauss_txn_swinfo_t; -typedef struct st_msg_txn_snapshot { - dms_message_head_t head; - uint32 xmap; -} msg_txn_snapshot_t; - -typedef struct st_msg_rls_owner_req { - dms_message_head_t head; - uint64 owner_lsn; - uint64 owner_scn; - dms_session_e sess_type; - char pageid[DMS_PAGEID_SIZE]; -} msg_rls_owner_req_t; - -typedef struct st_msg_rls_owner_ack { - dms_message_head_t head; - bool8 released; -} msg_rls_owner_ack_t; - -typedef struct st_dcs_boc_req { - dms_message_head_t head; - uint64 commit_scn; - uint64 min_scn; - uint32 inst_id; - uint64 lsn; -} dcs_boc_req_t; - typedef struct st_msg_send_opengauss_oldest_xmin { dms_message_head_t head; uint64 oldest_xmin; @@ -203,5 +170,5 @@ typedef struct st_msg_send_opengauss_oldest_xmin { } #endif -#endif /* __DCS_MSG_H__ */ +#endif // __CMPT_MSG_TRAN_H__ diff --git a/src/cmpt/cmpt_msg_version.h b/src/cmpt/cmpt_msg_version.h new file mode 100644 index 0000000000000000000000000000000000000000..2e096086178e831791b03866a2ecacef01674e37 --- /dev/null +++ b/src/cmpt/cmpt_msg_version.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * DMS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * ------------------------------------------------------------------------- + * + * cmpt_msg_version.h + * + * + * IDENTIFICATION + * src/cmpt/cmpt_msg_version.h + * + * ------------------------------------------------------------------------- + */ +#ifndef __CMPT_MSG_VERSION_H__ +#define __CMPT_MSG_VERSION_H__ + +#include "cmpt_msg_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum st_dms_protocol_version { + DMS_PROTO_VER_0 = 0, // invalid version + DMS_PROTO_VER_1 = 1, // first version + DMS_PROTO_VER_2 = 2, + DMS_PROTO_VER_3 = 3, // add MSG_REQ_OPENGAUSS_IMMEDIATE_CKPT, MSG_ACK_OPENGAUSS_IMMEDIATE_CKPT + DMS_PROTO_VER_NUMS +} dms_protocol_version_t; + +#define DMS_INVALID_PROTO_VER DMS_PROTO_VER_0 +#define DMS_SW_PROTO_VER DMS_PROTO_VER_3 + +typedef enum en_dms_protocol_result { + DMS_PROTOCOL_VERSION_NOT_MATCH = 0, + DMS_PROTOCOL_VERSION_NOT_SUPPORT = 1, +} dms_protocol_result_e; + +typedef struct st_dms_protocol_result_ack { + dms_message_head_t head; + dms_protocol_result_e result; +} dms_protocol_result_ack_t; + +typedef struct st_dms_proto_version_attr { + uint32 req_size; +} dms_proto_version_attr; + +#ifdef __cplusplus +} +#endif + +#endif // __CMPT_MSG_VERSION_H__ \ No newline at end of file diff --git a/src/cmpt/cmpt_reform_proc.c b/src/cmpt/cmpt_reform_proc.c new file mode 100644 index 0000000000000000000000000000000000000000..055ad0a161fbf0c347507119cb1d12b329375710 --- /dev/null +++ b/src/cmpt/cmpt_reform_proc.c @@ -0,0 +1,670 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * DMS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * ------------------------------------------------------------------------- + * + * cmpt_msg_proc.c + * + * + * IDENTIFICATION + * src/cmpt/cmpt_msg_proc.c + * + * ------------------------------------------------------------------------- + */ + +#include "cmpt_msg_version.h" +#include "cmpt_msg_reform.h" +#include "dms_reform_judge.h" +#include "dms_reform_judge_step.h" +#include "dms_reform_judge_switch.h" +#include "dms_reform_judge_stat.h" +#include "dms_reform.h" +#include "dms_process.h" +#include "drc_res_mgr.h" + +static void dms_reform_judgement_normal(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_disconnect(inst_lists); + dms_reform_judgement_reconnect(inst_lists); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_lock_instance(); + dms_reform_judgement_drc_clean(inst_lists); + dms_reform_judgement_rebuild(inst_lists); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_recovery_analyse(inst_lists); + dms_reform_judgement_repair(); + dms_reform_judgement_dw_recovery(inst_lists); + dms_reform_judgement_df_recovery(); + dms_reform_judgement_reset_user(); + dms_reform_judgement_sync_node_lfn(); + dms_reform_judgement_drc_access(); + dms_reform_judgement_page_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); + dms_reform_judgement_recovery(inst_lists); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); + dms_reform_judgement_file_blocked(inst_lists); + dms_reform_judgement_space_reload(); + // file_unblocked must be done before txn_deposit + dms_reform_judgement_file_unblocked(); + dms_reform_judgement_update_scn(); + // txn_deposit must before dc_init, otherwise, dc_init may be hung due to transactions accessing the deleted node. + dms_reform_judgement_rollback_prepare(inst_lists); + dms_reform_judgement_txn_deposit(inst_lists); + dms_reform_judgement_xa_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); + dms_reform_judgement_ddl_2phase_rcy(); + dms_reform_judgement_success(); + dms_reform_judgement_set_phase(DMS_PHASE_END); + dms_reform_judgement_rollback_start(inst_lists); + dms_reform_judgement_wait_ckpt(); + dms_reform_judgement_set_remove_point(inst_lists); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_new_join(instance_list_t *inst_lists) +{ + share_info_t *share_info = DMS_SHARE_INFO; + dms_reform_judgement_prepare(); + dms_reform_judgement_reconnect(inst_lists); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + if (!share_info->catalog_centralized) { + dms_reform_judgement_lock_instance(); + dms_reform_judgement_drc_clean(inst_lists); + dms_reform_judgement_rebuild(inst_lists); + } + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_dw_recovery(inst_lists); + dms_reform_judgement_sync_node_lfn(); + dms_reform_judgement_drc_access(); + dms_reform_judgement_page_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); + dms_reform_judgement_set_curr_point(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); + dms_reform_judgement_file_blocked(inst_lists); + dms_reform_judgement_space_reload(); + // file_unblocked must be done before txn_deposit + dms_reform_judgement_file_unblocked(); + dms_reform_judgement_update_scn(); + dms_reform_judgement_rollback_prepare(inst_lists); + dms_reform_judgement_txn_deposit(inst_lists); + dms_reform_judgement_xa_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); + dms_reform_judgement_success(); + dms_reform_judgement_set_phase(DMS_PHASE_END); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_old_remove(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_disconnect(inst_lists); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_lock_instance(); + dms_reform_judgement_drc_clean(inst_lists); + dms_reform_judgement_rebuild(inst_lists); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_recovery_analyse(inst_lists); + dms_reform_judgement_repair(); + dms_reform_judgement_dw_recovery(inst_lists); + dms_reform_judgement_df_recovery(); + dms_reform_judgement_reset_user(); + dms_reform_judgement_sync_node_lfn(); + dms_reform_judgement_drc_access(); + dms_reform_judgement_page_access(); + dms_reform_judgement_recovery(inst_lists); + dms_reform_judgement_file_blocked(inst_lists); + dms_reform_judgement_space_reload(); + // file_unblocked must be done before txn_deposit + dms_reform_judgement_file_unblocked(); + dms_reform_judgement_rollback_prepare(inst_lists); + dms_reform_judgement_txn_deposit(inst_lists); + dms_reform_judgement_xa_access(); + dms_reform_judgement_ddl_2phase_rcy(); + dms_reform_judgement_success(); + dms_reform_judgement_rollback_start(inst_lists); + dms_reform_judgement_wait_ckpt(); + dms_reform_judgement_set_remove_point(inst_lists); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_shutdown_consistency(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_disconnect(inst_lists); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_lock_instance(); + dms_reform_judgement_drc_clean(inst_lists); + dms_reform_judgement_rebuild(inst_lists); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_repair(); + dms_reform_judgement_sync_node_lfn(); + dms_reform_judgement_drc_access(); + dms_reform_judgement_page_access(); + dms_reform_judgement_rollback_prepare(inst_lists); + dms_reform_judgement_txn_deposit(inst_lists); + dms_reform_judgement_success(); + dms_reform_judgement_rollback_start(inst_lists); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_normal_standby(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_disconnect(inst_lists); + dms_reform_judgement_reconnect(inst_lists); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_lock_instance(); + dms_reform_judgement_drc_clean(inst_lists); + dms_reform_judgement_rebuild(inst_lists); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_repair(); + dms_reform_judgement_dw_recovery(inst_lists); + dms_reform_judgement_df_recovery(); + dms_reform_judgement_reset_user(); + dms_reform_judgement_drc_access(); + dms_reform_judgement_standby_sync(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); + dms_reform_judgement_stop_server(); + dms_reform_judgement_recovery(inst_lists); + dms_reform_judgement_page_access(); + /* stop lrpl must after page access and before txn_deposit */ + dms_reform_judgement_stop_lrpl(); + dms_reform_judgement_calibrate_log_file(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); + dms_reform_judgement_file_blocked(inst_lists); + dms_reform_judgement_space_reload(); + // file_unblocked must be done before txn_deposit + dms_reform_judgement_file_unblocked(); + dms_reform_judgement_update_scn(); + // txn_deposit must before dc_init, otherwise, dc_init may be hung due to transactions accessing the deleted node. + dms_reform_judgement_rollback_prepare(inst_lists); + dms_reform_judgement_txn_deposit(inst_lists); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); + dms_reform_judgement_success(); + dms_reform_judgement_set_phase(DMS_PHASE_END); + dms_reform_judgement_rollback_start(inst_lists); + dms_reform_judgement_wait_ckpt(); + dms_reform_judgement_start_lrpl(); + dms_reform_judgement_resume_server(); + dms_reform_judgement_done(); +} + +#ifdef OPENGAUSS +static void dms_reform_judgement_switchover_opengauss(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_start(); + dms_reform_judgement_drc_validate(false); + dms_reform_judgement_switchover_demote(inst_lists); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_lock_instance(); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_migrate(inst_lists); + dms_reform_judgement_drc_access(); + dms_reform_judgement_page_access(); + dms_reform_judgement_switch_lock(); + dms_reform_judgement_switchover_promote_opengauss(); + dms_reform_judgement_drc_validate(false); + dms_reform_judgement_success(); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_failover_opengauss(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_disconnect(inst_lists); + dms_reform_judgement_reconnect(inst_lists); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_lock_instance(); + dms_reform_judgement_drc_clean(inst_lists); + dms_reform_judgement_rebuild(inst_lists); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_drc_validate(true); /* maintain drc inaccess as failover not finished */ + dms_reform_judgement_failover_promote_opengauss(); + dms_refrom_judgement_startup_opengauss(); + dms_reform_judgement_repair(); + dms_reform_judgement_drc_access(); + dms_reform_judgement_recovery_opengauss(inst_lists); + dms_reform_judgement_page_access(); + dms_reform_judgement_drc_validate(false); + dms_reform_judgement_success(); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_normal_opengauss(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_disconnect(inst_lists); + dms_reform_judgement_reconnect(inst_lists); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_lock_instance(); + dms_reform_judgement_drc_clean(inst_lists); + dms_reform_judgement_rebuild(inst_lists); + dms_reform_judgement_remaster(inst_lists); + dms_refrom_judgement_startup_opengauss(); + dms_reform_judgement_repair(); + dms_reform_judgement_drc_access(); + dms_reform_judgement_recovery_opengauss(inst_lists); + dms_reform_judgement_page_access(); + dms_reform_judgement_drc_validate(false); + dms_reform_judgement_success(); + dms_reform_judgement_done(); +} +#endif + +static void dms_reform_judgement_build(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_drc_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); + dms_reform_judgement_page_access(); + dms_reform_judgement_xa_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); + dms_reform_judgement_file_unblocked(); + dms_reform_judgement_success(); + dms_reform_judgement_set_phase(DMS_PHASE_END); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_full_clean(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_lock_instance(); + dms_reform_judgement_drc_clean(inst_lists); + dms_reform_judgement_rebuild(inst_lists); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_repair(); +#ifndef OPENGAUSS + dms_reform_judgement_reset_user(); +#endif + dms_reform_judgement_drc_access(); + dms_reform_judgement_page_access(); + dms_reform_judgement_xa_access(); + dms_reform_judgement_success(); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_maintain(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_start(); + dms_reform_judgement_dw_recovery(inst_lists); + dms_reform_judgement_df_recovery(); + dms_reform_judgement_drc_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); + dms_reform_judgement_recovery(inst_lists); + dms_reform_judgement_page_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); + dms_reform_judgement_rollback_prepare(inst_lists); + dms_reform_judgement_rollback_start(inst_lists); + dms_reform_judgement_txn_deposit(inst_lists); + dms_reform_judgement_xa_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); + dms_reform_judgement_success(); + dms_reform_judgement_set_phase(DMS_PHASE_END); + dms_reform_judgement_wait_ckpt(); + dms_reform_judgement_set_remove_point(inst_lists); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_rst_recover(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_drc_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); + dms_reform_judgement_recovery(inst_lists); + dms_reform_judgement_success(); + dms_reform_judgement_set_phase(DMS_PHASE_END); + dms_reform_judgement_wait_ckpt(); + dms_reform_judgement_set_remove_point(inst_lists); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_standby_maintain(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_start(); + dms_reform_judgement_dw_recovery(inst_lists); + dms_reform_judgement_drc_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); + dms_reform_judgement_recovery(inst_lists); + dms_reform_judgement_page_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); + dms_reform_judgement_rollback_prepare(inst_lists); + dms_reform_judgement_rollback_start(inst_lists); + dms_reform_judgement_txn_deposit(inst_lists); + dms_reform_judgement_xa_access(); + dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); + dms_reform_judgement_success(); + dms_reform_judgement_set_phase(DMS_PHASE_END); + dms_reform_judgement_wait_ckpt(); + dms_reform_judgement_start_lrpl(); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_az_switchover_demote(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_start(); + dms_reform_judgement_az_demote_phase1(inst_lists); + dms_reform_judgement_az_demote_change_role(inst_lists); + dms_reform_judgement_az_demote_approve(inst_lists); + dms_reform_judgement_az_demote_phase2(inst_lists); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_lock_instance(); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_migrate(inst_lists); + dms_reform_judgement_drc_access(); + dms_reform_judgement_page_access(); + dms_reform_judgement_recovery(inst_lists); + dms_reform_judgement_update_scn(); + // txn_deposit must before dc_init, otherwise, dc_init may be hung due to transactions accessing the deleted node. + dms_reform_judgement_rollback_prepare(inst_lists); + dms_reform_judgement_txn_deposit(inst_lists); + dms_reform_judgement_success(); + dms_reform_judgement_rollback_start(inst_lists); + dms_reform_judgement_wait_ckpt(); + dms_reform_judgement_start_lrpl(); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_az_switchover_to_promote(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_migrate(inst_lists); + dms_reform_judgement_drc_access(); + dms_reform_judgement_page_access(); + dms_reform_judgement_az_promote_phase1(); + dms_reform_judgement_reload_txn(); + dms_reform_judgement_txn_deposit(inst_lists); + dms_reform_judgement_az_promote_phase2(); + dms_reform_judgement_file_blocked(inst_lists); + dms_reform_judgement_update_scn(); + dms_reform_judgement_ddl_2phase_rcy(); + dms_reform_judgement_space_reload(); + dms_reform_judgement_xa_access(); + dms_reform_judgement_file_unblocked(); + dms_reform_judgement_success(); + dms_reform_judgement_wait_ckpt(); + dms_reform_judgement_set_remove_point(inst_lists); + dms_reform_judgement_done(); +} + +static void dms_reform_judgement_az_failover(instance_list_t *inst_lists) +{ + dms_reform_judgement_prepare(); + dms_reform_judgement_start(); + dms_reform_judgement_drc_inaccess(); + dms_reform_judgement_remaster(inst_lists); + dms_reform_judgement_repair(); + dms_reform_judgement_drc_access(); + dms_reform_judgement_page_access(); + dms_reform_judgement_az_failover_promote_phase1(); + dms_reform_judgement_az_failover_promote_resetlog(); + dms_reform_judgement_reload_txn(); + dms_reform_judgement_txn_deposit(inst_lists); + dms_reform_judgement_az_failover_promote_phase2(); + dms_reform_judgement_file_blocked(inst_lists); + dms_reform_judgement_update_scn(); + dms_reform_judgement_ddl_2phase_rcy(); + dms_reform_judgement_space_reload(); + dms_reform_judgement_xa_access(); + dms_reform_judgement_file_unblocked(); + dms_reform_judgement_success(); + dms_reform_judgement_wait_ckpt(); + dms_reform_judgement_set_remove_point(inst_lists); + dms_reform_judgement_done(); +} + +static bool32 dms_reform_judgement_normal_check(instance_list_t *inst_lists) +{ + // there are instances which status is out or reform, no need reform. + if (inst_lists[INST_LIST_OLD_OUT].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REFORM].inst_id_count != 0 || + inst_lists[INST_LIST_NEW_OUT].inst_id_count != 0 || inst_lists[INST_LIST_NEW_REFORM].inst_id_count != 0) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, " + "old_out: %d, old_reform: %d, new_out: %d, new_reform: %d", + inst_lists[INST_LIST_OLD_OUT].inst_id_count, inst_lists[INST_LIST_OLD_REFORM].inst_id_count, + inst_lists[INST_LIST_NEW_OUT].inst_id_count, inst_lists[INST_LIST_NEW_REFORM].inst_id_count); + return CM_FALSE; + } + +#ifndef OPENGAUSS + if (dms_reform_judgement_az_switchover_check(inst_lists)) { + return CM_TRUE; + } +#endif + + if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count == 0 && inst_lists[INST_LIST_OLD_REMOVE].inst_id_count == 0 && + inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { + dms_reform_judgement_stat_cancel(); + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, old_join: 0, old_remove: 0, new_join: 0"); + return CM_FALSE; + } + + return CM_TRUE; +} + +static bool32 dms_reform_judgement_new_join_check(instance_list_t *inst_lists) +{ + // there are instances which status is out or reform, no need reform. + if (inst_lists[INST_LIST_OLD_OUT].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REFORM].inst_id_count != 0 || + inst_lists[INST_LIST_NEW_OUT].inst_id_count != 0 || inst_lists[INST_LIST_NEW_REFORM].inst_id_count != 0) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, " + "old_out: %d, old_reform: %d, new_out: %d, new_reform: %d", + inst_lists[INST_LIST_OLD_OUT].inst_id_count, inst_lists[INST_LIST_OLD_REFORM].inst_id_count, + inst_lists[INST_LIST_NEW_OUT].inst_id_count, inst_lists[INST_LIST_NEW_REFORM].inst_id_count); + return CM_FALSE; + } + + if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REMOVE].inst_id_count != 0 || + inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { + dms_reform_judgement_stat_cancel(); + return CM_FALSE; + } + + if (g_dms.callback.db_in_rollback(g_dms.reform_ctx.handle_judge)) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, db in rollback"); + dms_reform_judgement_stat_cancel(); + return CM_FALSE; + } + + return CM_TRUE; +} + +static bool32 dms_reform_judgement_old_remove_check(instance_list_t *inst_lists) +{ + // there are instances which status is out or reform, no need reform. + if (inst_lists[INST_LIST_OLD_OUT].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REFORM].inst_id_count != 0 || + inst_lists[INST_LIST_NEW_OUT].inst_id_count != 0 || inst_lists[INST_LIST_NEW_REFORM].inst_id_count != 0) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, " + "old_out: %d, old_reform: %d, new_out: %d, new_reform: %d", + inst_lists[INST_LIST_OLD_OUT].inst_id_count, inst_lists[INST_LIST_OLD_REFORM].inst_id_count, + inst_lists[INST_LIST_NEW_OUT].inst_id_count, inst_lists[INST_LIST_NEW_REFORM].inst_id_count); + return CM_FALSE; + } + + if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REMOVE].inst_id_count == 0 || + inst_lists[INST_LIST_NEW_JOIN].inst_id_count != 0) { + dms_reform_judgement_stat_cancel(); + return CM_FALSE; + } + + return CM_TRUE; +} + +static bool32 dms_reform_judgement_shutdown_consistency_check(instance_list_t *inst_lists) +{ + return dms_reform_judgement_old_remove_check(inst_lists); +} + +static bool32 dms_reform_judgement_build_check(instance_list_t *inst_lists) +{ + if (DMS_FIRST_REFORM_FINISH) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, first reform has finished"); + return CM_FALSE; + } + return CM_TRUE; +} + +#ifdef OPENGAUSS +static bool32 dms_reform_judgement_normal_opengauss_check(instance_list_t *inst_lists) +{ + // there are instances which status is out or reform, no need reform. + if (inst_lists[INST_LIST_OLD_OUT].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REFORM].inst_id_count != 0 || + inst_lists[INST_LIST_NEW_OUT].inst_id_count != 0 || inst_lists[INST_LIST_NEW_REFORM].inst_id_count != 0) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, " + "old_out: %d, old_reform: %d, new_out: %d, new_reform: %d", + inst_lists[INST_LIST_OLD_OUT].inst_id_count, inst_lists[INST_LIST_OLD_REFORM].inst_id_count, + inst_lists[INST_LIST_NEW_OUT].inst_id_count, inst_lists[INST_LIST_NEW_REFORM].inst_id_count); + return CM_FALSE; + } + + if (dms_reform_judgement_switchover_opengauss_check(inst_lists)) { + return CM_TRUE; + } + + if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count == 0 && inst_lists[INST_LIST_OLD_REMOVE].inst_id_count == 0 && + inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, old_join: 0, old_remove: 0, new_join: 0"); + dms_reform_judgement_stat_cancel(); + return CM_FALSE; + } + + return CM_TRUE; +} +#endif + +static bool32 dms_reform_judgement_full_clean_check(instance_list_t *inst_lists) +{ + return CM_TRUE; +} + +static bool32 dms_reform_judgement_maintain_check(instance_list_t *inst_lists) +{ + if (DMS_FIRST_REFORM_FINISH) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, first reform has finished"); + return CM_FALSE; + } + + // if instance status is not join, finish current judgement + if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count == 0 && inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, old_join: 0, new_join: 0"); + dms_reform_judgement_stat_cancel(); + return CM_FALSE; + } + + share_info_t *share_info = DMS_SHARE_INFO; + share_info->promote_id = (uint8)g_dms.inst_id; + return CM_TRUE; +} + +static bool32 dms_reform_judgement_rst_recover_check(instance_list_t *inst_lists) +{ + // if instance status is not join, finish current judgement, that means last rst recover has finished + if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count == 0 && inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, old_join: 0, new_join: 0"); + dms_reform_judgement_stat_cancel(); + return CM_FALSE; + } + return CM_TRUE; +} + +static bool32 dms_reform_judgement_standby_maintain_check(instance_list_t *inst_lists) +{ + if (DMS_FIRST_REFORM_FINISH) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, first reform has finished"); + return CM_FALSE; + } + + // if instance status is not join, finish current judgement + if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count == 0 && inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { + LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, old_join: 0, new_join: 0"); + return CM_FALSE; + } + + share_info_t *share_info = DMS_SHARE_INFO; + share_info->promote_id = (uint8)g_dms.inst_id; + return CM_TRUE; +} + +static dms_reform_judgement_proc_t g_reform_judgement_proc_base[DMS_REFORM_TYPE_COUNT] = { + [DMS_REFORM_TYPE_FOR_NORMAL] = { + dms_reform_judgement_normal_check, dms_reform_judgement_normal }, +#ifdef OPENGAUSS + [DMS_REFORM_TYPE_FOR_NORMAL_OPENGAUSS] = { + dms_reform_judgement_normal_opengauss_check, dms_reform_judgement_normal_opengauss }, + [DMS_REFORM_TYPE_FOR_FAILOVER_OPENGAUSS] = { + dms_reform_judgement_failover_opengauss_check, dms_reform_judgement_failover_opengauss }, +#endif + [DMS_REFORM_TYPE_FOR_BUILD] = { + dms_reform_judgement_build_check, dms_reform_judgement_build }, +#ifdef OPENGAUSS + [DMS_REFORM_TYPE_FOR_SWITCHOVER_OPENGAUSS] = { + dms_reform_judgement_switchover_opengauss_check, dms_reform_judgement_switchover_opengauss }, +#endif + [DMS_REFORM_TYPE_FOR_FULL_CLEAN] = { + dms_reform_judgement_full_clean_check, dms_reform_judgement_full_clean }, + [DMS_REFORM_TYPE_FOR_MAINTAIN] = { + dms_reform_judgement_maintain_check, dms_reform_judgement_maintain }, + [DMS_REFORM_TYPE_FOR_RST_RECOVER] = { + dms_reform_judgement_rst_recover_check, dms_reform_judgement_rst_recover }, + [DMS_REFORM_TYPE_FOR_NEW_JOIN] = { + dms_reform_judgement_new_join_check, dms_reform_judgement_new_join }, + [DMS_REFORM_TYPE_FOR_STANDBY_MAINTAIN] = { + dms_reform_judgement_standby_maintain_check, dms_reform_judgement_standby_maintain }, + [DMS_REFORM_TYPE_FOR_NORMAL_STANDBY] = { + dms_reform_judgement_normal_check, dms_reform_judgement_normal_standby }, + [DMS_REFORM_TYPE_FOR_AZ_SWITCHOVER_DEMOTE] = { + dms_reform_judgement_az_switchover_check, dms_reform_judgement_az_switchover_demote }, + [DMS_REFORM_TYPE_FOR_AZ_SWITCHOVER_PROMOTE] = { + dms_reform_judgement_az_switchover_check, dms_reform_judgement_az_switchover_to_promote }, + [DMS_REFORM_TYPE_FOR_AZ_FAILOVER] = { + dms_reform_judgement_az_failover_check, dms_reform_judgement_az_failover }, + [DMS_REFORM_TYPE_FOR_OLD_REMOVE] = { + dms_reform_judgement_old_remove_check, dms_reform_judgement_old_remove }, + [DMS_REFORM_TYPE_FOR_SHUTDOWN_CONSISTENCY] = { + dms_reform_judgement_shutdown_consistency_check, dms_reform_judgement_shutdown_consistency }, +}; + +dms_reform_judgement_proc_t *g_reform_judgement_proc_map[DMS_PROTO_VER_NUMS] = { + [DMS_PROTO_VER_1] = g_reform_judgement_proc_base, + [DMS_PROTO_VER_2] = g_reform_judgement_proc_base, + [DMS_PROTO_VER_3] = g_reform_judgement_proc_base, +}; + +dms_proto_version_attr g_req_share_info_version_ctrl[DMS_PROTO_VER_NUMS] = { + [DMS_PROTO_VER_1] = { CM_ALIGN8(sizeof(dms_message_head_t) + OFFSET_OF(share_info_t, inst_bitmap)) }, + [DMS_PROTO_VER_2] = { CM_ALIGN8(sizeof(dms_message_head_t) + OFFSET_OF(share_info_t, old_master_info)) }, + [DMS_PROTO_VER_3] = { CM_ALIGN8(sizeof(dms_message_head_t) + OFFSET_OF(share_info_t, old_master_info)) }, +}; + diff --git a/src/cmpt/cmpt_reform_proc.h b/src/cmpt/cmpt_reform_proc.h new file mode 100644 index 0000000000000000000000000000000000000000..d5793dc1a7125eb9d33663a79a8ad53729a92596 --- /dev/null +++ b/src/cmpt/cmpt_reform_proc.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * DMS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * ------------------------------------------------------------------------- + * + * cmpt_reform_proc.h + * + * + * IDENTIFICATION + * src/cmpt/cmpt_reform_proc.h + * + * ------------------------------------------------------------------------- + */ +#ifndef __CMPT_REFORM_PROC_H__ +#define __CMPT_REFORM_PROC_H__ + +#include "cmpt_msg_version.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern dms_reform_judgement_proc_t *g_reform_judgement_proc_map[DMS_PROTO_VER_NUMS]; + +#ifdef __cplusplus +} +#endif + +#endif // __CMPT_REFORM_PROC_H__ \ No newline at end of file diff --git a/src/cmpt/cmpt_reform_step.h b/src/cmpt/cmpt_reform_step.h new file mode 100644 index 0000000000000000000000000000000000000000..c70f8f97930b1cc99289a168b72901183d49ded9 --- /dev/null +++ b/src/cmpt/cmpt_reform_step.h @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * DMS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * ------------------------------------------------------------------------- + * + * cmpt_reform_step.h + * + * + * IDENTIFICATION + * src/cmpt/cmpt_reform_step.h + * + * ------------------------------------------------------------------------- + */ +#ifndef __CMPT_REFORM_STEP_H__ +#define __CMPT_REFORM_STEP_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +// Notice: every step should not be dependent on its Value, Value is only used for distinguish different step +typedef enum en_reform_step { + DMS_REFORM_STEP_DONE, + DMS_REFORM_STEP_PREPARE, // just sync wait reformer. do nothing + DMS_REFORM_STEP_START, // no need to set last_fail before this step + DMS_REFORM_STEP_DISCONNECT, + DMS_REFORM_STEP_RECONNECT, + DMS_REFORM_STEP_DRC_CLEAN, + DMS_REFORM_STEP_FULL_CLEAN, + DMS_REFORM_STEP_MIGRATE, + DMS_REFORM_STEP_REBUILD, + DMS_REFORM_STEP_REMASTER, + DMS_REFORM_STEP_REPAIR, + DMS_REFORM_STEP_SWITCH_LOCK, + DMS_REFORM_STEP_SWITCHOVER_DEMOTE, + DMS_REFORM_STEP_RECOVERY, + DMS_REFORM_STEP_RECOVERY_OPENGAUSS, + DMS_REFORM_STEP_DRC_RCY_CLEAN, + DMS_REFORM_STEP_CTL_RCY_CLEAN, + DMS_REFORM_STEP_TXN_DEPOSIT, + DMS_REFORM_STEP_ROLLBACK_PREPARE, + DMS_REFORM_STEP_ROLLBACK_START, + DMS_REFORM_STEP_SUCCESS, + DMS_REFORM_STEP_SELF_FAIL, // cause by self + DMS_REFORM_STEP_REFORM_FAIL, // cause by notification from reformer + DMS_REFORM_STEP_SYNC_WAIT, // tips: can not use before reconnect + DMS_REFORM_STEP_PAGE_ACCESS, // set page accessible + DMS_REFORM_STEP_DW_RECOVERY, // recovery the dw area + DMS_REFORM_STEP_DF_RECOVERY, + DMS_REFORM_STEP_SPACE_RELOAD, + DMS_REFORM_STEP_DRC_ACCESS, // set drc accessible + DMS_REFORM_STEP_DRC_INACCESS, // set drc inaccessible + DMS_REFORM_STEP_SWITCHOVER_PROMOTE_OPENGAUSS, + DMS_REFORM_STEP_FAILOVER_PROMOTE_OPENGAUSS, + DMS_REFORM_STEP_STARTUP_OPENGAUSS, // for opengauss + DMS_REFORM_STEP_DONE_CHECK, + DMS_REFORM_STEP_SET_PHASE, // for Gauss100 + DMS_REFORM_STEP_WAIT_DB, // for Gauss100 + DMS_REFORM_STEP_FILE_UNBLOCKED, // for Gauss100 + DMS_REFORM_STEP_FILE_BLOCKED, // for Gauss100 + DMS_REFORM_STEP_UPDATE_SCN, + DMS_REFORM_STEP_WAIT_CKPT, // for Gauss100 + DMS_REFORM_STEP_DRC_VALIDATE, + DMS_REFORM_STEP_LOCK_INSTANCE, // get X mode instance lock for reform + DMS_REFORM_STEP_PUSH_GCV_AND_UNLOCK, // push GCV in X instance lock, then unlock X + DMS_REFORM_STEP_SET_REMOVE_POINT, // for Gauss100, set rcy point who is removed node after ckpt + DMS_REFORM_STEP_RESET_USER, + DMS_REFORM_STEP_RECOVERY_ANALYSE, // for Gauss100, set rcy flag for pages which in redo log + DMS_REFORM_STEP_XA_DRC_ACCESS, // for Gauss100, set xa drc access + DMS_REFORM_STEP_DDL_2PHASE_DRC_ACCESS, + DMS_REFORM_STEP_DDL_2PHASE_RCY, + DMS_REFORM_STEP_DRC_LOCK_ALL_ACCESS, + DMS_REFORM_STEP_SET_CURRENT_POINT, + DMS_REFORM_STEP_STANDBY_UPDATE_REMOVE_NODE_CTRL, + DMS_REFORM_STEP_STANDBY_STOP_THREAD, + DMS_REFORM_STEP_STANDBY_RELOAD_NODE_CTRL, + DMS_REFORM_STEP_STANDBY_SET_ONLINE_LIST, + DMS_REFORM_STEP_STOP_SERVER, + DMS_REFORM_STEP_RESUME_SERVER_FOR_REFORMER, + DMS_REFORM_STEP_RESUME_SERVER_FOR_PARTNER, + DMS_REFORM_STEP_START_LRPL, // for Gauss100, start log replay + DMS_REFORM_STEP_STOP_LRPL, // for Gauss100, stop log replay + DMS_REFORM_STEP_CALIBRATE_LOG_FILE, + + DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_PHASE1, // for Gauss100, AZ SWITCHOVER primary to standby + DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_STOP_CKPT, + DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_UPDATE_NODE_CTRL, + DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_CHANGE_ROLE, + DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_APPROVE, // for Gauss100, AZ SWITCHOVER primary to standby + DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_PHASE2, // for Gauss100, AZ SWITCHOVER primary to standby + DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_PREPARE, // for Gauss100, AZ SWITCHOVER standby to primary + DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_PHASE1, // for Gauss100, AZ SWITCHOVER standby to primary + DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_PHASE2, // for Gauss100, AZ SWITCHOVER standby to primary + DMS_REFORM_STEP_AZ_FAILOVER_PROMOTE_PHASE1, // for Gauss100, AZ FAILOVER standby to primary + 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_SYNC_NODE_LFN, + DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_SWITCH_LOG, // for Gauss100, AZ SWITCHOVER standby to primary + DMS_REFORM_STEP_AZ_PROMOTE_SUCCESS, + DMS_REFORM_STEP_COUNT +} reform_step_t; + +// The steps will be repeated, DMS_REFORM_STEP_TOTAL_COUNT > DMS_REFORM_STEP_COUNT +#define DMS_REFORM_STEP_TOTAL_COUNT 128 +#define DMS_REFORM_PHASE_TOTAL_COUNT 8 + +#ifdef __cplusplus +} +#endif + +#endif // __CMPT_REFORM_STEP_H__ \ No newline at end of file diff --git a/src/common/dms_mfc.c b/src/common/dms_mfc.c index d8d6986786751f086a368e17e214164839a4fdf3..94adb71c0f418c0bd0d7444f43971e1554b4f883 100644 --- a/src/common/dms_mfc.c +++ b/src/common/dms_mfc.c @@ -22,7 +22,6 @@ * ------------------------------------------------------------------------- */ -#include "dms_mfc.h" #include "dms_process.h" #include "dms_error.h" #include "dms_stat.h" diff --git a/src/common/dms_mfc.h b/src/common/dms_mfc.h index a18476f92c96f1d03b4e478d9ee9bc7f01f7a118..ddf49667331603facaf489f98d498753a91e3934 100644 --- a/src/common/dms_mfc.h +++ b/src/common/dms_mfc.h @@ -27,19 +27,17 @@ #include "mes_interface.h" #include "cm_spinlock.h" #include "dms_api.h" +#include "cmpt_msg_common.h" #ifdef __cplusplus extern "C" { #endif /* common code to adapt new MES */ - #define DMS_MSG_HEAD_SIZE sizeof(dms_message_head_t) -#define DMS_ASYNC_OR_INVLD_RUID (0) - -#define DMS_MSG_HEAD_UNUSED_SIZE 24 #define DMS_MAX_WORK_THREAD_CNT 128 +#define DMS_ASYNC_OR_INVLD_RUID (0) #define MFC_RETURN_IF_BAD_RUID(ruid) \ do { \ if (ruid == 0) { \ @@ -48,31 +46,6 @@ extern "C" { } \ } while (0) -typedef struct st_dms_message_head { - unsigned int msg_proto_ver; - unsigned int sw_proto_ver; - unsigned int cmd; - unsigned int flags; - unsigned long long ruid; - unsigned char src_inst; - unsigned char dst_inst; - unsigned short size; - unsigned int cluster_ver; - unsigned short src_sid; - unsigned short dst_sid; - unsigned short tickets; - unsigned short unused; - union { - struct { - long long judge_time; // for message used in reform, check if it is the same round of reform - }; - struct { - unsigned long long seq; - }; - unsigned char reserved[DMS_MSG_HEAD_UNUSED_SIZE]; /* 64 bytes total */ - }; -} dms_message_head_t; - typedef struct st_dms_message_t { dms_message_head_t *head; char *buffer; diff --git a/src/dcs/dcs_ckpt.c b/src/dcs/dcs_ckpt.c index 1a102eb0745d9e02cfeb5896b825a20a9f752b00..a0440f8d6cbf0e8ce630b2e263dd04f4803f74a8 100644 --- a/src/dcs/dcs_ckpt.c +++ b/src/dcs/dcs_ckpt.c @@ -27,7 +27,7 @@ #include "dms.h" #include "dms_cm.h" #include "dms_error.h" -#include "dms_msg_command.h" +#include "cmpt_msg_cmd.h" #include "dms_msg_protocol.h" #include "drc.h" #include "drc_res_mgr.h" diff --git a/src/dcs/dcs_cr_page.c b/src/dcs/dcs_cr_page.c index f40b8931279d566aea4ca809f14e74b89993e9c5..2228ee84366edeb051eafc80a50ef4e0db3e53ba 100644 --- a/src/dcs/dcs_cr_page.c +++ b/src/dcs/dcs_cr_page.c @@ -24,13 +24,14 @@ #include "dcs_cr_page.h" #include "dcs_page.h" -#include "dcs_msg.h" #include "drc_res_mgr.h" #include "dms_error.h" -#include "dms_msg_command.h" +#include "cmpt_msg_cmd.h" #include "dms_msg_protocol.h" #include "dms_stat.h" #include "dms_dynamic_trace.h" +#include "cmpt_msg_pcr.h" +#include "cmpt_msg_tran.h" #ifdef __cplusplus extern "C" { @@ -94,7 +95,7 @@ static int dcs_send_pcr_request(dms_process_context_t *ctx, msg_pcr_request_t *r static int dcs_send_txn_wait(dms_process_context_t *ctx, msg_pcr_request_t *request, char *wxid) { - msg_txn_wait_t msg ; + msg_txn_wait_t msg; dms_init_ack_head(&request->head, &msg.head, MSG_ACK_TXN_WAIT, sizeof(msg_txn_wait_t), ctx->sess_id); msg.head.src_inst = ctx->inst_id; CM_ASSERT(request->head.dst_inst == ctx->inst_id); diff --git a/src/dcs/dcs_dc.c b/src/dcs/dcs_dc.c index fae5468c57be4a22eb7df82905a1fce27c354687..1b3799bf00ea7c7182937f4b48e52740a6c9318d 100644 --- a/src/dcs/dcs_dc.c +++ b/src/dcs/dcs_dc.c @@ -23,12 +23,12 @@ */ #include "dcs_dc.h" -#include "dcs_msg.h" -#include "dms_msg_command.h" #include "dms_msg_protocol.h" #include "dms_error.h" #include "dms_api.h" #include "cm_utils.h" +#include "cmpt_msg_cmd.h" +#include "cmpt_msg_misc.h" #ifdef __cplusplus extern "C" { diff --git a/src/dcs/dcs_page.h b/src/dcs/dcs_page.h index 2210e579df25f6ef69fb676670bfc97e473a4a77..b5c141d7d60fcd0d6f56cbcbaf6b3cca5e7d495f 100644 --- a/src/dcs/dcs_page.h +++ b/src/dcs/dcs_page.h @@ -24,10 +24,9 @@ #ifndef __DCS_PAGE_H__ #define __DCS_PAGE_H__ -#include "cm_types.h" #include "drc.h" -#include "dcs_msg.h" -#include "dms_msg.h" +#include "cmpt_msg_mesi.h" +#include "dms_mfc.h" #ifdef __cplusplus extern "C" { @@ -36,13 +35,6 @@ extern "C" { #define DCS_INSTID_VALID(instid) ((instid) != CM_INVALID_ID8) #define DCS_DMS_REQUEST_PAGE_WAIT_TIME 2000 -typedef struct st_msg_page_batch_op { - dms_message_head_t head; - uint32 count; - atomic_t lsn; - uint64 scn; -} msg_page_batch_op_t; - void drc_proc_buf_ctrl_recycle(dms_process_context_t *ctx, dms_message_t *receive_msg); void dcs_proc_try_ask_master_for_page_owner_id(dms_process_context_t *ctx, dms_message_t *receive_msg); void dcs_proc_release_owner_req(dms_process_context_t *ctx, dms_message_t *receive_msg); diff --git a/src/dcs/dcs_smon.c b/src/dcs/dcs_smon.c index 670e0b79f7717e77fd7f95e76122d190ee2fb557..8e2cd1751dcf60e6fe9f76aa5988d6bffde169f1 100644 --- a/src/dcs/dcs_smon.c +++ b/src/dcs/dcs_smon.c @@ -25,10 +25,11 @@ #include "dcs_smon.h" #include "dms_error.h" #include "dms_mfc.h" -#include "dms_msg_command.h" #include "dms_msg_protocol.h" #include "drc_res_mgr.h" #include "dms_stat.h" +#include "cmpt_msg_cmd.h" +#include "cmpt_msg_lock.h" #ifndef OPENGAUSS #define CM_MAX_RMS 16320 @@ -654,8 +655,8 @@ int dms_smon_req_tlock_by_tid(dms_context_t *dms_ctx, void *data, unsigned int l } typedef struct dms_send_req_and_handle_ack_ctx { - uint8 req_msg_type; - uint8 rsp_msg_type; + uint16 req_msg_type; + uint16 rsp_msg_type; uint16 msg_size; void *cookie; int (*build_req_msg_body)(void *cookie, void *req_msg); diff --git a/src/dcs/dcs_smon.h b/src/dcs/dcs_smon.h index b14c994ee0ece384d7c57e926f330bcd60f4ea2d..b9112d455a99df41a37506c6876d1800a3d654fc 100644 --- a/src/dcs/dcs_smon.h +++ b/src/dcs/dcs_smon.h @@ -31,30 +31,6 @@ extern "C" { #endif -#pragma pack(4) - typedef struct st_dms_smon_deadlock_alock_req { - dms_message_head_t head; - alockid_t alockid; - } dms_smon_deadlock_alock_req_t; - - typedef struct st_dms_smon_deadlock_alock_rsp { - dms_message_head_t head; - uint32 ret_code; - uint32 data_size; - char data[0]; - } dms_smon_deadlock_alock_rsp_t; -#pragma pack() - -typedef struct st_dcs_req_tlock_by_rm { - uint32 type; - uint16 sid; - uint16 rmid; -} dcs_req_tlock_by_rm_t; - -typedef struct st_dcs_req_tlock_by_tid { - char tlock[DMS_SMON_TLOCK_MSG_MAX_LEN]; -} dcs_req_tlock_by_tid_t; - void dcs_proc_smon_dlock_msg(dms_process_context_t *ctx, dms_message_t *receive_msg); void dcs_proc_process_get_itl_lock(dms_process_context_t *ctx, dms_message_t *receive_msg); void dcs_proc_smon_deadlock_sql(dms_process_context_t *ctx, dms_message_t *receive_msg); diff --git a/src/dcs/dcs_tran.c b/src/dcs/dcs_tran.c index 90777d5c83ca2d664e32094be257bfcb0938d1e9..37a85c21a0bb9c64ae20e27b5fe2e21237c1a9e6 100644 --- a/src/dcs/dcs_tran.c +++ b/src/dcs/dcs_tran.c @@ -23,15 +23,16 @@ */ #include "dcs_tran.h" -#include "dcs_msg.h" #include "dms.h" #include "dms_msg.h" -#include "dms_msg_command.h" +#include "cmpt_msg_cmd.h" #include "dms_msg_protocol.h" #include "drc.h" #include "drc_tran.h" #include "dms_stat.h" #include "dms_error.h" +#include "cmpt_msg_tran.h" +#include "cmpt_msg_drm.h" int dms_request_opengauss_txn_status(dms_context_t *dms_ctx, unsigned char request, unsigned char *result) { diff --git a/src/dls/dls_msg.c b/src/dls/dls_msg.c index 300c7e069a11b88a777df7d6073af05726b8d7c7..f42ed7516a581ffa8f1218751f80efca217036b7 100644 --- a/src/dls/dls_msg.c +++ b/src/dls/dls_msg.c @@ -25,10 +25,10 @@ #include "dms_error.h" #include "mes_interface.h" #include "dms_stat.h" -#include "dcs_msg.h" #include "dls_msg.h" #include "cm_encrypt.h" #include "cm_timer.h" +#include "cmpt_msg_mesi.h" bool8 g_lock_matrix[LATCH_STATUS_X + 1][LATCH_STATUS_X + 1] = { {1, 1, 1, 1}, diff --git a/src/dls/dls_msg.h b/src/dls/dls_msg.h index 6a4d24df80bbf1a68df327c82df07fdad1e9eb49..02b5ac42a9e66b46c369be92bc40cfa2105c216c 100644 --- a/src/dls/dls_msg.h +++ b/src/dls/dls_msg.h @@ -29,6 +29,7 @@ #include "dms_cm.h" #include "drc_lock.h" #include "dms_msg.h" +#include "cmpt_msg_mesi.h" #ifdef __cplusplus extern "C" { diff --git a/src/dms/dms_msg.c b/src/dms/dms_msg.c index f7552f0862adc2e4ee3e0c8efac761135563b22f..58daa2e51568f84a009b14f04ac7c3d55759da99 100644 --- a/src/dms/dms_msg.c +++ b/src/dms/dms_msg.c @@ -33,6 +33,7 @@ #include "dms_msg_protocol.h" #include "fault_injection.h" #include "dms_dynamic_trace.h" +#include "cmpt_msg_misc.h" #ifdef __cplusplus extern "C" { diff --git a/src/dms/dms_msg.h b/src/dms/dms_msg.h index ec2b20fc2b96f086ed7599b13c6a04335f1f2c3d..742a73c117acb2fde77046c9214c9cae2801a2f5 100644 --- a/src/dms/dms_msg.h +++ b/src/dms/dms_msg.h @@ -30,6 +30,8 @@ #include "dms_api.h" #include "drc.h" #include "dms_error.h" +#include "cmpt_msg_common.h" +#include "cmpt_msg_drm.h" #ifdef __cplusplus extern "C" { @@ -50,275 +52,6 @@ extern "C" { /* biggest: pcr page ack: head + ack + page */ #define DMS_MESSAGE_BUFFER_SIZE (uint32)(SIZE_K(32) + 64) -typedef struct st_msg_error { - dms_message_head_t head; - int32 code; -} msg_error_t; - -typedef struct st_dms_ask_res_req { - dms_message_head_t head; - union { - struct { - uint8 inst_id; /* the instance that the request comes from */ - uint8 curr_mode; /* current holding lock mode in request instance */ - uint8 req_mode; /* the expected lock mode that request instance wants */ - uint8 is_try; /* if is try request */ - uint8 intercept_type; - uint8 is_upgrade; /* used for table lock upgrade */ - uint16 sess_id; /* the session id that the request comes from */ - uint64 ruid; /* request packet ruid */ - uint32 srsn; - date_t req_time; - uint32 req_proto_ver; - dms_session_e sess_type; /* session type */ - }; - drc_request_info_t drc_reg_info; - }; - uint16 len; - uint8 res_type; - uint8 unused; - uint64 scn; /* sync SCN to remote instance */ - char resid[DMS_RESID_SIZE]; -} dms_ask_res_req_t; - -// msg for notifying instance load page from disk -typedef struct st_dms_ask_res_ack_load { - dms_message_head_t head; - uint64 master_lsn; - uint64 scn; - bool8 master_grant; - uint8 node_count; -} dms_ask_res_ack_ld_t; - -typedef struct st_dms_ask_res_ack_load_wrapper { - dms_ask_res_ack_ld_t ack; - uint64 node_lfn[DMS_MAX_INSTANCES]; -} dms_ask_res_ack_ld_wrapper_t; - -// msg for notifying instance is already resource owner -typedef struct st_dms_already_owner_ack { - dms_message_head_t head; - uint64 scn; -} dms_already_owner_ack_t; - -typedef struct st_dms_ask_res_ack { - dms_message_head_t head; - uint64 lsn; - uint64 scn; - uint64 edp_map; -#ifdef OPENGAUSS - uint8 seg_fileno; - uint32 seg_blockno; - bool8 need_check_pincount; - uint64 lsn_on_disk; -#endif - bool8 enable_cks; // enable checksum - uint8 unused; - uint16 checksum; -#ifndef OPENGAUSS - uint8 node_id; - uint8 node_cnt; - uint64 node_lfn; -#endif -} dms_ask_res_ack_t; - -typedef struct st_dms_ask_res_ack_wrapper { - dms_ask_res_ack_t res_ack; - uint64 data[DMS_MAX_INSTANCES + 1]; /* index 0: timestamp, other: node_lfn */ -} dms_ask_res_ack_wrapper; - -typedef struct st_dms_claim_owner_req { - dms_message_head_t head; - dms_lock_mode_t req_mode; - dms_session_e sess_type; - bool8 has_edp; // previous owner has earlier dirty page - uint8 res_type; - uint16 len; - uint64 lsn; - char resid[DMS_RESID_SIZE]; - uint32 srsn; -} dms_claim_owner_req_t; - -typedef struct st_dms_invld_req { - dms_message_head_t head; - uint64 scn; /* sync SCN to remote instance */ - uint8 is_try; - uint8 res_type; - uint16 len; - bool32 invld_owner; - dms_session_e sess_type; - char resid[DMS_RESID_SIZE]; -} dms_invld_req_t; - -typedef struct st_dms_ask_res_owner_id_req { - dms_message_head_t head; - dms_session_e sess_type; - uint16 len; - uint8 res_type; - uint8 intercept_type; - uint64 lsn; - char resid[DMS_RESID_SIZE]; -} dms_ask_res_owner_id_req_t; - -typedef struct st_dms_ask_res_owner_id_ack { - dms_message_head_t head; - uint8 owner_id; - uint8 unused[3]; -} dms_ask_res_owner_id_ack_t; - -typedef struct st_dms_res_req_info { - uint8 req_id; - uint8 owner_id; - uint8 res_type; - bool8 is_try; - uint8 unused; - uint8 intercept_type; - uint16 req_sid; - dms_session_e sess_type; - uint64 req_ruid; - uint32 len; - dms_lock_mode_t req_mode; - dms_lock_mode_t curr_mode; - char resid[DMS_RESID_SIZE]; - uint32 req_proto_ver; - uint64 seq; -} dms_res_req_info_t; - -typedef struct st_dms_cancel_request_res { - dms_message_head_t head; - union { - struct { - uint8 inst_id; /* the instance that the request comes from */ - uint8 curr_mode; /* current holding lock mode in request instance */ - uint8 req_mode; /* the expected lock mode that request instance wants */ - uint8 is_try; /* if is try request */ - uint8 intercept_type; - uint8 is_upgrade; /* used for table lock upgrade */ - uint16 sess_id; /* the session id that the request comes from */ - uint64 ruid; /* request packet ruid */ - uint32 srsn; - date_t req_time; - uint32 req_proto_ver; - dms_session_e sess_type; /* session type */ - }; - drc_request_info_t drc_reg_info; - }; - uint16 len; - uint8 res_type; - uint8 unused; - char resid[DMS_RESID_SIZE]; -} dms_cancel_request_res_t; - -typedef struct st_dms_confirm_cvt_req { - dms_message_head_t head; - uint8 res_type; - uint8 cvt_mode; - char resid[DMS_RESID_SIZE]; -}dms_confirm_cvt_req_t; - -typedef enum en_confirm_result { - CONFIRM_NONE = 0, - CONFIRM_READY = 1, - CONFIRM_CANCEL = 2 -}confirm_result_t; - -typedef struct st_dms_confirm_cvt_ack { - dms_message_head_t head; - uint32 result; - uint64 lsn; - uint64 edp_map; - uint8 lock_mode; -}dms_confirm_cvt_ack_t; - -typedef struct st_dms_query_owner_req { - dms_message_head_t head; - char resid[DMS_RESID_SIZE]; -} dms_query_owner_req_t; - -typedef struct st_dms_query_owner_ack { - dms_message_head_t head; - uint8 owner_id; -} dms_query_owner_ack_t; - -typedef enum en_dms_xa_oper_type { - DMS_XA_OPER_CREATE = 0, - DMS_XA_OPER_DELETE = 1 -} dms_xa_oper_type_t; - -typedef struct st_dms_xa_res_req { - dms_message_head_t head; - uint8 undo_set_id; - drc_global_xid_t xa_xid; - dms_xa_oper_type_t oper_type; -} dms_xa_res_req_t; - -typedef struct st_dms_xa_res_ack { - dms_message_head_t head; - uint32 return_code; -} dms_xa_res_ack_t; - -typedef struct st_dms_ask_xa_owner_req { - dms_message_head_t head; - dms_session_e sess_type; - drc_global_xid_t xa_xid; -} dms_ask_xa_owner_req_t; - -typedef struct st_dms_ask_xa_owner_ack { - dms_message_head_t head; - uint8 owner_id; - uint8 unused[3]; -} dms_ask_xa_owner_ack_t; - -typedef struct st_dms_ask_xa_inuse_req { - dms_message_head_t head; - dms_session_e sess_type; - drc_global_xid_t xa_xid; -} dms_ask_xa_inuse_req_t; - -typedef struct st_dms_ask_xa_inuse_ack { - dms_message_head_t head; - bool8 inuse; - uint8 unused[3]; -} dms_ask_xa_inuse_ack_t; - -typedef struct st_dms_end_xa_req { - dms_message_head_t head; - drc_global_xid_t xa_xid; - bool8 is_commit; - uint64 flags; - uint64 commit_scn; -} dms_end_xa_req_t; - -typedef struct st_dms_end_xa_ack { - dms_message_head_t head; - int32 return_code; -} dms_end_xa_ack_t; - -typedef struct st_dms_common_ack { - dms_message_head_t head; - int32 ret; -} dms_common_ack_t; - -typedef struct st_dms_invld_ack { - dms_common_ack_t common_ack; - uint64 scn; - uint64 lfn; -} dms_invld_ack_t; - -typedef struct st_dms_chk_ownership_req { - dms_message_head_t head; - char resid[DMS_RESID_SIZE]; - uint16 len; - uint8 inst_id; - uint8 curr_mode; -} dms_chk_ownership_req_t; - -typedef enum en_req_flags { - REQ_FLAG_DEFAULT = 0x00, - REQ_FLAG_REFORM_SESSION = 0x01, - REQ_FLAG_CEIL = 0x80, -} req_flags_t; - static inline void cm_print_error_msg(const void *msg_data) { msg_error_t *error_msg = (msg_error_t *)msg_data; @@ -481,24 +214,6 @@ bool8 dms_cmd_need_ack(uint32 cmd); void dms_proc_check_page_ownership(dms_process_context_t *proc_ctx, dms_message_t *receive_msg); void dms_build_req_info_local(dms_context_t *dms_ctx, dms_lock_mode_t curr_mode, dms_lock_mode_t req_mode, drc_request_info_t *req_info); -/* -* The following structs are used for communication -* between Primary and Standby to obtain relevant -* information about buffers on other nodes. -*/ -typedef struct st_dms_req_buf_info { - dms_message_head_t head; - unsigned long long copy_insts; - unsigned char claimed_owner; - unsigned char master_id; - unsigned char from_inst; - char resid[DMS_RESID_SIZE]; -} dms_req_buf_info_t; - -typedef struct st_dms_ack_buf_info { - dms_message_head_t head; - stat_buf_info_t buf_info; -} dms_ack_buf_info_t; int dms_send_request_buf_info(dms_context_t *dms_ctx, dv_drc_buf_info *drc_info); void dms_proc_ask_node_buf_info(dms_process_context_t *proc_ctx, dms_message_t *receive_msg); diff --git a/src/dms/dms_msg_protocol.h b/src/dms/dms_msg_protocol.h index 0ec61096572e05e3e1ae1b11aae1635f33004598..7b7b9d72038ae2d3f5bbc0eea3cad43e11e47d89 100644 --- a/src/dms/dms_msg_protocol.h +++ b/src/dms/dms_msg_protocol.h @@ -24,31 +24,12 @@ #ifndef __DMS_MSG_PROTOCOL_H__ #define __DMS_MSG_PROTOCOL_H__ +#include "cmpt_msg_version.h" + #ifdef __cplusplus extern "C" { #endif -typedef enum st_dms_protocol_version { - DMS_PROTO_VER_0 = 0, // invalid version - DMS_PROTO_VER_1 = 1, // first version - DMS_PROTO_VER_2 = 2, - DMS_PROTO_VER_3 = 3, // add MSG_REQ_OPENGAUSS_IMMEDIATE_CKPT, MSG_ACK_OPENGAUSS_IMMEDIATE_CKPT - DMS_PROTO_VER_NUMS -} dms_protocol_version_t; - -#define DMS_INVALID_PROTO_VER DMS_PROTO_VER_0 -#define DMS_SW_PROTO_VER DMS_PROTO_VER_3 - -typedef enum en_dms_protocol_result { - DMS_PROTOCOL_VERSION_NOT_MATCH = 0, - DMS_PROTOCOL_VERSION_NOT_SUPPORT = 1, -} dms_protocol_result_e; - -typedef struct st_dms_protocol_result_ack { - dms_message_head_t head; - dms_protocol_result_e result; -} dms_protocol_result_ack_t; - static inline bool8 dms_check_if_protocol_compatibility_error(int ret) { if (ret == ERRNO_DMS_PROTOCOL_VERSION_NOT_MATCH || ret == ERRNO_DMS_PROTOCOL_VERSION_NOT_SUPPORT) { @@ -75,10 +56,6 @@ void dms_protocol_proc_maintain_version(dms_process_context_t *proc_ctx, dms_mes void dms_proc_opengauss_immediate_ckpt(dms_process_context_t *process_ctx, dms_message_t *receive_msg); /****************** A lightweight, universal DMS message version compatibility solution *******************/ -typedef struct st_dms_proto_version_attr { - uint32 req_size; -} dms_proto_version_attr; - const dms_proto_version_attr *dms_get_version_attr(dms_proto_version_attr *version_attrs, uint32 proto_version); int dms_fill_versioned_msg_head(dms_proto_version_attr *version_attrs, dms_message_head_t *head, uint32 send_version); int dms_recv_versioned_msg(dms_proto_version_attr *version_attrs, dms_message_t *msg, diff --git a/src/dms/dms_process.c b/src/dms/dms_process.c index 64a698ddbefe0852b98ae5e2a550edcd29de1cf9..877b9a8c42da672cd1c8ab51e034ef4eb369dfd0 100644 --- a/src/dms/dms_process.c +++ b/src/dms/dms_process.c @@ -25,14 +25,13 @@ #include "dms_process.h" #include "dms_stat.h" #include "dcs_dc.h" -#include "dcs_msg.h" #include "dcs_page.h" #include "dcs_cr_page.h" #include "dcs_tran.h" #include "dls_msg.h" #include "dms_error.h" #include "dms_msg.h" -#include "dms_msg_command.h" +#include "cmpt_msg_cmd.h" #include "dms_msg_protocol.h" #include "drc_lock.h" #include "drc_res_mgr.h" @@ -476,7 +475,13 @@ static void dms_process_message(uint32 work_idx, uint64 ruid, mes_msg_t *mes_msg mes_msg_info_t msg_data = {head->cmd, head->src_sid}; mes_set_cur_msg_info(work_idx, &msg_data, sizeof(mes_msg_info_t)); - dms_processor_t *processor = &g_dms.processors[head->cmd]; + + dms_processor_t *processor = NULL; + if (head->cmd < MSG_REQ_END) { + processor = &g_dms.req_processors[head->cmd]; + } else { + processor = &g_dms.ack_processors[head->cmd - MSG_ACK_BEGIN]; + } if (processor->is_enqueue) { bool8 pass_check = dms_check_message_proto_version(head); if (!pass_check) { @@ -543,15 +548,26 @@ static void dms_process_message(uint32 work_idx, uint64 ruid, mes_msg_t *mes_msg static int dms_register_proc_func(processor_func_t *proc_func) { if ((proc_func->cmd_type >= MSG_REQ_END && proc_func->cmd_type < MSG_ACK_BEGIN) || - proc_func->cmd_type >= MSG_ACK_END || proc_func->cmd_type >= CM_MAX_MES_MSG_CMD) { + proc_func->cmd_type >= MSG_ACK_END) { DMS_THROW_ERROR(ERRNO_DMS_CMD_INVALID, proc_func->cmd_type); return ERRNO_DMS_CMD_INVALID; } - g_dms.processors[proc_func->cmd_type].proc = proc_func->proc; - g_dms.processors[proc_func->cmd_type].is_enqueue = proc_func->is_enqueue_work_thread; - g_dms.processors[proc_func->cmd_type].is_enable_before_reform = proc_func->is_enable_before_reform; - int ret = strcpy_s(g_dms.processors[proc_func->cmd_type].name, CM_MAX_NAME_LEN, proc_func->func_name); + uint32 index; + dms_processor_t *proc = NULL; + if (proc_func->cmd_type < MSG_REQ_END) { + // req + proc = g_dms.req_processors; + index = proc_func->cmd_type; + } else { + // ack + proc = g_dms.ack_processors; + index = proc_func->cmd_type - MSG_ACK_BEGIN; + } + proc[index].proc = proc_func->proc; + proc[index].is_enqueue = proc_func->is_enqueue_work_thread; + proc[index].is_enable_before_reform = proc_func->is_enable_before_reform; + int ret = strcpy_s(proc[index].name, CM_MAX_NAME_LEN, proc_func->func_name); DMS_SECUREC_CHECK(ret); return DMS_SUCCESS; @@ -909,7 +925,14 @@ int dms_set_mes_profile(dms_profile_t *dms_profile, mes_profile_t *mes_profile) static unsigned short dms_get_msg_cmd(char *buff) { dms_message_head_t *dms_head = (dms_message_head_t *)buff; - return (unsigned short)(dms_head->cmd); + + if (dms_head->cmd < MSG_REQ_END) { + return dms_head->cmd; + } else if (dms_head->cmd >= MSG_ACK_BEGIN && dms_head->cmd < MSG_ACK_END) { + return MSG_REQ_END + dms_head->cmd - MSG_ACK_BEGIN; + } else { + return CM_MAX_MES_MSG_CMD; + } } int dms_mes_interrupt(void *arg, int wait_time) diff --git a/src/dms/dms_process.h b/src/dms/dms_process.h index 9c5beed6ed5a3708e38aaa31792cc5c9e148d445..2501f266d47a91a4b14d0a45b7bc08e8fb12da2a 100644 --- a/src/dms/dms_process.h +++ b/src/dms/dms_process.h @@ -28,7 +28,7 @@ #include "dms_mfc.h" #include "cm_types.h" #include "dms_msg.h" -#include "dms_msg_command.h" +#include "cmpt_msg_cmd.h" #include "dms_reform.h" #include "fault_injection.h" @@ -60,7 +60,8 @@ typedef struct st_dms_instance { uint32 proc_ctx_cnt; dms_ock_scrlock_context_t scrlock_ctx; dms_process_context_t *proc_ctx; - dms_processor_t processors[CM_MAX_MES_MSG_CMD]; + dms_processor_t req_processors[DMS_REQ_CMD_SIZE]; + dms_processor_t ack_processors[DMS_ACK_CMD_SIZE]; dms_callback_t callback; reform_context_t reform_ctx; uint64 min_scn[DMS_MAX_INSTANCES]; @@ -196,7 +197,13 @@ static inline void dms_proc_broadcast_ack3(dms_process_context_t *process_ctx, d static inline const char *dms_get_mescmd_msg(uint32 cmd) { - return (cmd < MSG_CMD_CEIL) ? g_dms.processors[cmd].name : "INVALID"; + if (cmd < MSG_REQ_END) { + return g_dms.req_processors[cmd].name; + } else if (cmd >= MSG_ACK_BEGIN && cmd < MSG_ACK_END) { + return g_dms.ack_processors[cmd - MSG_ACK_BEGIN].name; + } else { + return "INVALID"; + } } unsigned int dms_get_mes_prio_by_cmd(dms_message_head_t *msg); diff --git a/src/dms/dms_stat.h b/src/dms/dms_stat.h index e1323f32301fcd156fae46a143769c123dec22a3..aefbb2b66c2095c1ed667fd4332589ab8a3a61f1 100644 --- a/src/dms/dms_stat.h +++ b/src/dms/dms_stat.h @@ -28,7 +28,7 @@ #include "cm_date.h" #include "dms_api.h" #include "cm_atomic.h" -#include "dms_msg_command.h" +#include "cmpt_msg_cmd.h" #include "cm_error.h" #ifdef __cplusplus diff --git a/src/drc/drc.h b/src/drc/drc.h index 915f063bf54580d5c09511bfba07d18921cf62b2..d4ea465c55b99deb64b5e493552e5ecfd134234f 100644 --- a/src/drc/drc.h +++ b/src/drc/drc.h @@ -349,12 +349,6 @@ typedef struct st_claim_info { uint32 srsn; } claim_info_t; -typedef struct st_edp_info { - uint64 edp_map; /* to indicate which instance holds EDP */ - uint64 lsn; /* current LSN of page */ - uint8 latest_edp; /* instance id which holds the max LSN's EDP */ -} edp_info_t; - typedef struct st_res_id { char data[DMS_RESID_SIZE]; uint16 len; @@ -372,12 +366,6 @@ typedef struct st_drc_global_xid_res { drc_global_xid_t xid; } drc_global_xa_res_t; -typedef struct st_drc_xa_res_msg { - uint8 owner_id; /* owner */ - uint8 undo_set_id; /* undo set the xa trans save in */ - drc_global_xid_t xa_xid; -} drc_xa_res_msg_t; - static inline bool32 dms_same_page(char *res, const char *resid, uint32 len) { drc_page_t *drc_page = (drc_page_t *)res; diff --git a/src/drc/drc_res_mgr.c b/src/drc/drc_res_mgr.c index 25a75c2c8619a0899366b68cbd175b79e0a261a5..d6fde4838b87d791df6e920148523a88cb261e79 100644 --- a/src/drc/drc_res_mgr.c +++ b/src/drc/drc_res_mgr.c @@ -28,6 +28,7 @@ #include "dms_error.h" #include "drc_page.h" #include "dms_reform_proc_parallel.h" +#include "cmpt_msg_drm.h" /* some global struct definition */ drc_res_ctx_t g_drc_res_ctx; diff --git a/src/drc/drc_res_mgr.h b/src/drc/drc_res_mgr.h index bf7be2dfa8b2677169ca3394533b4c2cc66df981..796581ee1b5e340b61ff7612789a665dac2ac849 100644 --- a/src/drc/drc_res_mgr.h +++ b/src/drc/drc_res_mgr.h @@ -29,6 +29,7 @@ #include "dms_process.h" #include "dms_cm.h" #include "cm_hash.h" +#include "cm_atomic.h" #ifdef __cplusplus extern "C" { diff --git a/src/drc/drc_tran.c b/src/drc/drc_tran.c index 7853887ddb0597e0f974821849083925b7c87ca0..1d1f3d1a033951d359e195899905c5038699120d 100644 --- a/src/drc/drc_tran.c +++ b/src/drc/drc_tran.c @@ -29,6 +29,7 @@ #include "dms_reform.h" #include "dms_process.h" #include "dcs_tran.h" +#include "cmpt_msg_tran.h" #define TX_WAIT_INTERVAL 5 // in milliseconds diff --git a/src/fi/fault_injection.h b/src/fi/fault_injection.h index 29e8f86407d3dd5f09b1587e0e7376fc2dc982e7..36f4aa6d191b4bc4b506fe7504297bd96dae3f7d 100644 --- a/src/fi/fault_injection.h +++ b/src/fi/fault_injection.h @@ -26,7 +26,7 @@ #include "cm_config.h" #include "dms_api.h" #include "dms_msg.h" -#include "dms_msg_command.h" +#include "cmpt_msg_cmd.h" #include "ddes_fault_injection.h" #ifdef __cplusplus diff --git a/src/param/dms_param.h b/src/param/dms_param.h index 57bc3589a5bfdfc31c233abf44e35e6b94071a65..f8b2b6a9133146b7c06ba7b442ac4d52c47571b1 100644 --- a/src/param/dms_param.h +++ b/src/param/dms_param.h @@ -25,7 +25,7 @@ #include "cm_config.h" #include "dms_api.h" #include "dms_msg.h" -#include "dms_msg_command.h" +#include "cmpt_msg_cmd.h" #include "cm_types.h" #include "dms_error.h" #include "ddes_fault_injection.h" diff --git a/src/rc/dms_reform.h b/src/rc/dms_reform.h index 79c36171b53571769d559abb0fb3f804a049632d..87eb9556dfc105911a591baf55e5f2bc19c345d0 100644 --- a/src/rc/dms_reform.h +++ b/src/rc/dms_reform.h @@ -32,6 +32,7 @@ #include "drc.h" #include "dms_reform_cm_res.h" #include "scrlock_adapter.h" +#include "cmpt_msg_reform.h" #ifdef __cplusplus extern "C" { @@ -92,109 +93,6 @@ extern "C" { } \ } while (CM_FALSE) -typedef enum en_inst_list_type { - INST_LIST_OLD_BASE = 0, - INST_LIST_OLD_OUT = INST_LIST_OLD_BASE + DMS_ONLINE_STATUS_OUT, - INST_LIST_OLD_JOIN = INST_LIST_OLD_BASE + DMS_ONLINE_STATUS_JOIN, - INST_LIST_OLD_REFORM = INST_LIST_OLD_BASE + DMS_ONLINE_STATUS_REFORM, - INST_LIST_OLD_IN = INST_LIST_OLD_BASE + DMS_ONLINE_STATUS_IN, - INST_LIST_OLD_REMOVE, - INST_LIST_NEW_BASE, - INST_LIST_NEW_OUT = INST_LIST_NEW_BASE + DMS_ONLINE_STATUS_OUT, - INST_LIST_NEW_JOIN = INST_LIST_NEW_BASE + DMS_ONLINE_STATUS_JOIN, - INST_LIST_NEW_REFORM = INST_LIST_NEW_BASE + DMS_ONLINE_STATUS_REFORM, - INST_LIST_NEW_IN = INST_LIST_NEW_BASE + DMS_ONLINE_STATUS_IN, - INST_LIST_TYPE_COUNT -} inst_list_type_t; - -// The steps will be repeated, DMS_REFORM_STEP_TOTAL_COUNT > DMS_REFORM_STEP_COUNT -#define DMS_REFORM_STEP_TOTAL_COUNT 128 -#define DMS_REFORM_PHASE_TOTAL_COUNT 8 - -// Notice: every step should not be dependent on its Value, Value is only used for distinguish different step -typedef enum en_reform_step { - DMS_REFORM_STEP_DONE, - DMS_REFORM_STEP_PREPARE, // just sync wait reformer. do nothing - DMS_REFORM_STEP_START, // no need to set last_fail before this step - DMS_REFORM_STEP_DISCONNECT, - DMS_REFORM_STEP_RECONNECT, - DMS_REFORM_STEP_DRC_CLEAN, - DMS_REFORM_STEP_FULL_CLEAN, - DMS_REFORM_STEP_MIGRATE, - DMS_REFORM_STEP_REBUILD, - DMS_REFORM_STEP_REMASTER, - DMS_REFORM_STEP_REPAIR, - DMS_REFORM_STEP_SWITCH_LOCK, - DMS_REFORM_STEP_SWITCHOVER_DEMOTE, - DMS_REFORM_STEP_RECOVERY, - DMS_REFORM_STEP_RECOVERY_OPENGAUSS, - DMS_REFORM_STEP_DRC_RCY_CLEAN, - DMS_REFORM_STEP_CTL_RCY_CLEAN, - DMS_REFORM_STEP_TXN_DEPOSIT, - DMS_REFORM_STEP_ROLLBACK_PREPARE, - DMS_REFORM_STEP_ROLLBACK_START, - DMS_REFORM_STEP_SUCCESS, - DMS_REFORM_STEP_SELF_FAIL, // cause by self - DMS_REFORM_STEP_REFORM_FAIL, // cause by notification from reformer - DMS_REFORM_STEP_SYNC_WAIT, // tips: can not use before reconnect - DMS_REFORM_STEP_PAGE_ACCESS, // set page accessible - DMS_REFORM_STEP_DW_RECOVERY, // recovery the dw area - DMS_REFORM_STEP_DF_RECOVERY, - DMS_REFORM_STEP_SPACE_RELOAD, - DMS_REFORM_STEP_DRC_ACCESS, // set drc accessible - DMS_REFORM_STEP_DRC_INACCESS, // set drc inaccessible - DMS_REFORM_STEP_SWITCHOVER_PROMOTE_OPENGAUSS, - DMS_REFORM_STEP_FAILOVER_PROMOTE_OPENGAUSS, - DMS_REFORM_STEP_STARTUP_OPENGAUSS, // for opengauss - DMS_REFORM_STEP_DONE_CHECK, - DMS_REFORM_STEP_SET_PHASE, // for Gauss100 - DMS_REFORM_STEP_WAIT_DB, // for Gauss100 - DMS_REFORM_STEP_FILE_UNBLOCKED, // for Gauss100 - DMS_REFORM_STEP_FILE_BLOCKED, // for Gauss100 - DMS_REFORM_STEP_UPDATE_SCN, - DMS_REFORM_STEP_WAIT_CKPT, // for Gauss100 - DMS_REFORM_STEP_DRC_VALIDATE, - DMS_REFORM_STEP_LOCK_INSTANCE, // get X mode instance lock for reform - DMS_REFORM_STEP_PUSH_GCV_AND_UNLOCK, // push GCV in X instance lock, then unlock X - DMS_REFORM_STEP_SET_REMOVE_POINT, // for Gauss100, set rcy point who is removed node after ckpt - DMS_REFORM_STEP_RESET_USER, - DMS_REFORM_STEP_RECOVERY_ANALYSE, // for Gauss100, set rcy flag for pages which in redo log - DMS_REFORM_STEP_XA_DRC_ACCESS, // for Gauss100, set xa drc access - DMS_REFORM_STEP_DDL_2PHASE_DRC_ACCESS, - DMS_REFORM_STEP_DDL_2PHASE_RCY, - DMS_REFORM_STEP_DRC_LOCK_ALL_ACCESS, - DMS_REFORM_STEP_SET_CURRENT_POINT, - DMS_REFORM_STEP_STANDBY_UPDATE_REMOVE_NODE_CTRL, - DMS_REFORM_STEP_STANDBY_STOP_THREAD, - DMS_REFORM_STEP_STANDBY_RELOAD_NODE_CTRL, - DMS_REFORM_STEP_STANDBY_SET_ONLINE_LIST, - DMS_REFORM_STEP_STOP_SERVER, - DMS_REFORM_STEP_RESUME_SERVER_FOR_REFORMER, - DMS_REFORM_STEP_RESUME_SERVER_FOR_PARTNER, - DMS_REFORM_STEP_START_LRPL, // for Gauss100, start log replay - DMS_REFORM_STEP_STOP_LRPL, // for Gauss100, stop log replay - DMS_REFORM_STEP_CALIBRATE_LOG_FILE, - - DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_PHASE1, // for Gauss100, AZ SWITCHOVER primary to standby - DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_STOP_CKPT, - DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_UPDATE_NODE_CTRL, - DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_CHANGE_ROLE, - DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_APPROVE, // for Gauss100, AZ SWITCHOVER primary to standby - DMS_REFORM_STEP_AZ_SWITCH_DEMOTE_PHASE2, // for Gauss100, AZ SWITCHOVER primary to standby - DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_PREPARE, // for Gauss100, AZ SWITCHOVER standby to primary - DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_PHASE1, // for Gauss100, AZ SWITCHOVER standby to primary - DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_PHASE2, // for Gauss100, AZ SWITCHOVER standby to primary - DMS_REFORM_STEP_AZ_FAILOVER_PROMOTE_PHASE1, // for Gauss100, AZ FAILOVER standby to primary - 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_SYNC_NODE_LFN, - DMS_REFORM_STEP_AZ_SWITCH_PROMOTE_SWITCH_LOG, // for Gauss100, AZ SWITCHOVER standby to primary - DMS_REFORM_STEP_AZ_PROMOTE_SUCCESS, - DMS_REFORM_STEP_COUNT -} reform_step_t; - #define DMS_REFORM_STEP_DESC_STR_LEN 30 typedef enum en_dms_thread_status { @@ -204,82 +102,6 @@ typedef enum en_dms_thread_status { DMS_THREAD_STATUS_PAUSED, } dms_thread_status_t; -typedef struct st_migrate_task { - uint8 export_inst; - uint8 import_inst; - uint8 part_id; - uint8 unused; -} migrate_task_t; - -typedef struct st_migrate_info { - migrate_task_t migrate_task[DRC_MAX_PART_NUM]; - uint8 migrate_task_num; - uint8 unused[3]; -} migrate_info_t; - -typedef struct st_remaster_info { - drc_part_t part_map[DRC_MAX_PART_NUM]; - drc_inst_part_t inst_part_tbl[DMS_MAX_INSTANCES]; - uint8 deposit_map[DMS_MAX_INSTANCES]; -} remaster_info_t; - -typedef struct st_version_info { - uint64 start_time; - uint8 inst_id; - uint8 unused[3]; -} version_info_t; - -#pragma pack(4) -/* Tips: Byte alignment is required, padding is not allowed */ -typedef struct st_share_info { - /* ============= start version 1 =================*/ - reform_step_t reform_step[DMS_REFORM_STEP_TOTAL_COUNT]; - reform_phase_t reform_phase[DMS_REFORM_PHASE_TOTAL_COUNT]; - instance_list_t list_stable; - instance_list_t list_online; - instance_list_t list_offline; - instance_list_t list_reconnect; - instance_list_t list_disconnect; - instance_list_t list_clean; - instance_list_t list_rebuild; - instance_list_t list_recovery; - instance_list_t list_withdraw; - instance_list_t list_rollback; - uint64 bitmap_stable; - uint64 bitmap_online; - uint64 bitmap_reconnect; - uint64 bitmap_disconnect; - uint64 bitmap_clean; - uint64 bitmap_recovery; - uint64 bitmap_in; - uint64 bitmap_remove; - remaster_info_t remaster_info; - migrate_info_t migrate_info; - version_info_t reformer_version; // record reformer version, find reformer restart in time - version_info_t switch_version; // in reform of switchover, there is another reformer - dms_reform_type_t reform_type; - uint8 reform_step_count; - uint8 reform_phase_count; - bool8 full_clean; - uint8 reformer_id; // current reformer id - uint8 promote_id; // instance promote to primary - uint8 demote_id; // instance demote to standy; - uint8 last_reformer; // last reformer - bool8 catalog_centralized; - uint64 version_num; - dw_recovery_info_t dw_recovery_info; - uint64 start_times[DMS_MAX_INSTANCES]; - date_t judge_time; - uint32 proto_version; - /* ============= end version 1 =================*/ - - /* ============= start version 2 =================*/ - uint64 inst_bitmap[INST_LIST_TYPE_COUNT]; - /* ============= end version 2 =================*/ -} share_info_t; - -#pragma pack() - typedef struct st_rebuild_info { void *rebuild_data[DMS_MAX_INSTANCES]; } rebuild_info_t; diff --git a/src/rc/dms_reform_judge.c b/src/rc/dms_reform_judge.c index 411f4f5a3d021c455bc6fb6be97fdbcece34d802..e83d38ee82d18633ac91824b5c4b4a09302c9d51 100644 --- a/src/rc/dms_reform_judge.c +++ b/src/rc/dms_reform_judge.c @@ -31,6 +31,8 @@ #include "dms_reform_judge_stat.h" #include "dms_reform_judge_switch.h" #include "dms_dynamic_trace.h" +#include "cmpt_reform_step.h" +#include "cmpt_reform_proc.h" extern dms_reform_proc_t g_dms_reform_procs[DMS_REFORM_STEP_COUNT]; @@ -570,591 +572,6 @@ static void dms_reform_judgement_list_collect(instance_list_t *inst_lists, uint8 } } -static void dms_reform_judgement_normal(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_disconnect(inst_lists); - dms_reform_judgement_reconnect(inst_lists); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_lock_instance(); - dms_reform_judgement_drc_clean(inst_lists); - dms_reform_judgement_rebuild(inst_lists); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_recovery_analyse(inst_lists); - dms_reform_judgement_repair(); - dms_reform_judgement_dw_recovery(inst_lists); - dms_reform_judgement_df_recovery(); - dms_reform_judgement_reset_user(); - dms_reform_judgement_sync_node_lfn(); - dms_reform_judgement_drc_access(); - dms_reform_judgement_page_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); - dms_reform_judgement_recovery(inst_lists); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); - dms_reform_judgement_file_blocked(inst_lists); - dms_reform_judgement_space_reload(); - // file_unblocked must be done before txn_deposit - dms_reform_judgement_file_unblocked(); - dms_reform_judgement_update_scn(); - // txn_deposit must before dc_init, otherwise, dc_init may be hung due to transactions accessing the deleted node. - dms_reform_judgement_rollback_prepare(inst_lists); - dms_reform_judgement_txn_deposit(inst_lists); - dms_reform_judgement_xa_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); - dms_reform_judgement_ddl_2phase_rcy(); - dms_reform_judgement_success(); - dms_reform_judgement_set_phase(DMS_PHASE_END); - dms_reform_judgement_rollback_start(inst_lists); - dms_reform_judgement_wait_ckpt(); - dms_reform_judgement_set_remove_point(inst_lists); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_new_join(instance_list_t *inst_lists) -{ - share_info_t *share_info = DMS_SHARE_INFO; - dms_reform_judgement_prepare(); - dms_reform_judgement_reconnect(inst_lists); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - if (!share_info->catalog_centralized) { - dms_reform_judgement_lock_instance(); - dms_reform_judgement_drc_clean(inst_lists); - dms_reform_judgement_rebuild(inst_lists); - } - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_dw_recovery(inst_lists); - dms_reform_judgement_sync_node_lfn(); - dms_reform_judgement_drc_access(); - dms_reform_judgement_page_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); - dms_reform_judgement_set_curr_point(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); - dms_reform_judgement_file_blocked(inst_lists); - dms_reform_judgement_space_reload(); - // file_unblocked must be done before txn_deposit - dms_reform_judgement_file_unblocked(); - dms_reform_judgement_update_scn(); - dms_reform_judgement_rollback_prepare(inst_lists); - dms_reform_judgement_txn_deposit(inst_lists); - dms_reform_judgement_xa_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); - dms_reform_judgement_success(); - dms_reform_judgement_set_phase(DMS_PHASE_END); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_old_remove(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_disconnect(inst_lists); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_lock_instance(); - dms_reform_judgement_drc_clean(inst_lists); - dms_reform_judgement_rebuild(inst_lists); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_recovery_analyse(inst_lists); - dms_reform_judgement_repair(); - dms_reform_judgement_dw_recovery(inst_lists); - dms_reform_judgement_df_recovery(); - dms_reform_judgement_reset_user(); - dms_reform_judgement_sync_node_lfn(); - dms_reform_judgement_drc_access(); - dms_reform_judgement_page_access(); - dms_reform_judgement_recovery(inst_lists); - dms_reform_judgement_file_blocked(inst_lists); - dms_reform_judgement_space_reload(); - // file_unblocked must be done before txn_deposit - dms_reform_judgement_file_unblocked(); - dms_reform_judgement_rollback_prepare(inst_lists); - dms_reform_judgement_txn_deposit(inst_lists); - dms_reform_judgement_xa_access(); - dms_reform_judgement_ddl_2phase_rcy(); - dms_reform_judgement_success(); - dms_reform_judgement_rollback_start(inst_lists); - dms_reform_judgement_wait_ckpt(); - dms_reform_judgement_set_remove_point(inst_lists); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_shutdown_consistency(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_disconnect(inst_lists); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_lock_instance(); - dms_reform_judgement_drc_clean(inst_lists); - dms_reform_judgement_rebuild(inst_lists); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_repair(); - dms_reform_judgement_sync_node_lfn(); - dms_reform_judgement_drc_access(); - dms_reform_judgement_page_access(); - dms_reform_judgement_rollback_prepare(inst_lists); - dms_reform_judgement_txn_deposit(inst_lists); - dms_reform_judgement_success(); - dms_reform_judgement_rollback_start(inst_lists); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_normal_standby(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_disconnect(inst_lists); - dms_reform_judgement_reconnect(inst_lists); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_lock_instance(); - dms_reform_judgement_drc_clean(inst_lists); - dms_reform_judgement_rebuild(inst_lists); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_repair(); - dms_reform_judgement_dw_recovery(inst_lists); - dms_reform_judgement_df_recovery(); - dms_reform_judgement_reset_user(); - dms_reform_judgement_drc_access(); - dms_reform_judgement_standby_sync(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); - dms_reform_judgement_stop_server(); - dms_reform_judgement_recovery(inst_lists); - dms_reform_judgement_page_access(); - /* stop lrpl must after page access and before txn_deposit */ - dms_reform_judgement_stop_lrpl(); - dms_reform_judgement_calibrate_log_file(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); - dms_reform_judgement_file_blocked(inst_lists); - dms_reform_judgement_space_reload(); - // file_unblocked must be done before txn_deposit - dms_reform_judgement_file_unblocked(); - dms_reform_judgement_update_scn(); - // txn_deposit must before dc_init, otherwise, dc_init may be hung due to transactions accessing the deleted node. - dms_reform_judgement_rollback_prepare(inst_lists); - dms_reform_judgement_txn_deposit(inst_lists); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); - dms_reform_judgement_success(); - dms_reform_judgement_set_phase(DMS_PHASE_END); - dms_reform_judgement_rollback_start(inst_lists); - dms_reform_judgement_wait_ckpt(); - dms_reform_judgement_start_lrpl(); - dms_reform_judgement_resume_server(); - dms_reform_judgement_done(); -} - -#ifdef OPENGAUSS -static void dms_reform_judgement_switchover_opengauss(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_start(); - dms_reform_judgement_drc_validate(false); - dms_reform_judgement_switchover_demote(inst_lists); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_lock_instance(); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_migrate(inst_lists); - dms_reform_judgement_drc_access(); - dms_reform_judgement_page_access(); - dms_reform_judgement_switch_lock(); - dms_reform_judgement_switchover_promote_opengauss(); - dms_reform_judgement_drc_validate(false); - dms_reform_judgement_success(); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_failover_opengauss(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_disconnect(inst_lists); - dms_reform_judgement_reconnect(inst_lists); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_lock_instance(); - dms_reform_judgement_drc_clean(inst_lists); - dms_reform_judgement_rebuild(inst_lists); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_drc_validate(true); /* maintain drc inaccess as failover not finished */ - dms_reform_judgement_failover_promote_opengauss(); - dms_refrom_judgement_startup_opengauss(); - dms_reform_judgement_repair(); - dms_reform_judgement_drc_access(); - dms_reform_judgement_recovery_opengauss(inst_lists); - dms_reform_judgement_page_access(); - dms_reform_judgement_drc_validate(false); - dms_reform_judgement_success(); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_normal_opengauss(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_disconnect(inst_lists); - dms_reform_judgement_reconnect(inst_lists); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_lock_instance(); - dms_reform_judgement_drc_clean(inst_lists); - dms_reform_judgement_rebuild(inst_lists); - dms_reform_judgement_remaster(inst_lists); - dms_refrom_judgement_startup_opengauss(); - dms_reform_judgement_repair(); - dms_reform_judgement_drc_access(); - dms_reform_judgement_recovery_opengauss(inst_lists); - dms_reform_judgement_page_access(); - dms_reform_judgement_drc_validate(false); - dms_reform_judgement_success(); - dms_reform_judgement_done(); -} -#endif - -static void dms_reform_judgement_build(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_drc_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); - dms_reform_judgement_page_access(); - dms_reform_judgement_xa_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); - dms_reform_judgement_file_unblocked(); - dms_reform_judgement_success(); - dms_reform_judgement_set_phase(DMS_PHASE_END); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_full_clean(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_lock_instance(); - dms_reform_judgement_drc_clean(inst_lists); - dms_reform_judgement_rebuild(inst_lists); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_repair(); -#ifndef OPENGAUSS - dms_reform_judgement_reset_user(); -#endif - dms_reform_judgement_drc_access(); - dms_reform_judgement_page_access(); - dms_reform_judgement_xa_access(); - dms_reform_judgement_success(); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_maintain(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_start(); - dms_reform_judgement_dw_recovery(inst_lists); - dms_reform_judgement_df_recovery(); - dms_reform_judgement_drc_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); - dms_reform_judgement_recovery(inst_lists); - dms_reform_judgement_page_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); - dms_reform_judgement_rollback_prepare(inst_lists); - dms_reform_judgement_rollback_start(inst_lists); - dms_reform_judgement_txn_deposit(inst_lists); - dms_reform_judgement_xa_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); - dms_reform_judgement_success(); - dms_reform_judgement_set_phase(DMS_PHASE_END); - dms_reform_judgement_wait_ckpt(); - dms_reform_judgement_set_remove_point(inst_lists); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_rst_recover(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_drc_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); - dms_reform_judgement_recovery(inst_lists); - dms_reform_judgement_success(); - dms_reform_judgement_set_phase(DMS_PHASE_END); - dms_reform_judgement_wait_ckpt(); - dms_reform_judgement_set_remove_point(inst_lists); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_standby_maintain(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_start(); - dms_reform_judgement_dw_recovery(inst_lists); - dms_reform_judgement_drc_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_DRC_ACCESS); - dms_reform_judgement_recovery(inst_lists); - dms_reform_judgement_page_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_RECOVERY); - dms_reform_judgement_rollback_prepare(inst_lists); - dms_reform_judgement_rollback_start(inst_lists); - dms_reform_judgement_txn_deposit(inst_lists); - dms_reform_judgement_xa_access(); - dms_reform_judgement_set_phase(DMS_PHASE_AFTER_TXN_DEPOSIT); - dms_reform_judgement_success(); - dms_reform_judgement_set_phase(DMS_PHASE_END); - dms_reform_judgement_wait_ckpt(); - dms_reform_judgement_start_lrpl(); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_az_switchover_demote(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_start(); - dms_reform_judgement_az_demote_phase1(inst_lists); - dms_reform_judgement_az_demote_change_role(inst_lists); - dms_reform_judgement_az_demote_approve(inst_lists); - dms_reform_judgement_az_demote_phase2(inst_lists); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_lock_instance(); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_migrate(inst_lists); - dms_reform_judgement_drc_access(); - dms_reform_judgement_page_access(); - dms_reform_judgement_recovery(inst_lists); - dms_reform_judgement_update_scn(); - // txn_deposit must before dc_init, otherwise, dc_init may be hung due to transactions accessing the deleted node. - dms_reform_judgement_rollback_prepare(inst_lists); - dms_reform_judgement_txn_deposit(inst_lists); - dms_reform_judgement_success(); - dms_reform_judgement_rollback_start(inst_lists); - dms_reform_judgement_wait_ckpt(); - dms_reform_judgement_start_lrpl(); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_az_switchover_to_promote(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_migrate(inst_lists); - dms_reform_judgement_drc_access(); - dms_reform_judgement_page_access(); - dms_reform_judgement_az_promote_phase1(); - dms_reform_judgement_reload_txn(); - dms_reform_judgement_txn_deposit(inst_lists); - dms_reform_judgement_az_promote_phase2(); - dms_reform_judgement_file_blocked(inst_lists); - dms_reform_judgement_update_scn(); - dms_reform_judgement_ddl_2phase_rcy(); - dms_reform_judgement_space_reload(); - dms_reform_judgement_xa_access(); - dms_reform_judgement_file_unblocked(); - dms_reform_judgement_success(); - dms_reform_judgement_wait_ckpt(); - dms_reform_judgement_set_remove_point(inst_lists); - dms_reform_judgement_done(); -} - -static void dms_reform_judgement_az_failover(instance_list_t *inst_lists) -{ - dms_reform_judgement_prepare(); - dms_reform_judgement_start(); - dms_reform_judgement_drc_inaccess(); - dms_reform_judgement_remaster(inst_lists); - dms_reform_judgement_repair(); - dms_reform_judgement_drc_access(); - dms_reform_judgement_page_access(); - dms_reform_judgement_az_failover_promote_phase1(); - dms_reform_judgement_az_failover_promote_resetlog(); - dms_reform_judgement_reload_txn(); - dms_reform_judgement_txn_deposit(inst_lists); - dms_reform_judgement_az_failover_promote_phase2(); - dms_reform_judgement_file_blocked(inst_lists); - dms_reform_judgement_update_scn(); - dms_reform_judgement_ddl_2phase_rcy(); - dms_reform_judgement_space_reload(); - dms_reform_judgement_xa_access(); - dms_reform_judgement_file_unblocked(); - dms_reform_judgement_success(); - dms_reform_judgement_wait_ckpt(); - dms_reform_judgement_set_remove_point(inst_lists); - dms_reform_judgement_done(); -} - -static bool32 dms_reform_judgement_normal_check(instance_list_t *inst_lists) -{ - // there are instances which status is out or reform, no need reform. - if (inst_lists[INST_LIST_OLD_OUT].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REFORM].inst_id_count != 0 || - inst_lists[INST_LIST_NEW_OUT].inst_id_count != 0 || inst_lists[INST_LIST_NEW_REFORM].inst_id_count != 0) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, " - "old_out: %d, old_reform: %d, new_out: %d, new_reform: %d", - inst_lists[INST_LIST_OLD_OUT].inst_id_count, inst_lists[INST_LIST_OLD_REFORM].inst_id_count, - inst_lists[INST_LIST_NEW_OUT].inst_id_count, inst_lists[INST_LIST_NEW_REFORM].inst_id_count); - return CM_FALSE; - } - -#ifndef OPENGAUSS - if (dms_reform_judgement_az_switchover_check(inst_lists)) { - return CM_TRUE; - } -#endif - - if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count == 0 && inst_lists[INST_LIST_OLD_REMOVE].inst_id_count == 0 && - inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { - dms_reform_judgement_stat_cancel(); - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, old_join: 0, old_remove: 0, new_join: 0"); - return CM_FALSE; - } - - return CM_TRUE; -} - -static bool32 dms_reform_judgement_new_join_check(instance_list_t *inst_lists) -{ - // there are instances which status is out or reform, no need reform. - if (inst_lists[INST_LIST_OLD_OUT].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REFORM].inst_id_count != 0 || - inst_lists[INST_LIST_NEW_OUT].inst_id_count != 0 || inst_lists[INST_LIST_NEW_REFORM].inst_id_count != 0) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, " - "old_out: %d, old_reform: %d, new_out: %d, new_reform: %d", - inst_lists[INST_LIST_OLD_OUT].inst_id_count, inst_lists[INST_LIST_OLD_REFORM].inst_id_count, - inst_lists[INST_LIST_NEW_OUT].inst_id_count, inst_lists[INST_LIST_NEW_REFORM].inst_id_count); - return CM_FALSE; - } - - if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REMOVE].inst_id_count != 0 || - inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { - dms_reform_judgement_stat_cancel(); - return CM_FALSE; - } - - if (g_dms.callback.db_in_rollback(g_dms.reform_ctx.handle_judge)) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, db in rollback"); - dms_reform_judgement_stat_cancel(); - return CM_FALSE; - } - - return CM_TRUE; -} - -static bool32 dms_reform_judgement_old_remove_check(instance_list_t *inst_lists) -{ - // there are instances which status is out or reform, no need reform. - if (inst_lists[INST_LIST_OLD_OUT].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REFORM].inst_id_count != 0 || - inst_lists[INST_LIST_NEW_OUT].inst_id_count != 0 || inst_lists[INST_LIST_NEW_REFORM].inst_id_count != 0) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, " - "old_out: %d, old_reform: %d, new_out: %d, new_reform: %d", - inst_lists[INST_LIST_OLD_OUT].inst_id_count, inst_lists[INST_LIST_OLD_REFORM].inst_id_count, - inst_lists[INST_LIST_NEW_OUT].inst_id_count, inst_lists[INST_LIST_NEW_REFORM].inst_id_count); - return CM_FALSE; - } - - if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REMOVE].inst_id_count == 0 || - inst_lists[INST_LIST_NEW_JOIN].inst_id_count != 0) { - dms_reform_judgement_stat_cancel(); - return CM_FALSE; - } - - return CM_TRUE; -} - -static bool32 dms_reform_judgement_shutdown_consistency_check(instance_list_t *inst_lists) -{ - return dms_reform_judgement_old_remove_check(inst_lists); -} - -static bool32 dms_reform_judgement_build_check(instance_list_t *inst_lists) -{ - if (DMS_FIRST_REFORM_FINISH) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, first reform has finished"); - return CM_FALSE; - } - return CM_TRUE; -} - -#ifdef OPENGAUSS -static bool32 dms_reform_judgement_normal_opengauss_check(instance_list_t *inst_lists) -{ - // there are instances which status is out or reform, no need reform. - if (inst_lists[INST_LIST_OLD_OUT].inst_id_count != 0 || inst_lists[INST_LIST_OLD_REFORM].inst_id_count != 0 || - inst_lists[INST_LIST_NEW_OUT].inst_id_count != 0 || inst_lists[INST_LIST_NEW_REFORM].inst_id_count != 0) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, " - "old_out: %d, old_reform: %d, new_out: %d, new_reform: %d", - inst_lists[INST_LIST_OLD_OUT].inst_id_count, inst_lists[INST_LIST_OLD_REFORM].inst_id_count, - inst_lists[INST_LIST_NEW_OUT].inst_id_count, inst_lists[INST_LIST_NEW_REFORM].inst_id_count); - return CM_FALSE; - } - - if (dms_reform_judgement_switchover_opengauss_check(inst_lists)) { - return CM_TRUE; - } - - if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count == 0 && inst_lists[INST_LIST_OLD_REMOVE].inst_id_count == 0 && - inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, old_join: 0, old_remove: 0, new_join: 0"); - dms_reform_judgement_stat_cancel(); - return CM_FALSE; - } - - return CM_TRUE; -} -#endif - -static bool32 dms_reform_judgement_full_clean_check(instance_list_t *inst_lists) -{ - return CM_TRUE; -} - -static bool32 dms_reform_judgement_maintain_check(instance_list_t *inst_lists) -{ - if (DMS_FIRST_REFORM_FINISH) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, first reform has finished"); - return CM_FALSE; - } - - // if instance status is not join, finish current judgement - if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count == 0 && inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, old_join: 0, new_join: 0"); - dms_reform_judgement_stat_cancel(); - return CM_FALSE; - } - - share_info_t *share_info = DMS_SHARE_INFO; - share_info->promote_id = (uint8)g_dms.inst_id; - return CM_TRUE; -} - -static bool32 dms_reform_judgement_rst_recover_check(instance_list_t *inst_lists) -{ - // if instance status is not join, finish current judgement, that means last rst recover has finished - if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count == 0 && inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, old_join: 0, new_join: 0"); - dms_reform_judgement_stat_cancel(); - return CM_FALSE; - } - return CM_TRUE; -} - -static bool32 dms_reform_judgement_standby_maintain_check(instance_list_t *inst_lists) -{ - if (DMS_FIRST_REFORM_FINISH) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, first reform has finished"); - return CM_FALSE; - } - - // if instance status is not join, finish current judgement - if (inst_lists[INST_LIST_OLD_JOIN].inst_id_count == 0 && inst_lists[INST_LIST_NEW_JOIN].inst_id_count == 0) { - LOG_DEBUG_INF("[DMS REFORM]dms_reform_judgement, result: No, old_join: 0, new_join: 0"); - return CM_FALSE; - } - - share_info_t *share_info = DMS_SHARE_INFO; - share_info->promote_id = (uint8)g_dms.inst_id; - return CM_TRUE; -} - #ifndef OPENGAUSS static void dms_reform_judgement_refresh_reform_info(void) { diff --git a/src/rc/dms_reform_msg.c b/src/rc/dms_reform_msg.c index b18caa0b0e4bceb97c82245c5a6c6020c6b07820..d60e87820fc454f3b7e56c42951e4d0a4f1df8cc 100644 --- a/src/rc/dms_reform_msg.c +++ b/src/rc/dms_reform_msg.c @@ -34,11 +34,7 @@ #include "dcs_page.h" #include "dms_reform_xa.h" #include "dms_reform_proc_stat.h" - -static dms_proto_version_attr g_req_share_info_version_ctrl[DMS_PROTO_VER_NUMS] = { - [DMS_PROTO_VER_1] = { OFFSET_OF(dms_reform_req_sync_share_info_t, share_info.inst_bitmap), }, - [DMS_PROTO_VER_2] = { sizeof(dms_reform_req_sync_share_info_t) }, -}; +#include "cmpt_msg_reform.h" static int dms_reform_req_common_wait(uint64 ruid) { diff --git a/src/rc/dms_reform_msg.h b/src/rc/dms_reform_msg.h index 47354c901387e30bab6a3139a584fee95e607a82..80221f148b004c13b134d5e2ddb8eb3a9dd83ea5 100644 --- a/src/rc/dms_reform_msg.h +++ b/src/rc/dms_reform_msg.h @@ -29,6 +29,7 @@ #include "mes_interface.h" #include "dms_process.h" #include "drc_lock.h" +#include "cmpt_msg_reform.h" #ifdef __cplusplus extern "C" { @@ -36,30 +37,6 @@ extern "C" { #define DMS_REFORM_MSG_MAX_LENGTH SIZE_K(32) -typedef struct st_dms_reform_ack_common { - dms_message_head_t head; - int result; // proc result - uint8 last_fail; // for ack MSG_REQ_REFORM_PREPARE - union { - uint8 dms_status; // for ack MSG_REQ_DATABASE_STATUS - uint8 has_ddl_2phase; - }; - uint8 lock_mode; - bool8 is_edp; - uint64 lsn; - uint64 start_time; - uint64 bitmap_has_xa; - uint8 db_is_readwrite; -} dms_reform_ack_common_t; - -typedef struct st_dms_reform_req_sync_step { - dms_message_head_t head; - uint64 scn; - uint64 start_time; - uint8 last_step; - uint8 curr_step; - uint8 next_step; -} dms_reform_req_sync_step_t; void dms_reform_init_req_sync_step(dms_reform_req_sync_step_t *req); int dms_reform_req_sync_step_wait(uint64 ruid); void dms_reform_proc_sync_step(dms_process_context_t *process_ctx, dms_message_t *receive_msg); @@ -68,61 +45,28 @@ void dms_reform_init_req_sync_next_step(dms_reform_req_sync_step_t *req, uint8 d int dms_reform_req_sync_next_step_wait(uint64 ruid); void dms_reform_proc_sync_next_step(dms_process_context_t *process_ctx, dms_message_t *receive_msg); -typedef struct st_dms_reform_req_sync_share_info { - dms_message_head_t head; - share_info_t share_info; -} dms_reform_req_sync_share_info_t; int dms_reform_init_req_sync_share_info(dms_reform_req_sync_share_info_t *req, uint8 dst_id); int dms_reform_req_sync_share_info_wait(uint64 ruid); void dms_reform_proc_sync_share_info(dms_process_context_t *process_ctx, dms_message_t *receive_msg); -typedef struct st_dms_reform_req_partner_status { - dms_message_head_t head; - uint64 lsn; - driver_ping_info_t driver_ping_info; -} dms_reform_req_partner_status_t; void dms_reform_init_req_dms_status(dms_reform_req_partner_status_t *req, uint8 dst_id, uint32 sess_id); int dms_reform_req_dms_status_wait(uint8 *online_status, uint64 *online_times, uint8 *online_rw_status, uint8 dst_id, uint64 ruid); void dms_reform_proc_req_dms_status(dms_process_context_t *process_ctx, dms_message_t *receive_msg); -typedef struct st_dms_reform_req_prepare { - dms_message_head_t head; - bool8 last_fail; -} dms_reform_req_prepare_t; void dms_reform_init_req_prepare(dms_reform_req_prepare_t *req, uint8 dst_id); int dms_reform_req_prepare_wait(bool8 *last_fail, int *in_reform, bool8 *has_ddl_2phase, uint64 ruid); void dms_reform_proc_req_prepare(dms_process_context_t *process_ctx, dms_message_t *receive_msg); -typedef struct st_dms_reform_req_gcv_sync { - dms_message_head_t head; - bool8 pushing; -} dms_reform_req_gcv_sync_t; - -typedef struct st_dms_reform_ack_gcv_sync { - dms_message_head_t head; - bool8 updated; -} dms_reform_ack_gcv_sync_t; void dms_reform_init_req_gcv_sync(dms_reform_req_gcv_sync_t *req, uint8 dst_id, bool8 pushing); int dms_reform_req_gcv_sync_wait(bool8 *updated, bool8 pushing, uint64 ruid); void dms_reform_proc_req_gcv_sync(dms_process_context_t *process_ctx, dms_message_t *receive_msg); -typedef struct st_dms_reform_req_migrate { - dms_message_head_t head; - uint32 part_id; - uint32 res_num; - bool8 is_part_end; - uint8 res_type; -} dms_reform_req_migrate_t; int dms_reform_req_migrate_res(migrate_task_t *migrate_task, uint8 type, void *handle, uint32 sess_id); void dms_reform_proc_req_migrate(dms_process_context_t *process_ctx, dms_message_t *receive_msg); void dms_reform_ack_req_migrate(dms_process_context_t *process_ctx, dms_message_t *receive_msg, int result); -typedef struct st_dms_reform_req_rebuild { - dms_message_head_t head; - uint32 offset; -} dms_reform_req_rebuild_t; int dms_reform_req_page_rebuild(msg_command_t cmd, dms_context_t *dms_ctx, dms_ctrl_info_t *ctrl_info, uint8 master_id); int dms_reform_req_page_rebuild_parallel(msg_command_t cmd, dms_context_t *dms_ctx, dms_ctrl_info_t *ctrl_info, @@ -138,17 +82,9 @@ typedef int (*dms_reform_proc_lock_info_rebuild)(void *lock_info, uint8 src_inst void dms_reform_proc_req_lock_rebuild_base(dms_process_context_t *ctx, dms_message_t *receive_msg, uint32 entry_size, dms_reform_proc_lock_info_rebuild proc); -typedef enum dms_reform_req_page_action { - DMS_REQ_FLUSH_COPY, -} page_action_t; - void dms_reform_proc_req_page(dms_process_context_t *process_ctx, dms_message_t *receive_msg); int dms_reform_send_data(dms_message_head_t *msg_head, uint32 sess_id); -typedef struct st_dms_reform_req_switchover { - dms_message_head_t head; - uint64 start_time; -} dms_reform_req_switchover_t; void dms_reform_init_req_switchover(dms_reform_req_switchover_t *req, uint8 reformer_id, uint16 sess_id); int dms_reform_req_switchover_wait(uint64 ruid, uint64 *start_time); void dms_reform_proc_req_switchover(dms_process_context_t *process_ctx, dms_message_t *receive_msg); @@ -156,47 +92,26 @@ void dms_reform_proc_req_switchover(dms_process_context_t *process_ctx, dms_mess void dms_reform_proc_reform_done_req(dms_process_context_t *process_ctx, dms_message_t *receive_msg); int dms_reform_check_reform_done(void); -typedef struct st_dms_reform_ack_map { - dms_message_head_t head; - remaster_info_t remaster_info; -} dms_reform_ack_map_t; void dms_reform_init_map_info_req(dms_message_head_t *head, uint8 dst_id); int dms_reform_map_info_req_wait(uint64 ruid); void dms_reform_proc_map_info_req(dms_process_context_t *process_ctx, dms_message_t *receive_msg); -typedef struct st_dms_reform_req_opengauss_ondemand_redo { - dms_message_head_t head; - uint16 len; -} dms_reform_req_opengauss_ondemand_redo_t; void dms_reform_proc_opengauss_ondemand_redo_buffer(dms_process_context_t *process_ctx, dms_message_t *receive_msg); void dms_reform_ack_req_rebuild(dms_process_context_t *process_ctx, dms_message_t *receive_msg, int result); void dms_reform_set_judge_time(dms_message_head_t *req_head); bool32 dms_reform_check_judge_time(dms_message_head_t *req_head); -typedef struct st_dms_reform_req_group { - dms_message_head_t head; - uint32 offset; -} dms_reform_req_group_t; - void dms_reform_req_group_init(uint8 thread_index); void dms_reform_req_group_free(uint8 thread_index); int dms_reform_req_group(msg_command_t cmd, uint8 dst_id, uint8 thread_index, void *data, uint32 data_len); int dms_reform_req_group_send_rest(uint8 thread_index); -typedef struct st_dms_reform_req_az_switchover { - dms_message_head_t head; - uint64 start_time; -} dms_reform_req_az_switchover_t; void dms_reform_init_req_az_switchover_demote(dms_reform_req_az_switchover_t *req, uint8 reformer_id, uint16 sess_id); int dms_reform_req_az_switchover_wait(uint64 ruid, uint64 *start_time); void dms_reform_proc_req_az_switchover(dms_process_context_t *process_ctx, dms_message_t *receive_msg); -typedef struct st_dms_reform_req_az_failover { - dms_message_head_t head; - uint64 start_time; -} dms_reform_req_az_failover_t; void dms_reform_init_req_az_failover(dms_reform_req_az_failover_t *req, uint8 reformer_id, uint16 sess_id); int dms_reform_req_az_failover_wait(uint64 ruid, uint64 *start_time); diff --git a/src/rc/dms_reform_proc.h b/src/rc/dms_reform_proc.h index 0fcb7afba9282cc7eb4bc055f5eed3327f7a9d54..ef6fe124417f0c3d7aa21133cf043bd7ebc3472f 100644 --- a/src/rc/dms_reform_proc.h +++ b/src/rc/dms_reform_proc.h @@ -64,11 +64,6 @@ int dms_reform_repair(void); void dms_reform_rebuild_add_to_flush_copy(drc_page_t *drc_page); void dms_reform_rebuild_del_from_flush_copy(drc_page_t *drc_page); -typedef struct st_repair_item { - char page_id[DMS_PAGEID_SIZE]; - uint32 action; -} repair_item_t; - #ifdef __cplusplus } #endif