diff --git a/storage/ctc/CMakeLists.txt b/storage/ctc/CMakeLists.txt index 7e3266fc979e58debc02e4617d61157f08fbf926..90289c4afc2588f5b88ddd95fb53a19e164135c8 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 22783cf927c5557fd4423c755a82a3bddb9ef6e6..6fdbfd9833e97a1f51525de01aa416e7a053ab5c 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 5ba8b194d0aca46d5f0e07273465c3e775555020..56ebae78dd3f682d956032d76c24a96c0883a1f4 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 8ba50be251d888f4e9cadce6ce8de34d8111d3ba..92a568a66178dcc3c92625dc309ba44f9c8d1d8e 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 3e4f75a72957e25f9968bb33b2192572c773f422..2ec5bcba8cde799d8aedcf151d7d5fa0f027c7dd 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 2cfe5d60419a18aad4d2546f04233f77e8579770..90a87e810eac05dd08e1b0b5e25b0499a79ecd82 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;