From 814a87530268a05e46f49a1e4f02311dbb1d70c0 Mon Sep 17 00:00:00 2001 From: qiuyang19960521 Date: Thu, 28 Nov 2024 11:36:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(compile):=20=E7=8B=AC=E7=AB=8B=E5=87=BA?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- storage/ctc/CMakeLists.txt | 8 ++++---- storage/ctc/ctc_meta_data.cc | 5 ++++- storage/ctc/ctc_meta_data.h | 3 +++ storage/ctc/ctc_mysql_proxy.cc | 16 +++++++++++++--- storage/ctc/ctc_srv.h | 9 ++++++++- storage/ctc/ha_ctc.cc | 8 +++++++- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/storage/ctc/CMakeLists.txt b/storage/ctc/CMakeLists.txt index 7e3266f..90289c4 100644 --- a/storage/ctc/CMakeLists.txt +++ b/storage/ctc/CMakeLists.txt @@ -68,14 +68,14 @@ IF (WITH_CANTIAN) ${CTC_SOURCES} STORAGE_ENGINE MANDATORY - LINK_LIBRARIES libzecommon.so libzeclient.so libzeprotocol.so libprotobuf-c.a pcre2-8 ctc_proxy cantian + LINK_LIBRARIES libzecommon.so libzeclient.so libzeprotocol.so libprotobuf-c.a pcre2-8 ctc_proxy libcantian.so libmessage_queue.so ) ELSEIF (NOT WITHOUT_CTC_STORAGE_ENGINE) MYSQL_ADD_PLUGIN(ctc ${CTC_SOURCES} STORAGE_ENGINE MODULE_ONLY - LINK_LIBRARIES libzecommon.so libzeclient.so libzeprotocol.so libprotobuf-c.a pcre2-8 ctc_proxy cantian + LINK_LIBRARIES libzecommon.so libzeclient.so libzeprotocol.so libprotobuf-c.a pcre2-8 ctc_proxy libcantian.so libmessage_queue.so ) ENDIF () ELSE () @@ -84,14 +84,14 @@ ELSE () ${CTC_SOURCES} STORAGE_ENGINE DEFAULT - LINK_LIBRARIES message_queue libprotobuf-c.a libsecurec.so ctc_proxy + LINK_LIBRARIES libmessage_queue.so libprotobuf-c.a libsecurec.so ctc_proxy ) ELSEIF (NOT WITHOUT_CTC_STORAGE_ENGINE) MYSQL_ADD_PLUGIN(ctc ${CTC_SOURCES} STORAGE_ENGINE MODULE_ONLY - LINK_LIBRARIES message_queue libprotobuf-c.a libsecurec.so ctc_proxy + LINK_LIBRARIES libmessage_queue.so libprotobuf-c.a libsecurec.so ctc_proxy ) ENDIF () ENDIF () diff --git a/storage/ctc/ctc_meta_data.cc b/storage/ctc/ctc_meta_data.cc index 22783cf..6fdbfd9 100644 --- a/storage/ctc/ctc_meta_data.cc +++ b/storage/ctc/ctc_meta_data.cc @@ -552,7 +552,10 @@ static typename std::enable_if::typ return 0; } -int ctc_invalidate_mysql_dd_cache(ctc_handler_t *tch, ctc_invalidate_broadcast_request *broadcast_req, int *err_code) { +int ctc_invalidate_mysql_dd_cache_req(ctc_handler_t *tch, + ctc_invalidate_broadcast_request *broadcast_req, + int *err_code) +{ return (int)ctc_invalidate_mysql_dd_cache_impl(tch, broadcast_req, err_code); } diff --git a/storage/ctc/ctc_meta_data.h b/storage/ctc/ctc_meta_data.h index 5ba8b19..56ebae7 100644 --- a/storage/ctc/ctc_meta_data.h +++ b/storage/ctc/ctc_meta_data.h @@ -31,6 +31,9 @@ void ctc_mdl_unlock_thd(ctc_handler_t *tch, ctc_lock_table_info *lock_info); int ctc_set_sys_var(ctc_set_opt_request *broadcast_req); int ctc_ddl_execute_lock_tables_by_req(ctc_handler_t *tch, ctc_lock_table_info *lock_info, int *err_code); void ctc_mdl_unlock_tables_thd(ctc_handler_t *tch); +int ctc_invalidate_mysql_dd_cache_req(ctc_handler_t *tch, + ctc_invalidate_broadcast_request *broadcast_req, + int *err_code); #pragma GCC visibility pop diff --git a/storage/ctc/ctc_mysql_proxy.cc b/storage/ctc/ctc_mysql_proxy.cc index 8ba50be..92a568a 100644 --- a/storage/ctc/ctc_mysql_proxy.cc +++ b/storage/ctc/ctc_mysql_proxy.cc @@ -521,8 +521,11 @@ int32_t ctc_check_table_exist(MYSQL *curr_conn_proxy, const char *db_name, const return res; } -__attribute__((visibility("default"))) int ctc_ddl_execute_lock_tables(ctc_handler_t *tch, char *db_name, ctc_lock_table_info *lock_info, int *err_code) { - +__attribute__((visibility("default"))) int ctc_ddl_execute_lock_tables(ctc_handler_t *tch, + char *db_name, + ctc_lock_table_info *lock_info, + int *err_code) +{ if (IS_METADATA_NORMALIZATION()) { if (lock_info->sql_type == SQLCOM_LOCK_TABLES) { if (ctc_ddl_execute_lock_tables_by_req(tch, lock_info, err_code)) { @@ -616,7 +619,7 @@ __attribute__((visibility("default"))) int ctc_ddl_execute_lock_tables(ctc_handl } __attribute__((visibility("default"))) int ctc_ddl_execute_unlock_tables(ctc_handler_t *tch, uint32_t mysql_inst_id, ctc_lock_table_info *lock_info) - { +{ if (IS_METADATA_NORMALIZATION()) { UNUSED_PARAM(mysql_inst_id); if (lock_info->sql_type == SQLCOM_UNLOCK_TABLES) { @@ -717,4 +720,11 @@ __attribute__((visibility("default"))) int close_mysql_connection(uint32_t thd_i close_mysql_conn_by_key(agent_conn_map_key); } return 0; +} + +__attribute__((visibility("default"))) int ctc_invalidate_mysql_dd_cache(ctc_handler_t *tch, + ctc_invalidate_broadcast_request *broadcast_req, + int *err_code) +{ + return ctc_invalidate_mysql_dd_cache_req(tch, broadcast_req, err_code); } \ No newline at end of file diff --git a/storage/ctc/ctc_srv.h b/storage/ctc/ctc_srv.h index 3e4f75a..2ec5bcb 100644 --- a/storage/ctc/ctc_srv.h +++ b/storage/ctc/ctc_srv.h @@ -233,6 +233,10 @@ typedef struct { int err_code; } ctc_invalidate_broadcast_request; +typedef struct { + int result; +} mysql_init_lib_request; + typedef struct { bool is_key_null; // 该列数据是否为null uint8_t *left_key; // 指向索引查询条件的左值 @@ -342,6 +346,7 @@ enum CTC_FUNC_TYPE { CTC_FUNC_TYPE_GET_MAX_SESSIONS, CTC_FUNC_LOCK_INSTANCE, CTC_FUNC_UNLOCK_INSTANCE, + CTC_FUNC_INIT_MYSQL_LIB, CTC_FUNC_CHECK_TABLE_EXIST, CTC_FUNC_SEARCH_METADATA_SWITCH, CTC_FUNC_QUERY_SHM_USAGE, @@ -589,6 +594,9 @@ typedef struct en_ctcpart_scan_range { int srv_wait_instance_startuped(void); int ctc_alloc_inst_id(uint32_t *inst_id); int ctc_release_inst_id(uint32_t inst_id); +#ifdef WITH_CANTIAN +int init_mysql_lib(void); +#endif int ctc_open_table(ctc_handler_t *tch, const char *table_name, const char *user_name); int ctc_close_table(ctc_handler_t *tch); @@ -690,7 +698,6 @@ int ctc_broadcast_rewrite_sql(ctc_handler_t *tch, ctc_ddl_broadcast_request *bro /* Metadata Related Interface */ int ctc_check_db_table_exists(const char *db, const char *name, bool *is_exists); int ctc_search_metadata_status(bool *cantian_metadata_switch, bool *cantian_cluster_ready); - int ctc_invalidate_mysql_dd_cache(ctc_handler_t *tch, ctc_invalidate_broadcast_request *broadcast_req, int *err_code); int ctc_broadcast_mysql_dd_invalidate(ctc_handler_t *tch, ctc_invalidate_broadcast_request *broadcast_req); diff --git a/storage/ctc/ha_ctc.cc b/storage/ctc/ha_ctc.cc index 2cfe5d6..90a87e8 100644 --- a/storage/ctc/ha_ctc.cc +++ b/storage/ctc/ha_ctc.cc @@ -482,6 +482,12 @@ static int ctc_reg_instance() { CTC_START_TIMEOUT); sleep(1); } +#ifdef WITH_CANTIAN + ret = (ct_errno_t)init_mysql_lib(); + if (ret == CT_SUCCESS) { + ctc_log_system("[CTC_INIT]:ctc reg mysql proxy lib in cantian success"); + } +#endif return convert_ctc_error_code_to_mysql(ret); } @@ -4611,7 +4617,7 @@ void ctc_reset_mysql_read_only() { ctc_log_system("[Disaster Recovery] set super_read_only = false."); } -int ctc_set_cluster_role_by_cantian(bool is_slave) { +__attribute__((visibility("default"))) int ctc_set_cluster_role_by_cantian(bool is_slave) { lock_guard lock(m_ctc_cluster_role_mutex); if (is_slave) { ctc_cluster_role = (int32_t)dis_cluster_role::STANDBY; -- Gitee