From 5502b80c83ea835c6962f6c5e8e928838a2cfd80 Mon Sep 17 00:00:00 2001 From: zhaozihao Date: Tue, 12 Mar 2024 19:25:02 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A4=87=E9=9B=86=E7=BE=A4=E4=B8=8D?= =?UTF-8?q?=E7=94=A8proxy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- storage/tianchi/ha_tse.h | 1 + storage/tianchi/tse_mysql_proxy.cc | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/storage/tianchi/ha_tse.h b/storage/tianchi/ha_tse.h index 6e2807a..3ea0f5d 100644 --- a/storage/tianchi/ha_tse.h +++ b/storage/tianchi/ha_tse.h @@ -986,6 +986,7 @@ bool is_initialize(); bool is_starting(); bool tse_is_temporary(const dd::Table *table_def); +int32_t tse_get_cluster_role(); #pragma GCC visibility pop #endif diff --git a/storage/tianchi/tse_mysql_proxy.cc b/storage/tianchi/tse_mysql_proxy.cc index f2ac71d..994d798 100644 --- a/storage/tianchi/tse_mysql_proxy.cc +++ b/storage/tianchi/tse_mysql_proxy.cc @@ -28,6 +28,7 @@ #include "tse_log.h" #include "tse_srv.h" #include "tse_util.h" +#include "ha_tse.h" #include "ctc_meta_data.h" #include "tse_proxy_util.h" #include "sql/sql_table.h" @@ -334,6 +335,10 @@ __attribute__((visibility("default"))) int tse_execute_rewrite_open_conn(uint32_ } bool use_proxy = !is_backup_lock_op(broadcast_req->sql_command); + if (tse_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY) { + tse_log_system("[Disaster Recovery] Do not use proxy in slave mysql."); + use_proxy = false; + } uint64_t conn_map_key = tse_get_conn_key(broadcast_req->mysql_inst_id, thd_id, use_proxy); MYSQL *curr_conn = NULL; -- Gitee From 9b78aa9d90ce6449e8856a97462b2a88a675f745 Mon Sep 17 00:00:00 2001 From: zhaozihao Date: Thu, 14 Mar 2024 15:41:14 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=A4=87=E9=9B=86=E7=BE=A4=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E5=85=B3=E9=97=ADreadonly=E7=9A=84=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add log --- storage/tianchi/ctc_meta_data.cc | 3 +- storage/tianchi/ctc_meta_data.h | 2 ++ storage/tianchi/tse_mysql_proxy.cc | 12 ++++++-- storage/tianchi/tse_proxy_util.cc | 45 +++++++++++++++++++++++++++++- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/storage/tianchi/ctc_meta_data.cc b/storage/tianchi/ctc_meta_data.cc index 7b601de..ba32357 100644 --- a/storage/tianchi/ctc_meta_data.cc +++ b/storage/tianchi/ctc_meta_data.cc @@ -32,7 +32,6 @@ #include "my_dir.h" #include "sql/sql_handler.h" #include "sql/sql_base.h" -#include "sql/sql_class.h" #include "sql/dd/cache/dictionary_client.h" #include "sql/mysqld_thd_manager.h" #include "sql/dd/types/procedure.h" @@ -155,7 +154,7 @@ static void release_tse_mdl_thd_by_inst_id(uint32_t mysql_inst_id) { } } -static void ctc_init_thd(THD **thd, uint64_t thd_key) { +void ctc_init_thd(THD **thd, uint64_t thd_key) { lock_guard lock(m_tse_mdl_thd_mutex); if (g_tse_mdl_thd_map.find(thd_key) != g_tse_mdl_thd_map.end()) { (*thd) = g_tse_mdl_thd_map[thd_key]; diff --git a/storage/tianchi/ctc_meta_data.h b/storage/tianchi/ctc_meta_data.h index f4c383e..bff0bfe 100644 --- a/storage/tianchi/ctc_meta_data.h +++ b/storage/tianchi/ctc_meta_data.h @@ -19,6 +19,7 @@ #define __CTC_META_DATA_H__ #include +#include "sql/sql_class.h" #include "tse_srv.h" #pragma GCC visibility push(default) @@ -29,6 +30,7 @@ int close_tse_mdl_thd(uint32_t thd_id, uint32_t mysql_inst_id); int tse_mdl_lock_thd(tianchi_handler_t *tch, tse_lock_table_info *lock_info, int *err_code); void tse_mdl_unlock_thd(tianchi_handler_t *tch, tse_lock_table_info *lock_info); int ctc_set_sys_var(tse_ddl_broadcast_request *broadcast_req); +void ctc_init_thd(THD **thd, uint64_t thd_key); #pragma GCC visibility pop diff --git a/storage/tianchi/tse_mysql_proxy.cc b/storage/tianchi/tse_mysql_proxy.cc index 994d798..4287cc7 100644 --- a/storage/tianchi/tse_mysql_proxy.cc +++ b/storage/tianchi/tse_mysql_proxy.cc @@ -327,6 +327,12 @@ static inline bool is_backup_lock_op(uint8_t sql_command) { sql_command == SQLCOM_UNLOCK_INSTANCE; } +static inline bool tse_use_proxy(uint8_t sql_command) { + bool is_slave = tse_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY; + tse_log_system("[zzh debug] use_proxy:%d", (is_slave || !is_backup_lock_op(sql_command))); + return is_slave || !is_backup_lock_op(sql_command); +} + extern uint32_t tse_instance_id; __attribute__((visibility("default"))) int tse_execute_rewrite_open_conn(uint32_t thd_id, tse_ddl_broadcast_request *broadcast_req) { // 相同节点不用执行 @@ -334,7 +340,8 @@ __attribute__((visibility("default"))) int tse_execute_rewrite_open_conn(uint32_ return 0; } - bool use_proxy = !is_backup_lock_op(broadcast_req->sql_command); + // bool use_proxy = !is_backup_lock_op(broadcast_req->sql_command); + bool use_proxy = tse_use_proxy(broadcast_req->sql_command); if (tse_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY) { tse_log_system("[Disaster Recovery] Do not use proxy in slave mysql."); use_proxy = false; @@ -375,7 +382,8 @@ __attribute__((visibility("default"))) int tse_ddl_execute_update(uint32_t thd_i return 0; } - bool use_proxy = !is_backup_lock_op(broadcast_req->sql_command); + // bool use_proxy = !is_backup_lock_op(broadcast_req->sql_command); + bool use_proxy = tse_use_proxy(broadcast_req->sql_command); uint64_t conn_map_key = tse_get_conn_key(broadcast_req->mysql_inst_id, thd_id, use_proxy); MYSQL *curr_conn = NULL; diff --git a/storage/tianchi/tse_proxy_util.cc b/storage/tianchi/tse_proxy_util.cc index e3b3214..15ef81e 100644 --- a/storage/tianchi/tse_proxy_util.cc +++ b/storage/tianchi/tse_proxy_util.cc @@ -21,6 +21,11 @@ #include "sql/sql_connect.h" #include "sql/conn_handler/connection_handler_manager.h" // Connection_handler_manager #include "compression.h" +#include "ha_tse.h" +#include "sql/sql_class.h" +#include "ctc_meta_data.h" +// static map g_tse_proxy_thd_map; +// static mutex m_tse_mdl_thd_mutex; #define TSE_CONN_MAX_RETRY_TIMES 10 #define TSE_PASSWORD_BUFFER_SIZE (uint32)512 @@ -195,6 +200,24 @@ int tse_init_agent_client(MYSQL *&curr_conn) { return 0; } +// static void tse_proxy_init_thd(THD **thd, uint64_t thd_key) { +// lock_guard lock(m_tse_mdl_thd_mutex); +// if (g_tse_proxy_thd_map.find(thd_key) != g_tse_proxy_thd_map.end()) { +// (*thd) = g_tse_proxy_thd_map[thd_key]; +// my_thread_init(); +// (*thd)->store_globals(); +// } else { +// THD* new_thd = new (std::nothrow) THD; +// my_thread_init(); +// new_thd->set_new_thread_id(); +// new_thd->thread_stack = (char *)&new_thd; +// new_thd->store_globals(); +// new_thd->set_query("tse_mdl_thd_notify", 18); +// g_tse_proxy_thd_map[thd_key] = new_thd; +// (*thd) = new_thd; +// } +// } + int tse_mysql_query(MYSQL *mysql, const char *query) { reset_mqh(nullptr, nullptr, 0); @@ -210,9 +233,29 @@ int tse_mysql_query(MYSQL *mysql, const char *query) { CR_SERVER_LOST: 2013 CR_UNKNOWN_ERROR: 2000 */ + + THD *thd = nullptr; + uint64_t thd_key = tse_get_conn_key((uint32)0xFFFFFFFF - 1, (uint32)0xFFFFFFFF - 1, true); + ctc_init_thd(&thd, thd_key); + // tse_proxy_init_thd(&thd, thd_key); + // my_thread_init(); + // thd->set_new_thread_id(); + // thd->thread_stack = (char *)&thd; + // thd->store_globals(); + // thd->set_query("tse_mdl_thd_notify", 18); + + + if (tse_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY) { + thd->set_skip_readonly_check(); + // ((THD *)mysql->thd)->set_skip_readonly_check(); + } ret = mysql_query(mysql, query); + if (tse_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY) { + thd->reset_skip_readonly_check(); + // ((THD *)mysql->thd)->reset_skip_readonly_check(); + } if (ret != 0) { - tse_log_error("[TSE_MYSQL_QUERY]:ret:%d, err_code=%d, err_msg=%s.", ret, mysql_errno(mysql), mysql_error(mysql)); + tse_log_error("[TSE_MYSQL_QUERY]:ret:%d, err_code=%d, err_msg=%s, query_str:%s.", ret, mysql_errno(mysql), mysql_error(mysql), query); } return ret; // success: 0, fail: other -- Gitee From bc998c09e441a7750049cb92e5f1c1882b552863 Mon Sep 17 00:00:00 2001 From: zhaozihao Date: Fri, 15 Mar 2024 11:25:14 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9useproxy=E7=9A=84?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- storage/tianchi/ctc_meta_data.cc | 3 +- storage/tianchi/ctc_meta_data.h | 2 - storage/tianchi/ha_tse.cc | 72 +++++++++++++++++------------- storage/tianchi/ha_tse.h | 2 + storage/tianchi/tse_mysql_proxy.cc | 10 +---- storage/tianchi/tse_proxy_util.cc | 39 ++-------------- 6 files changed, 49 insertions(+), 79 deletions(-) diff --git a/storage/tianchi/ctc_meta_data.cc b/storage/tianchi/ctc_meta_data.cc index ba32357..7b601de 100644 --- a/storage/tianchi/ctc_meta_data.cc +++ b/storage/tianchi/ctc_meta_data.cc @@ -32,6 +32,7 @@ #include "my_dir.h" #include "sql/sql_handler.h" #include "sql/sql_base.h" +#include "sql/sql_class.h" #include "sql/dd/cache/dictionary_client.h" #include "sql/mysqld_thd_manager.h" #include "sql/dd/types/procedure.h" @@ -154,7 +155,7 @@ static void release_tse_mdl_thd_by_inst_id(uint32_t mysql_inst_id) { } } -void ctc_init_thd(THD **thd, uint64_t thd_key) { +static void ctc_init_thd(THD **thd, uint64_t thd_key) { lock_guard lock(m_tse_mdl_thd_mutex); if (g_tse_mdl_thd_map.find(thd_key) != g_tse_mdl_thd_map.end()) { (*thd) = g_tse_mdl_thd_map[thd_key]; diff --git a/storage/tianchi/ctc_meta_data.h b/storage/tianchi/ctc_meta_data.h index bff0bfe..f4c383e 100644 --- a/storage/tianchi/ctc_meta_data.h +++ b/storage/tianchi/ctc_meta_data.h @@ -19,7 +19,6 @@ #define __CTC_META_DATA_H__ #include -#include "sql/sql_class.h" #include "tse_srv.h" #pragma GCC visibility push(default) @@ -30,7 +29,6 @@ int close_tse_mdl_thd(uint32_t thd_id, uint32_t mysql_inst_id); int tse_mdl_lock_thd(tianchi_handler_t *tch, tse_lock_table_info *lock_info, int *err_code); void tse_mdl_unlock_thd(tianchi_handler_t *tch, tse_lock_table_info *lock_info); int ctc_set_sys_var(tse_ddl_broadcast_request *broadcast_req); -void ctc_init_thd(THD **thd, uint64_t thd_key); #pragma GCC visibility pop diff --git a/storage/tianchi/ha_tse.cc b/storage/tianchi/ha_tse.cc index eb3bd56..d5df377 100644 --- a/storage/tianchi/ha_tse.cc +++ b/storage/tianchi/ha_tse.cc @@ -4280,44 +4280,52 @@ static bool ctc_show_status(handlerton *, THD *thd, stat_print_fn *stat_print, e return false; } +void tse_set_mysql_read_only() { + if(is_starting() || is_initialize()) { + tse_log_system("[Disaster Recovecy] starting or initializing"); + super_read_only = true; + read_only = true; + opt_readonly = true; + tse_log_system("[Disaster Recovery] set super_read_only = true."); + } else { + tse_ddl_broadcast_request local_req {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; + memcpy(local_req.user_name, "super_read_only", strlen("super_read_only")); + memcpy(local_req.user_ip, "on", strlen("on")); + ctc_set_sys_var(&local_req); + tse_log_system("[Disaster Recovery] ctc_set_sys_var: super_read_only: %s", local_req.user_ip); + } +} + +void tse_reset_mysql_read_only() { + if(is_starting() || is_initialize()) { + tse_log_system("[Disaster Recovecy] starting or initializing"); + super_read_only = false; + read_only = false; + opt_readonly = false; + tse_log_system("[Disaster Recovery] set super_read_only = false."); + } else { + tse_ddl_broadcast_request local_req_sro {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; + memcpy(local_req_sro.user_name, "super_read_only", strlen("super_read_only")); + memcpy(local_req_sro.user_ip, "off", strlen("off")); + ctc_set_sys_var(&local_req_sro); + tse_log_system("[Disaster Recovery] ctc_set_sys_var: super_read_only: %s", local_req_sro.user_ip); + + tse_ddl_broadcast_request local_req_ro {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; + memcpy(local_req_ro.user_name, "read_only", strlen("read_only")); + memcpy(local_req_ro.user_ip, "off", strlen("off")); + ctc_set_sys_var(&local_req_ro); + tse_log_system("[Disaster Recovery] ctc_set_sys_var: super_read_only: %s", local_req_ro.user_ip); + } +} + int tse_set_cluster_role_by_cantian(bool is_slave) { // todo: add mutex for cluster_role if (is_slave) { cluster_role = (int32_t)dis_cluster_role::STANDBY; - if(is_starting() || is_initialize()) { - tse_log_system("[Disaster Recovecy] starting or initializing"); - super_read_only = true; - read_only = true; - opt_readonly = true; - tse_log_system("[Disaster Recovery] set super_read_only = true."); - } else { - tse_ddl_broadcast_request local_req {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; - memcpy(local_req.user_name, "super_read_only", strlen("super_read_only")); - memcpy(local_req.user_ip, "on", strlen("on")); - ctc_set_sys_var(&local_req); - tse_log_system("[Disaster Recovery] ctc_set_sys_var: local_req->user_ip: %s", local_req.user_ip); - } + tse_set_mysql_read_only(); } else { cluster_role = (int32_t)dis_cluster_role::PRIMARY; - if(is_starting() || is_initialize()) { - tse_log_system("[Disaster Recovecy] starting or initializing"); - super_read_only = false; - read_only = false; - opt_readonly = false; - tse_log_system("[Disaster Recovery] set super_read_only = false."); - } else { - tse_ddl_broadcast_request local_req_sro {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; - memcpy(local_req_sro.user_name, "super_read_only", strlen("super_read_only")); - memcpy(local_req_sro.user_ip, "off", strlen("off")); - ctc_set_sys_var(&local_req_sro); - tse_log_system("[Disaster Recovery] ctc_set_sys_var: local_req->user_ip: %s", local_req_sro.user_ip); - - tse_ddl_broadcast_request local_req_ro {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; - memcpy(local_req_ro.user_name, "read_only", strlen("read_only")); - memcpy(local_req_ro.user_ip, "off", strlen("off")); - ctc_set_sys_var(&local_req_ro); - tse_log_system("[Disaster Recovery] ctc_set_sys_var: local_req->user_ip: %s", local_req_ro.user_ip); - } + tse_reset_mysql_read_only(); } return 0; } diff --git a/storage/tianchi/ha_tse.h b/storage/tianchi/ha_tse.h index 3ea0f5d..8f4d8b9 100644 --- a/storage/tianchi/ha_tse.h +++ b/storage/tianchi/ha_tse.h @@ -987,6 +987,8 @@ bool is_starting(); bool tse_is_temporary(const dd::Table *table_def); int32_t tse_get_cluster_role(); +void tse_set_mysql_read_only(); +void tse_reset_mysql_read_only(); #pragma GCC visibility pop #endif diff --git a/storage/tianchi/tse_mysql_proxy.cc b/storage/tianchi/tse_mysql_proxy.cc index 4287cc7..178f674 100644 --- a/storage/tianchi/tse_mysql_proxy.cc +++ b/storage/tianchi/tse_mysql_proxy.cc @@ -329,8 +329,8 @@ static inline bool is_backup_lock_op(uint8_t sql_command) { static inline bool tse_use_proxy(uint8_t sql_command) { bool is_slave = tse_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY; - tse_log_system("[zzh debug] use_proxy:%d", (is_slave || !is_backup_lock_op(sql_command))); - return is_slave || !is_backup_lock_op(sql_command); + tse_log_system("[Disaster Recovery] is_slave: %d, sql_command=%d, use_proxy:%d", is_slave, sql_command, (!is_slave && !is_backup_lock_op(sql_command))); + return !is_slave && !is_backup_lock_op(sql_command); } extern uint32_t tse_instance_id; @@ -340,12 +340,7 @@ __attribute__((visibility("default"))) int tse_execute_rewrite_open_conn(uint32_ return 0; } - // bool use_proxy = !is_backup_lock_op(broadcast_req->sql_command); bool use_proxy = tse_use_proxy(broadcast_req->sql_command); - if (tse_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY) { - tse_log_system("[Disaster Recovery] Do not use proxy in slave mysql."); - use_proxy = false; - } uint64_t conn_map_key = tse_get_conn_key(broadcast_req->mysql_inst_id, thd_id, use_proxy); MYSQL *curr_conn = NULL; @@ -382,7 +377,6 @@ __attribute__((visibility("default"))) int tse_ddl_execute_update(uint32_t thd_i return 0; } - // bool use_proxy = !is_backup_lock_op(broadcast_req->sql_command); bool use_proxy = tse_use_proxy(broadcast_req->sql_command); uint64_t conn_map_key = tse_get_conn_key(broadcast_req->mysql_inst_id, thd_id, use_proxy); diff --git a/storage/tianchi/tse_proxy_util.cc b/storage/tianchi/tse_proxy_util.cc index 15ef81e..81fffae 100644 --- a/storage/tianchi/tse_proxy_util.cc +++ b/storage/tianchi/tse_proxy_util.cc @@ -22,10 +22,8 @@ #include "sql/conn_handler/connection_handler_manager.h" // Connection_handler_manager #include "compression.h" #include "ha_tse.h" -#include "sql/sql_class.h" +#include "sql/mysqld.h" #include "ctc_meta_data.h" -// static map g_tse_proxy_thd_map; -// static mutex m_tse_mdl_thd_mutex; #define TSE_CONN_MAX_RETRY_TIMES 10 #define TSE_PASSWORD_BUFFER_SIZE (uint32)512 @@ -200,24 +198,6 @@ int tse_init_agent_client(MYSQL *&curr_conn) { return 0; } -// static void tse_proxy_init_thd(THD **thd, uint64_t thd_key) { -// lock_guard lock(m_tse_mdl_thd_mutex); -// if (g_tse_proxy_thd_map.find(thd_key) != g_tse_proxy_thd_map.end()) { -// (*thd) = g_tse_proxy_thd_map[thd_key]; -// my_thread_init(); -// (*thd)->store_globals(); -// } else { -// THD* new_thd = new (std::nothrow) THD; -// my_thread_init(); -// new_thd->set_new_thread_id(); -// new_thd->thread_stack = (char *)&new_thd; -// new_thd->store_globals(); -// new_thd->set_query("tse_mdl_thd_notify", 18); -// g_tse_proxy_thd_map[thd_key] = new_thd; -// (*thd) = new_thd; -// } -// } - int tse_mysql_query(MYSQL *mysql, const char *query) { reset_mqh(nullptr, nullptr, 0); @@ -234,25 +214,12 @@ int tse_mysql_query(MYSQL *mysql, const char *query) { CR_UNKNOWN_ERROR: 2000 */ - THD *thd = nullptr; - uint64_t thd_key = tse_get_conn_key((uint32)0xFFFFFFFF - 1, (uint32)0xFFFFFFFF - 1, true); - ctc_init_thd(&thd, thd_key); - // tse_proxy_init_thd(&thd, thd_key); - // my_thread_init(); - // thd->set_new_thread_id(); - // thd->thread_stack = (char *)&thd; - // thd->store_globals(); - // thd->set_query("tse_mdl_thd_notify", 18); - - if (tse_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY) { - thd->set_skip_readonly_check(); - // ((THD *)mysql->thd)->set_skip_readonly_check(); + tse_reset_mysql_read_only(); } ret = mysql_query(mysql, query); if (tse_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY) { - thd->reset_skip_readonly_check(); - // ((THD *)mysql->thd)->reset_skip_readonly_check(); + tse_set_mysql_read_only(); } if (ret != 0) { tse_log_error("[TSE_MYSQL_QUERY]:ret:%d, err_code=%d, err_msg=%s, query_str:%s.", ret, mysql_errno(mysql), mysql_error(mysql), query); -- Gitee From 73d2b3cf2ee00ded935f257d432be4043b4e4857 Mon Sep 17 00:00:00 2001 From: zhaozihao Date: Wed, 20 Mar 2024 09:40:55 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E7=BD=AEread=5F?= =?UTF-8?q?only=E7=9A=84=E6=96=B9=E6=B3=95=EF=BC=8Cfor=20liangke?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- storage/tianchi/ha_tse.cc | 42 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/storage/tianchi/ha_tse.cc b/storage/tianchi/ha_tse.cc index d5df377..2ed9ca3 100644 --- a/storage/tianchi/ha_tse.cc +++ b/storage/tianchi/ha_tse.cc @@ -4281,41 +4281,19 @@ static bool ctc_show_status(handlerton *, THD *thd, stat_print_fn *stat_print, e } void tse_set_mysql_read_only() { - if(is_starting() || is_initialize()) { - tse_log_system("[Disaster Recovecy] starting or initializing"); - super_read_only = true; - read_only = true; - opt_readonly = true; - tse_log_system("[Disaster Recovery] set super_read_only = true."); - } else { - tse_ddl_broadcast_request local_req {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; - memcpy(local_req.user_name, "super_read_only", strlen("super_read_only")); - memcpy(local_req.user_ip, "on", strlen("on")); - ctc_set_sys_var(&local_req); - tse_log_system("[Disaster Recovery] ctc_set_sys_var: super_read_only: %s", local_req.user_ip); - } + tse_log_system("[Disaster Recovecy] starting or initializing"); + super_read_only = true; + read_only = true; + opt_readonly = true; + tse_log_system("[Disaster Recovery] set super_read_only = true."); } void tse_reset_mysql_read_only() { - if(is_starting() || is_initialize()) { - tse_log_system("[Disaster Recovecy] starting or initializing"); - super_read_only = false; - read_only = false; - opt_readonly = false; - tse_log_system("[Disaster Recovery] set super_read_only = false."); - } else { - tse_ddl_broadcast_request local_req_sro {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; - memcpy(local_req_sro.user_name, "super_read_only", strlen("super_read_only")); - memcpy(local_req_sro.user_ip, "off", strlen("off")); - ctc_set_sys_var(&local_req_sro); - tse_log_system("[Disaster Recovery] ctc_set_sys_var: super_read_only: %s", local_req_sro.user_ip); - - tse_ddl_broadcast_request local_req_ro {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; - memcpy(local_req_ro.user_name, "read_only", strlen("read_only")); - memcpy(local_req_ro.user_ip, "off", strlen("off")); - ctc_set_sys_var(&local_req_ro); - tse_log_system("[Disaster Recovery] ctc_set_sys_var: super_read_only: %s", local_req_ro.user_ip); - } + tse_log_system("[Disaster Recovecy] starting or initializing"); + super_read_only = false; + read_only = false; + opt_readonly = false; + tse_log_system("[Disaster Recovery] set super_read_only = false."); } int tse_set_cluster_role_by_cantian(bool is_slave) { -- Gitee