diff --git a/storage/ctc/ctc_ddl_rewriter_plugin.cc b/storage/ctc/ctc_ddl_rewriter_plugin.cc index 5f50cd2df129d7d3157c273ca256af758d3806f8..e211c5af89c9566565d3e8c76afe7f7b62674185 100644 --- a/storage/ctc/ctc_ddl_rewriter_plugin.cc +++ b/storage/ctc/ctc_ddl_rewriter_plugin.cc @@ -458,6 +458,7 @@ static int ctc_set_var_meta(MYSQL_THD thd, list variables_info, ct ctc_log_error("alloc mem failed, set_opt_info size(%lu)", variables_info.size() * sizeof(set_opt_info_t)); return HA_ERR_OUT_OF_MEM; } + memset(set_opt_request->set_opt_info, 0, variables_info.size() * sizeof(set_opt_info_t)); set_opt_info_t *set_opt_info_begin = set_opt_request->set_opt_info; for (auto it = variables_info.begin(); it != variables_info.end(); ++it) { auto var_info = *it; diff --git a/storage/ctc/ctc_meta_data.cc b/storage/ctc/ctc_meta_data.cc index a9082440a4f92b7e0dc5159e8d9122eb27bcc20f..8de0c1f903e65506d8e5cbdac7232753a7141c6e 100644 --- a/storage/ctc/ctc_meta_data.cc +++ b/storage/ctc/ctc_meta_data.cc @@ -773,32 +773,33 @@ int close_ctc_mdl_thd(uint32_t thd_id, uint32_t mysql_inst_id) { return 0; } -static void ctc_get_set_var_item(THD* new_thd, sys_var* sysvar, Item** res MY_ATTRIBUTE((unused)), string& var_value, - bool is_null_value, bool var_is_int) { +static void ctc_get_set_var_item(THD* new_thd, sys_var* sysvar, Item** res MY_ATTRIBUTE((unused)), + const char* var_value, bool is_null_value, bool var_is_int) { + string val_str = string(var_value, strlen(var_value)); switch (sysvar->show_type()) { case SHOW_INT: case SHOW_LONG: case SHOW_LONGLONG: case SHOW_HA_ROWS: - if (var_value.c_str()[0] != '-') { + if (var_value[0] != '-') { *res = new (new_thd->mem_root) - Item_uint(var_value.c_str(), (uint)var_value.length()); + Item_uint(var_value, (uint)strlen(var_value)); break; } case SHOW_SIGNED_INT: case SHOW_SIGNED_LONG: case SHOW_SIGNED_LONGLONG: *res = new (new_thd->mem_root) - Item_int(var_value.c_str(), (uint)var_value.length()); + Item_int(var_value, (uint)strlen(var_value)); break; case SHOW_BOOL: case SHOW_MY_BOOL: - if(var_value == "1" || var_value == "0") { + if(val_str == "1" || val_str == "0") { *res = new (new_thd->mem_root) - Item_int(var_value.c_str(), (uint)var_value.length()); + Item_int(var_value, (uint)strlen(var_value)); } else { *res = new (new_thd->mem_root) - Item_string(var_value.c_str(), var_value.length(), + Item_string(var_value, strlen(var_value), &my_charset_utf8mb4_bin); } break; @@ -806,10 +807,10 @@ static void ctc_get_set_var_item(THD* new_thd, sys_var* sysvar, Item** res MY_AT case SHOW_LEX_STRING: if (var_is_int) { *res = new (new_thd->mem_root) - Item_int(var_value.c_str(), (uint)var_value.length()); + Item_int(var_value, (uint)strlen(var_value)); } else { *res = new (new_thd->mem_root) - Item_string(var_value.c_str(), var_value.length(), + Item_string(var_value, strlen(var_value), &my_charset_utf8mb4_bin); } break; @@ -818,12 +819,12 @@ static void ctc_get_set_var_item(THD* new_thd, sys_var* sysvar, Item** res MY_AT *res = new (new_thd->mem_root) Item_null(); else *res = new (new_thd->mem_root) - Item_string(var_value.c_str(), var_value.length(), + Item_string(var_value, strlen(var_value), &my_charset_utf8mb4_bin); break; case SHOW_DOUBLE: *res = new (new_thd->mem_root) - Item_float(var_value.c_str(), (uint)var_value.length()); + Item_float(var_value, (uint)strlen(var_value)); break; default: my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), sysvar->name.str); @@ -882,7 +883,6 @@ int ctc_get_sys_var(THD *new_thd, ctc_set_opt_request *broadcast_req, set_var *var = nullptr; sys_var *sysvar = nullptr; string var_name = set_opt_info->var_name; - string var_value = set_opt_info->var_value; sysvar = intern_find_sys_var(var_name.c_str(), var_name.length()); if (sysvar == nullptr) { @@ -907,7 +907,7 @@ int ctc_get_sys_var(THD *new_thd, ctc_set_opt_request *broadcast_req, if (set_opt_info->options & CTC_SET_VARIABLE_PERSIST_ONLY) { type = OPT_PERSIST_ONLY; } - ctc_get_set_var_item(new_thd, sysvar, &res, var_value, is_null_value, var_is_int); + ctc_get_set_var_item(new_thd, sysvar, &res, set_opt_info->var_value, is_null_value, var_is_int); if (is_default_value) { if (res) { diff --git a/storage/ctc/ctc_mysql_proxy.cc b/storage/ctc/ctc_mysql_proxy.cc index 17abf97f9664ce2c822cb104bb9094a3baea3881..8ba50be251d888f4e9cadce6ce8de34d8111d3ba 100644 --- a/storage/ctc/ctc_mysql_proxy.cc +++ b/storage/ctc/ctc_mysql_proxy.cc @@ -436,18 +436,20 @@ __attribute__((visibility("default"))) int ctc_ddl_execute_update(uint32_t thd_i return 0; } -__attribute__((visibility("default"))) int ctc_ddl_execute_set_opt(ctc_set_opt_request *broadcast_req, +__attribute__((visibility("default"))) int ctc_ddl_execute_set_opt(uint32_t thd_id, + ctc_set_opt_request *broadcast_req, bool allow_fail) { // 相同节点不用执行 if (broadcast_req->mysql_inst_id == ctc_instance_id) { - ctc_log_note("ctc_ddl_execute_set_opt curnode not need execute, mysql_inst_id:%u", broadcast_req->mysql_inst_id); + ctc_log_note("ctc_ddl_execute_set_opt curnode not need execute, mysql_inst_id:%u, conn_id:%u", + broadcast_req->mysql_inst_id, thd_id); return 0; } int ret = ctc_set_sys_var(broadcast_req); if (ret != 0) { - ctc_log_note("ctc_ddl_execute_set_opt curnode execute fail, cur_mysql_inst_id:%u, allow_fail:%d", - ctc_instance_id, allow_fail); + ctc_log_note("ctc_ddl_execute_set_opt curnode execute fail, cur_mysql_inst_id:%u, conn_id:%u, allow_fail:%d", + ctc_instance_id, thd_id, allow_fail); } return ret; diff --git a/storage/ctc/ctc_srv.h b/storage/ctc/ctc_srv.h index 8df5b5db8cfb9d667b384bf31a9e99018df892ee..352ef375ca0af9e6066e252f5f46820826745083 100644 --- a/storage/ctc/ctc_srv.h +++ b/storage/ctc/ctc_srv.h @@ -631,7 +631,7 @@ int close_mysql_connection(uint32_t thd_id, uint32_t mysql_inst_id); int ctc_ddl_execute_lock_tables(ctc_handler_t *tch, char *db_name, ctc_lock_table_info *lock_info, int *err_code); int ctc_ddl_execute_unlock_tables(ctc_handler_t *tch, uint32_t mysql_inst_id, ctc_lock_table_info *lock_info); EXTER_ATTACK int ctc_ddl_execute_update(uint32_t thd_id, ctc_ddl_broadcast_request *broadcast_req, bool *allow_fail); -EXTER_ATTACK int ctc_ddl_execute_set_opt(ctc_set_opt_request *broadcast_req, bool allow_fail); +EXTER_ATTACK int ctc_ddl_execute_set_opt(uint32_t thd_id, ctc_set_opt_request *broadcast_req, bool allow_fail); EXTER_ATTACK int ctc_execute_mysql_ddl_sql(ctc_handler_t *tch, ctc_ddl_broadcast_request *broadcast_req, bool allow_fail); EXTER_ATTACK int ctc_execute_set_opt(ctc_handler_t *tch, ctc_set_opt_request *broadcast_req, bool allow_fail); int ctc_execute_rewrite_open_conn(uint32_t thd_id, ctc_ddl_broadcast_request *broadcast_req); diff --git a/storage/ctc/ctc_srv_mq_module.cc b/storage/ctc/ctc_srv_mq_module.cc index e7ef4f39cdaceca63c1ba99dbc1c29f9235155db..0fdbaaaddea2f5db08ad1154845d5663f4b06ea0 100644 --- a/storage/ctc/ctc_srv_mq_module.cc +++ b/storage/ctc/ctc_srv_mq_module.cc @@ -74,7 +74,7 @@ static void* mq_msg_handler(void *arg) { case CTC_FUNC_TYPE_MYSQL_EXECUTE_SET_OPT: { execute_mysql_set_opt_request *req = (execute_mysql_set_opt_request *)message_block->seg_buf[0]; - req->result = ctc_ddl_execute_set_opt(&req->broadcast_req, req->allow_fail); + req->result = ctc_ddl_execute_set_opt(req->thd_id, &req->broadcast_req, req->allow_fail); ctc_log_system("[Disaster Recovery] execute_mysql_set_opt : result:%d", req->result); CTC_IGNORE_ERROR_WHEN_MYSQL_SHUTDOWN(req, "ctc_ddl_execute_set_opt"); break; diff --git a/storage/ctc/srv_mq_msg.h b/storage/ctc/srv_mq_msg.h index 7656d99a68b1b9496de39b067eeee09555f8ae55..256f23bb03fab3934b00b7b2fa16292911e11d4c 100644 --- a/storage/ctc/srv_mq_msg.h +++ b/storage/ctc/srv_mq_msg.h @@ -428,6 +428,7 @@ struct execute_mysql_ddl_sql_request { struct execute_mysql_set_opt_request { ctc_set_opt_request broadcast_req; + uint32_t thd_id; int result; bool allow_fail; };