diff --git a/mysql-test/suite/tianchi/r/ctc_index_functions_base.result b/mysql-test/suite/tianchi/r/ctc_index_functions_base.result index 06ee1ec11dceedbfa49982d73922b7446cf2cb60..7b51854399f6766b0599e05389d294be0e94811b 100644 --- a/mysql-test/suite/tianchi/r/ctc_index_functions_base.result +++ b/mysql-test/suite/tianchi/r/ctc_index_functions_base.result @@ -456,6 +456,3 @@ e NULL 5 drop table if exists DEMO; -show variables like '%ctc_prefetch_buf_size%'; -Variable_name Value -ctc_prefetch_buf_size 196608 diff --git a/mysql-test/suite/tianchi/t/ctc_index_functions_base.test b/mysql-test/suite/tianchi/t/ctc_index_functions_base.test index 65d637868172aea3a781b5ef34c209b00fcd4f98..59b77df5ed87482eb23f0a1e8ef7b1bac6a4d9a5 100644 --- a/mysql-test/suite/tianchi/t/ctc_index_functions_base.test +++ b/mysql-test/suite/tianchi/t/ctc_index_functions_base.test @@ -135,6 +135,3 @@ Select d from DEMO where f = 6; Select e from DEMO where d = 4 and f = 6; drop table if exists DEMO; - -# show prefetch buffer size -show variables like '%ctc_prefetch_buf_size%'; diff --git a/storage/tianchi/ctc_meta_data.cc b/storage/tianchi/ctc_meta_data.cc index ecebd63da500a11e1abb50090ca5b5932528719e..1c5d3755727b02aee5829d8074d11e5fa5e47f79 100644 --- a/storage/tianchi/ctc_meta_data.cc +++ b/storage/tianchi/ctc_meta_data.cc @@ -59,7 +59,7 @@ using namespace std; -extern uint32_t tse_instance_id; +extern uint32_t ctc_instance_id; static map g_tse_mdl_thd_map; static mutex m_tse_mdl_thd_mutex; static map *> g_tse_mdl_ticket_maps; @@ -390,7 +390,7 @@ static typename std::enable_if::type tse_invalidate_mysql_dd_cache_impl(tianchi_handler_t *tch, tse_invalidate_broadcast_request *broadcast_req, int *err_code) { UNUSED_PARAM(err_code); // 相同节点不用执行 - if(broadcast_req->mysql_inst_id == tse_instance_id) { + if(broadcast_req->mysql_inst_id == ctc_instance_id) { tse_log_note("tse_invalidate_mysql_dd_cache curnode not need execute,mysql_inst_id:%u", broadcast_req->mysql_inst_id); return 0; } @@ -512,7 +512,7 @@ static void tse_init_mdl_request(tse_lock_table_info *lock_info, MDL_request *md } int tse_mdl_lock_thd(tianchi_handler_t *tch, tse_lock_table_info *lock_info, int *err_code) { - bool is_same_node = (tch->inst_id == tse_instance_id); + bool is_same_node = (tch->inst_id == ctc_instance_id); uint64_t mdl_thd_key = tse_get_conn_key(tch->inst_id, tch->thd_id, true); if (is_same_node) { @@ -582,7 +582,7 @@ void ctc_mdl_unlock_thd_by_ticket(THD* thd, MDL_request *tse_release_request) { } void tse_mdl_unlock_tables_thd(tianchi_handler_t *tch) { - bool is_same_node = (tch->inst_id == tse_instance_id); + bool is_same_node = (tch->inst_id == ctc_instance_id); uint64_t mdl_thd_key = tse_get_conn_key(tch->inst_id, tch->thd_id, true); if (is_same_node) { @@ -633,7 +633,7 @@ void tse_mdl_unlock_tables_thd(tianchi_handler_t *tch) { } void tse_mdl_unlock_thd(tianchi_handler_t *tch, tse_lock_table_info *lock_info) { - bool is_same_node = (tch->inst_id == tse_instance_id); + bool is_same_node = (tch->inst_id == ctc_instance_id); uint64_t mdl_thd_key = tse_get_conn_key(tch->inst_id, tch->thd_id, true); if (is_same_node) { @@ -667,13 +667,13 @@ int close_tse_mdl_thd(uint32_t thd_id, uint32_t mysql_inst_id) { release_tse_mdl_thd_by_cantian_id((uint16_t)(mysql_inst_id >> 16)); } else { /* 清理整个mysqld节点相关的THD */ - tse_log_system("[TSE_MDL_THD]:Close All MDL THD by tse_instance_id:%u", mysql_inst_id); + tse_log_system("[TSE_MDL_THD]:Close All MDL THD by ctc_instance_id:%u", mysql_inst_id); release_tse_mdl_thd_by_inst_id(mysql_inst_id); } } else { /* 通过把mysql_inst_id左移32位 与 thd_id拼接在一起 用来唯一标识一个THD */ uint64_t mdl_thd_key = tse_get_conn_key(mysql_inst_id, thd_id, true); - tse_log_note("[TSE_MDL_THD]: Close THD by conn_id=%u, tse_instance_id=%u, proxy_conn_map_key=%lu", + tse_log_note("[TSE_MDL_THD]: Close THD by conn_id=%u, ctc_instance_id=%u, proxy_conn_map_key=%lu", thd_id, mysql_inst_id, mdl_thd_key); release_tse_mdl_thd_by_key(mdl_thd_key); } @@ -832,7 +832,7 @@ int tse_ddl_execute_lock_tables_by_req(tianchi_handler_t *tch, tse_lock_table_in // unlock tables before locking tables tse_mdl_unlock_tables_thd(tch); - bool is_same_node = (tch->inst_id == tse_instance_id); + bool is_same_node = (tch->inst_id == ctc_instance_id); uint64_t mdl_thd_key = tse_get_conn_key(tch->inst_id, tch->thd_id, true); if (is_same_node) { diff --git a/storage/tianchi/ha_tse.cc b/storage/tianchi/ha_tse.cc index ba9655cc3230768468907481465963ee4477490f..f5781f3bc1a9a78921dd9a2d6bacf06c143900d8 100644 --- a/storage/tianchi/ha_tse.cc +++ b/storage/tianchi/ha_tse.cc @@ -145,20 +145,20 @@ static void ctc_stats_enabled_update(THD *, SYS_VAR *, void *var_ptr, const void } /* 创库的表空间datafile自动扩展, 默认开 */ -bool tse_db_datafile_autoextend = true; -static MYSQL_SYSVAR_BOOL(db_datafile_autoextend, tse_db_datafile_autoextend, PLUGIN_VAR_NOCMDARG, +bool ctc_db_datafile_autoextend = true; +static MYSQL_SYSVAR_BOOL(db_datafile_autoextend, ctc_db_datafile_autoextend, PLUGIN_VAR_NOCMDARG, "Indicates whether to automatically extend the tablespace data files of the TSE database.", nullptr, nullptr, true); /* 创库的表空间datafile大小, 单位M, 默认32M, 最小1M, 最大8T */ -uint32_t tse_db_datafile_size = 32; -static MYSQL_SYSVAR_UINT(db_datafile_size, tse_db_datafile_size, PLUGIN_VAR_RQCMDARG, +uint32_t ctc_db_datafile_size = 32; +static MYSQL_SYSVAR_UINT(db_datafile_size, ctc_db_datafile_size, PLUGIN_VAR_RQCMDARG, "Size of the tablespace data file of the TSE database, in MB.", nullptr, nullptr, 32, 1, 8192 * 1024, 0); /* 创库的表空间datafile自动扩展大小, 单位M, 默认128M, 最小1M, 最大8T */ -uint32_t tse_db_datafile_extend_size = 128; -static MYSQL_SYSVAR_UINT(db_datafile_extend_size, tse_db_datafile_extend_size, PLUGIN_VAR_RQCMDARG, +uint32_t ctc_db_datafile_extend_size = 128; +static MYSQL_SYSVAR_UINT(db_datafile_extend_size, ctc_db_datafile_extend_size, PLUGIN_VAR_RQCMDARG, "Size of the TSE database tablespace data file automatically extended, in MB.", nullptr, nullptr, 128, 1, 8192 * 1024, 0); -bool tse_concurrent_ddl = true; -static MYSQL_SYSVAR_BOOL(concurrent_ddl, tse_concurrent_ddl, PLUGIN_VAR_RQCMDARG, +bool ctc_concurrent_ddl = true; +static MYSQL_SYSVAR_BOOL(concurrent_ddl, ctc_concurrent_ddl, PLUGIN_VAR_RQCMDARG, "Indicates whether to ban concurrent DDL.", nullptr, nullptr, true); static mutex m_tse_metadata_normalization_mutex; @@ -181,21 +181,17 @@ static MYSQL_THDVAR_UINT(lock_wait_timeout, PLUGIN_VAR_RQCMDARG, "millisecond and values 0 means disable the timeout.", nullptr, nullptr, 50000, 0, 1024 * 1024 * 1024, 0); -static MYSQL_THDVAR_UINT(prefetch_buf_size, PLUGIN_VAR_READONLY, - "the maximum buf size of data/index prefetch", nullptr, - nullptr, 192 * 1024, 0, 192 * 1024, 0); - static MYSQL_THDVAR_DOUBLE(sampling_ratio, PLUGIN_VAR_RQCMDARG, "sampling ratio used for analyzing tables", nullptr, nullptr, 100, 0.000001, 100, 0); -__attribute__((visibility("default"))) uint32_t tse_instance_id = 0; -static MYSQL_SYSVAR_UINT(instance_id, tse_instance_id, PLUGIN_VAR_READONLY, +__attribute__((visibility("default"))) uint32_t ctc_instance_id = 0; +static MYSQL_SYSVAR_UINT(instance_id, ctc_instance_id, PLUGIN_VAR_READONLY, "mysql instance id which is used for daac", nullptr, nullptr, 0, 0, UINT32_MAX, 0); -bool tse_enable_x_lock_instance = false; -static MYSQL_SYSVAR_BOOL(enable_x_lock_instance, tse_enable_x_lock_instance, PLUGIN_VAR_NOCMDARG, +bool ctc_enable_x_lock_instance = false; +static MYSQL_SYSVAR_BOOL(enable_x_lock_instance, ctc_enable_x_lock_instance, PLUGIN_VAR_NOCMDARG, "LCOK INSTANCE FOR BACKUP add X latch on the cantian side", nullptr, nullptr, false); char *ctc_version_str = const_cast(CTC_VERSION_STR); @@ -224,7 +220,6 @@ static MYSQL_SYSVAR_UINT(update_analyze_time, ctc_update_analyze_time, PLUGIN_VA static SYS_VAR *tse_system_variables[] = { MYSQL_SYSVAR(lock_wait_timeout), MYSQL_SYSVAR(instance_id), - MYSQL_SYSVAR(prefetch_buf_size), MYSQL_SYSVAR(sampling_ratio), MYSQL_SYSVAR(enable_x_lock_instance), MYSQL_SYSVAR(db_datafile_autoextend), @@ -304,9 +299,9 @@ bool is_log_table = false; static int tse_rollback_savepoint(handlerton *hton, THD *thd, void *savepoint); handlerton *tse_hton; -int ha_tse_get_inst_id() { return tse_instance_id; } +int ha_tse_get_inst_id() { return ctc_instance_id; } -void ha_tse_set_inst_id(uint32_t inst_id) { tse_instance_id = inst_id; } +void ha_tse_set_inst_id(uint32_t inst_id) { ctc_instance_id = inst_id; } handlerton *get_tse_hton() { return tse_hton; } @@ -392,12 +387,12 @@ bool is_alter_table_scan(bool m_error_if_not_empty) { bool ddl_enabled_normal(MYSQL_THD thd) { return !user_var_set(thd, "ctc_ddl_local_enabled") && - (tse_concurrent_ddl == true || user_var_set(thd, "ctc_ddl_enabled")); + (ctc_concurrent_ddl == true || user_var_set(thd, "ctc_ddl_enabled")); } bool engine_skip_ddl(MYSQL_THD thd) { // 接口流程不需要走到参天: 用于参天SYS库操作 - return user_var_set(thd, "ctc_ddl_local_enabled") && tse_concurrent_ddl == true; + return user_var_set(thd, "ctc_ddl_local_enabled") && ctc_concurrent_ddl == true; } bool engine_ddl_passthru(MYSQL_THD thd) { @@ -1299,7 +1294,7 @@ int get_tch_in_handler_data(handlerton *hton, THD *thd, tianchi_handler_t &tch, sess_ctx->sql_stat_start = 0; } - tch.inst_id = tse_instance_id; + tch.inst_id = ctc_instance_id; tch.ctx_addr = INVALID_VALUE64; tch.sess_addr = sess_ctx->sess_addr; tch.thd_id = sess_ctx->thd_id; @@ -1516,7 +1511,7 @@ static typename std::enable_if::typ invalidate_remote_dd(T *thd, tianchi_handler_t *tch) { tse_invalidate_broadcast_request req; - req.mysql_inst_id = tse_instance_id; + req.mysql_inst_id = ctc_instance_id; req.buff_len = 0; req.is_dcl = false; invalidate_obj_entry_t *obj = NULL; @@ -1572,7 +1567,7 @@ static typename std::enable_if::ty bool invalidate_remote_dcl_cache(tianchi_handler_t *tch) { tse_invalidate_broadcast_request req; - req.mysql_inst_id = tse_instance_id; + req.mysql_inst_id = ctc_instance_id; req.buff_len = 0; req.is_dcl = true; bool result = tse_broadcast_mysql_dd_invalidate(tch, &req); @@ -1684,7 +1679,7 @@ static int tse_commit(handlerton *hton, THD *thd, bool commit_trx) { tse_ddl_broadcast_request broadcast_req {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; string sql = string(thd->query().str).substr(0, thd->query().length); FILL_BROADCAST_BASE_REQ(broadcast_req, sql.c_str(), thd->m_main_security_ctx.priv_user().str, - thd->m_main_security_ctx.priv_host().str, tse_instance_id, thd->lex->sql_command); + thd->m_main_security_ctx.priv_host().str, ctc_instance_id, thd->lex->sql_command); if (thd->db().str != NULL && thd->db().length > 0) { strncpy(broadcast_req.db_name, thd->db().str, SMALL_RECORD_SIZE - 1); } @@ -1816,7 +1811,7 @@ static void tse_kill_connection(handlerton *hton, THD *thd) { local_tch.thd_id = tch.thd_id; tse_kill_session(&local_tch); - tse_log_system("[TSE_KILL_SESSION]:conn_id:%u, tse_instance_id:%u", tch.thd_id, tch.inst_id); + tse_log_system("[TSE_KILL_SESSION]:conn_id:%u, ctc_instance_id:%u", tch.thd_id, tch.inst_id); } static int tse_pre_create_db4cantian(THD *thd, tianchi_handler_t *tch) { @@ -1834,14 +1829,14 @@ static int tse_pre_create_db4cantian(THD *thd, tianchi_handler_t *tch) { tse_db_infos_t db_infos; db_infos.name = user_name; - db_infos.datafile_size = tse_db_datafile_size; - db_infos.datafile_autoextend = tse_db_datafile_autoextend; - db_infos.datafile_extend_size = tse_db_datafile_extend_size; + db_infos.datafile_size = ctc_db_datafile_size; + db_infos.datafile_autoextend = ctc_db_datafile_autoextend; + db_infos.datafile_extend_size = ctc_db_datafile_extend_size; int ret = tse_pre_create_db(tch, sql.c_str(), &db_infos, &error_code, error_message); DBUG_EXECUTE_IF("core_after_create_tablespace_and_db", { assert(0); }); // 元数据不一致的问题 - tse_log_system("[TSE_PRE_CREATE_DB]:ret:%d, database:%s, error_code:%d, error_message:%s, conn_id:%u, tse_instance_id:%u", + tse_log_system("[TSE_PRE_CREATE_DB]:ret:%d, database:%s, error_code:%d, error_message:%s, conn_id:%u, ctc_instance_id:%u", ret, thd->lex->name.str, error_code, error_message, tch->thd_id, tch->inst_id); if (ret != CT_SUCCESS) { @@ -1871,7 +1866,7 @@ static void tse_lock_table_handle_error(int err_code, tse_lock_table_info *lock_ case ERR_USER_DDL_LOCKED: my_printf_error(ER_DISALLOWED_OPERATION, "Instance has been locked, disallow this operation", MYF(0)); tse_log_system("[TSE_MDL_LOCK]: Instance has been locked, disallow this operation," - "lock_info=(%s, %s), sql=%s, conn_id=%u, tse_instance_id=%u", + "lock_info=(%s, %s), sql=%s, conn_id=%u, ctc_instance_id=%u", lock_info->db_name, lock_info->table_name, thd->query().str, tch.thd_id, tch.inst_id); break; @@ -1882,7 +1877,7 @@ static void tse_lock_table_handle_error(int err_code, tse_lock_table_info *lock_ default: my_printf_error(err_code, "The table or database is being used. Please try again later.", MYF(0)); - tse_log_error("[TSE_MDL_LOCK]: Lock failed, err=%d, lock_info=(%s, %s), sql=%s, conn_id=%u, tse_instance_id=%u", + tse_log_error("[TSE_MDL_LOCK]: Lock failed, err=%d, lock_info=(%s, %s), sql=%s, conn_id=%u, ctc_instance_id=%u", err_code, lock_info->db_name, lock_info->table_name, thd->query().str, tch.thd_id, tch.inst_id); break; } @@ -1956,10 +1951,10 @@ static int tse_notify_post_event(THD *thd, handlerton *tse_hton, tianchi_handler } tse_log_system("[UNLOCK_TABLE]: tse_unlock_table lock_info=(%s, %s), sql=%s", lock_info->db_name, lock_info->table_name, thd->query().str); - ret = tse_unlock_table(&tch, tse_instance_id, lock_info); + ret = tse_unlock_table(&tch, ctc_instance_id, lock_info); if (ret != 0) { - tse_log_error("[TSE_MDL_LOCK]: unlock failed, ret: %d, sql: %s, conn_id: %u, tse_instance_id: %u", + tse_log_error("[TSE_MDL_LOCK]: unlock failed, ret: %d, sql: %s, conn_id: %u, ctc_instance_id: %u", ret, thd->query().str, tch.thd_id, tch.inst_id); } } @@ -2032,7 +2027,7 @@ static bool tse_notify_exclusive_mdl(THD *thd, const MDL_key *mdl_key, update_sess_ctx_by_tch(tch, tse_hton, thd); if (ret != 0) { - tse_unlock_table(&tch, tse_instance_id, &lock_info); + tse_unlock_table(&tch, ctc_instance_id, &lock_info); return true; } @@ -3358,7 +3353,7 @@ int ha_tse::optimize(THD *thd, HA_CHECK_OPT *) } tse_ddl_stack_mem stack_mem(0); update_member_tch(m_tch, tse_hton, thd); - ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, tse_instance_id, false, 0}; + ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, ctc_instance_id, false, 0}; FILL_USER_INFO_WITH_THD(ddl_ctrl, thd); ct_errno_t ret = (ct_errno_t)fill_rebuild_index_req(table, thd, &ddl_ctrl, &stack_mem); if (ret != 0) { @@ -4295,7 +4290,7 @@ static int tse_create_db(THD *thd, handlerton *hton) { string sql = string(thd->query().str).substr(0, thd->query().length); FILL_BROADCAST_BASE_REQ(broadcast_req, sql.c_str(), thd->m_main_security_ctx.priv_user().str, - thd->m_main_security_ctx.priv_host().str, tse_instance_id, tch.sql_command); + thd->m_main_security_ctx.priv_host().str, ctc_instance_id, tch.sql_command); broadcast_req.options &= (~TSE_NOT_NEED_CANTIAN_EXECUTE); int ret = tse_execute_mysql_ddl_sql(&tch, &broadcast_req, false); @@ -4863,7 +4858,7 @@ EXTER_ATTACK int ha_tse::delete_table(const char *full_path_name, const dd::Tabl } update_member_tch(m_tch, tse_hton, thd); - ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, tse_instance_id, false, 0}; + ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, ctc_instance_id, false, 0}; FILL_USER_INFO_WITH_THD(ddl_ctrl, thd); tse_ddl_stack_mem stack_mem(0); int mysql_ret = fill_delete_table_req(full_path_name, table_def, thd, &ddl_ctrl, &stack_mem); @@ -5024,7 +5019,7 @@ EXTER_ATTACK int ha_tse::create(const char *name, TABLE *form, HA_CREATE_INFO *c tse_ddl_stack_mem stack_mem(0); update_member_tch(m_tch, tse_hton, thd); - ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, tse_instance_id, false, 0}; + ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, ctc_instance_id, false, 0}; FILL_USER_INFO_WITH_THD(ddl_ctrl, thd); if (is_alter_table_copy(thd)) { @@ -5116,7 +5111,7 @@ bool ha_tse::inplace_alter_table(TABLE *altered_table, tse_ddl_stack_mem stack_mem(0); update_member_tch(m_tch, tse_hton, thd); - ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, tse_instance_id, false, 0}; + ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, ctc_instance_id, false, 0}; FILL_USER_INFO_WITH_THD(ddl_ctrl, thd); if (alter_info->flags & Alter_info::ALTER_RECREATE) { ret = (ct_errno_t)fill_rebuild_index_req(altered_table, thd, &ddl_ctrl, &stack_mem); @@ -5180,7 +5175,7 @@ EXTER_ATTACK int ha_tse::rename_table(const char *from, const char *to, tse_ddl_stack_mem stack_mem(0); update_member_tch(m_tch, tse_hton, thd); - ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, tse_instance_id, false, 0}; + ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, ctc_instance_id, false, 0}; FILL_USER_INFO_WITH_THD(ddl_ctrl, thd); if (is_alter_table_copy(thd)) { ddl_ctrl.is_alter_copy = true; diff --git a/storage/tianchi/ha_tse_ddl.cc b/storage/tianchi/ha_tse_ddl.cc index b4c50ee776b72743e1a184f5c2e6377948e64351..41d6a961621d021a1ce3d7812d0185c6d1dc9c7a 100644 --- a/storage/tianchi/ha_tse_ddl.cc +++ b/storage/tianchi/ha_tse_ddl.cc @@ -71,7 +71,7 @@ using namespace std; const uint32_t TSE_DDL_PROTOBUF_MEM_SIZE = 1024 * 1024 * 10; // 10M mutex m_tse_ddl_protobuf_mem_mutex; char tse_ddl_req_mem[TSE_DDL_PROTOBUF_MEM_SIZE]; -extern uint32_t tse_instance_id; +extern uint32_t ctc_instance_id; extern handlerton *tse_hton; size_t tse_ddl_stack_mem::tse_ddl_req_msg_mem_max_size = 0; @@ -225,7 +225,7 @@ static int tse_create_tablespace_handler(handlerton *hton, THD *thd, } tianchi_handler_t tch; TSE_RETURN_IF_NOT_ZERO(get_tch_in_handler_data(hton, thd, tch)); - ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, tch, tse_instance_id, false, 0}; + ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, tch, ctc_instance_id, false, 0}; FILL_USER_INFO_WITH_THD(ddl_ctrl, thd); ddl_ctrl.msg_len = msg_len; ret = (ct_errno_t)tse_create_tablespace(tse_ddl_req_msg_mem, &ddl_ctrl); @@ -300,7 +300,7 @@ static int tse_alter_tablespace_handler(handlerton *hton, THD *thd, } tianchi_handler_t tch; TSE_RETURN_IF_NOT_ZERO(get_tch_in_handler_data(hton, thd, tch)); - ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, tch, tse_instance_id, false, 0}; + ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, tch, ctc_instance_id, false, 0}; FILL_USER_INFO_WITH_THD(ddl_ctrl, thd); ddl_ctrl.msg_len = msg_len; ret = (ct_errno_t)tse_alter_tablespace(tse_ddl_req_msg_mem, &ddl_ctrl); @@ -345,7 +345,7 @@ static int tse_drop_tablespace_handler(handlerton *hton, THD *thd, } tianchi_handler_t tch; TSE_RETURN_IF_NOT_ZERO(get_tch_in_handler_data(hton, thd, tch)); - ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, tch, tse_instance_id, false, 0}; + ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, tch, ctc_instance_id, false, 0}; FILL_USER_INFO_WITH_THD(ddl_ctrl, thd); ddl_ctrl.msg_len = msg_len; @@ -1656,7 +1656,7 @@ int ha_tse_truncate_table(tianchi_handler_t *tch, THD *thd, const char *db_name, } } update_member_tch(*tch, tse_hton, thd); - ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, *tch, tse_instance_id, false, 0}; + ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, *tch, ctc_instance_id, false, 0}; FILL_USER_INFO_WITH_THD(ddl_ctrl, thd); ddl_ctrl.msg_len = msg_len; ret = (ct_errno_t)tse_truncate_table(tse_ddl_req_msg_mem, &ddl_ctrl); diff --git a/storage/tianchi/ha_tsepart.cc b/storage/tianchi/ha_tsepart.cc index d92c6d7fdb189d8eb0b85224798925b894826c22..8bf71c79215e2707f74b8fe2884b47d0733646ea 100644 --- a/storage/tianchi/ha_tsepart.cc +++ b/storage/tianchi/ha_tsepart.cc @@ -897,7 +897,7 @@ int ha_tsepart::records(ha_rows *num_rows) /*!< out: number of rows */ return 0; } -extern uint32_t tse_instance_id; +extern uint32_t ctc_instance_id; /* alter table truncate partition */ int ha_tsepart::truncate_partition_low(dd::Table *dd_table) { THD *thd = ha_thd(); @@ -907,7 +907,7 @@ int ha_tsepart::truncate_partition_low(dd::Table *dd_table) { tse_ddl_stack_mem stack_mem(0); update_member_tch(m_tch, ht, thd); - ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, tse_instance_id, false, 0}; + ddl_ctrl_t ddl_ctrl = {{0}, {0}, {0}, 0, 0, m_tch, ctc_instance_id, false, 0}; FILL_USER_INFO_WITH_THD(ddl_ctrl, thd); ct_errno_t ret = (ct_errno_t)fill_truncate_partition_req( table->s->normalized_path.str, m_part_info, dd_table, thd, &ddl_ctrl, @@ -1111,7 +1111,7 @@ int ha_tsepart::repair(THD *thd, HA_CHECK_OPT *) tse_ddl_broadcast_request broadcast_req {{0}, {0}, {0}, {0}, 0, 0, 0, 0, {0}}; string sql = string(thd->query().str).substr(0, thd->query().length); FILL_BROADCAST_BASE_REQ(broadcast_req, sql.c_str(), thd->m_main_security_ctx.priv_user().str, - thd->m_main_security_ctx.priv_host().str, tse_instance_id, thd->lex->sql_command); + thd->m_main_security_ctx.priv_host().str, ctc_instance_id, thd->lex->sql_command); if (thd->db().str != NULL && thd->db().length > 0) { strncpy(broadcast_req.db_name, thd->db().str, SMALL_RECORD_SIZE - 1); } diff --git a/storage/tianchi/srv_mq_msg.h b/storage/tianchi/srv_mq_msg.h index 8508c5466989acd7d79516bcf33df5e7595bb829..f28ec3f386b1c2dd6e4915966689fe633a6527c5 100644 --- a/storage/tianchi/srv_mq_msg.h +++ b/storage/tianchi/srv_mq_msg.h @@ -172,9 +172,9 @@ struct pre_create_db_request { tianchi_handler_t tch; char sql_str[MAX_DDL_SQL_LEN]; char db_name[SMALL_RECORD_SIZE]; - uint32_t tse_db_datafile_size; - bool tse_db_datafile_autoextend; - uint32_t tse_db_datafile_extend_size; + uint32_t ctc_db_datafile_size; + bool ctc_db_datafile_autoextend; + uint32_t ctc_db_datafile_extend_size; int error_code; char error_message[SMALL_RECORD_SIZE]; int result; diff --git a/storage/tianchi/tse_ddl_rewriter_plugin.cc b/storage/tianchi/tse_ddl_rewriter_plugin.cc index ab6143d77c82a475707a95665f9386ce224351e2..ee61f007e73192a4c29a01f7121dde93ae149835 100644 --- a/storage/tianchi/tse_ddl_rewriter_plugin.cc +++ b/storage/tianchi/tse_ddl_rewriter_plugin.cc @@ -62,7 +62,7 @@ static SYS_VAR *tse_rewriter_system_variables[] = { nullptr }; -extern uint32_t tse_instance_id; +extern uint32_t ctc_instance_id; static bool is_current_system_var(set_var *setvar) { Item_func_get_system_var *itemFunc = dynamic_cast(setvar->value); @@ -467,7 +467,7 @@ static uint32_t tse_set_var_option(bool is_null_value, bool is_set_default_value static int tse_set_var_meta(MYSQL_THD thd, uint32_t options, const char* base_name, string var_name, string var_value) { tianchi_handler_t tch; - tch.inst_id = tse_instance_id; + tch.inst_id = ctc_instance_id; handlerton* hton = get_tse_hton(); TSE_RETURN_IF_NOT_ZERO(get_tch_in_handler_data(hton, thd, tch)); @@ -479,7 +479,7 @@ static int tse_set_var_meta(MYSQL_THD thd, uint32_t options, const char* base_na // user_name存变量名,user_ip存变量值 FILL_BROADCAST_BASE_REQ(broadcast_req, sql.c_str(), var_name.c_str(), - var_value.c_str(), tse_instance_id, SQLCOM_SET_OPTION); + var_value.c_str(), ctc_instance_id, SQLCOM_SET_OPTION); if(base_name != nullptr) { strncpy(broadcast_req.db_name, base_name, strlen(base_name)); } @@ -720,7 +720,7 @@ static int tse_lock_tables_ddl(string &, MYSQL_THD thd, bool &) { for (TABLE_LIST *table = tables; table != NULL; table = table->next_global) { tianchi_handler_t tch; - tch.inst_id = tse_instance_id; + tch.inst_id = ctc_instance_id; handlerton* hton = get_tse_hton(); TSE_RETURN_IF_NOT_ZERO(get_tch_in_handler_data(hton, thd, tch)); @@ -750,7 +750,7 @@ static int tse_lock_tables_ddl(string &, MYSQL_THD thd, bool &) { if (ret != 0) { for (TABLE_LIST *table = tables; table != NULL; table = table->next_global) { tianchi_handler_t tch; - tch.inst_id = tse_instance_id; + tch.inst_id = ctc_instance_id; handlerton* hton = get_tse_hton(); TSE_RETURN_IF_NOT_ZERO(get_tch_in_handler_data(hton, thd, tch)); @@ -759,7 +759,7 @@ static int tse_lock_tables_ddl(string &, MYSQL_THD thd, bool &) { FILL_USER_INFO_WITH_THD(lock_info, thd); strncpy(lock_info.db_name, table->db, SMALL_RECORD_SIZE); strncpy(lock_info.table_name, table->table_name, SMALL_RECORD_SIZE); - ret = tse_unlock_table(&tch, tse_instance_id, &lock_info); + ret = tse_unlock_table(&tch, ctc_instance_id, &lock_info); if (ret != 0) { tse_log_error("[TSE_DDL_REWRITE]:unlock table failed, table:%s.%s", lock_info.db_name, lock_info.table_name); } @@ -772,7 +772,7 @@ static int tse_unlock_tables_ddl(string &, MYSQL_THD thd, bool &) { int ret = 0; tianchi_handler_t tch; - tch.inst_id = tse_instance_id; + tch.inst_id = ctc_instance_id; handlerton* hton = get_tse_hton(); TSE_RETURN_IF_NOT_ZERO(get_tch_in_handler_data(hton, thd, tch)); @@ -781,7 +781,7 @@ static int tse_unlock_tables_ddl(string &, MYSQL_THD thd, bool &) { FILL_USER_INFO_WITH_THD(lock_info, thd); - ret = tse_unlock_table(&tch, tse_instance_id, &lock_info); + ret = tse_unlock_table(&tch, ctc_instance_id, &lock_info); return ret; } @@ -974,7 +974,7 @@ int ddl_broadcast_and_wait(MYSQL_THD thd, string &query_str, uint8_t sql_cmd, ddl_broadcast_cmd &broadcast_cmd) { tianchi_handler_t tch; memset(&tch, 0, sizeof(tch)); - tch.inst_id = tse_instance_id; + tch.inst_id = ctc_instance_id; handlerton *hton = get_tse_hton(); update_member_tch(tch, hton, thd); @@ -992,7 +992,7 @@ int ddl_broadcast_and_wait(MYSQL_THD thd, string &query_str, broadcast_req.options |= TSE_NOT_NEED_CANTIAN_EXECUTE; broadcast_req.options |= (thd->lex->contains_plaintext_password ? TSE_CURRENT_SQL_CONTAIN_PLAINTEXT_PASSWORD : 0); FILL_BROADCAST_BASE_REQ(broadcast_req, query_str.c_str(), thd->m_main_security_ctx.priv_user().str, - thd->m_main_security_ctx.priv_host().str, tse_instance_id, sql_cmd); + thd->m_main_security_ctx.priv_host().str, ctc_instance_id, sql_cmd); vector ticket_list; if (sql_cmd == SQLCOM_LOCK_TABLES) { @@ -1075,7 +1075,7 @@ bool check_agent_connection(MYSQL_THD thd) { int ctc_record_sql(MYSQL_THD thd, bool need_select_db) { tianchi_handler_t tch; - tch.inst_id = tse_instance_id; + tch.inst_id = ctc_instance_id; handlerton* hton = get_tse_hton(); TSE_RETURN_IF_NOT_ZERO(get_tch_in_handler_data(hton, thd, tch)); @@ -1091,7 +1091,7 @@ int ctc_record_sql(MYSQL_THD thd, bool need_select_db) { string sql = string(thd->query().str).substr(0, thd->query().length); FILL_BROADCAST_BASE_REQ(broadcast_req, sql.c_str(), thd->m_main_security_ctx.priv_user().str, - thd->m_main_security_ctx.priv_host().str, tse_instance_id, (uint8_t)thd->lex->sql_command); + thd->m_main_security_ctx.priv_host().str, ctc_instance_id, (uint8_t)thd->lex->sql_command); int ret = ctc_record_sql_for_cantian(&tch, &broadcast_req, false); update_sess_ctx_by_tch(tch, hton, thd); diff --git a/storage/tianchi/tse_mysql_proxy.cc b/storage/tianchi/tse_mysql_proxy.cc index 5ff835a545a7f12285b101d6268dc39032d07684..3bc2e3872fd1b927bdaef8ded1b0acdb4f9f1ba8 100644 --- a/storage/tianchi/tse_mysql_proxy.cc +++ b/storage/tianchi/tse_mysql_proxy.cc @@ -333,10 +333,10 @@ static inline bool tse_use_proxy(uint8_t sql_command) { return !is_slave && !is_backup_lock_op(sql_command); } -extern uint32_t tse_instance_id; +extern uint32_t ctc_instance_id; __attribute__((visibility("default"))) int tse_execute_rewrite_open_conn(uint32_t thd_id, tse_ddl_broadcast_request *broadcast_req) { // 相同节点不用执行 - if (broadcast_req->mysql_inst_id == tse_instance_id) { + if (broadcast_req->mysql_inst_id == ctc_instance_id) { return 0; } @@ -363,7 +363,7 @@ __attribute__((visibility("default"))) int tse_execute_rewrite_open_conn(uint32_ __attribute__((visibility("default"))) int tse_ddl_execute_update(uint32_t thd_id, tse_ddl_broadcast_request *broadcast_req, bool *allow_fail) { // 相同节点不用执行 - if(broadcast_req->mysql_inst_id == tse_instance_id) { + if(broadcast_req->mysql_inst_id == ctc_instance_id) { tse_log_note("tse_ddl_execute_update curnode not need execute,mysql_inst_id:%u", broadcast_req->mysql_inst_id); return 0; } @@ -518,14 +518,14 @@ __attribute__((visibility("default"))) int tse_ddl_execute_lock_tables(tianchi_h return 0; } - bool is_same_node = (tch->inst_id == tse_instance_id); + bool is_same_node = (tch->inst_id == ctc_instance_id); uint64_t conn_map_key = tse_get_conn_key(tch->inst_id, tch->thd_id, !is_same_node); MYSQL *curr_conn = NULL; int ret = tse_init_mysql_client(conn_map_key, db_name, curr_conn, lock_info->user_name, lock_info->user_ip, !is_same_node); if (ret != 0) { *err_code = ret; - tse_log_error("[TSE_LOCK_TABLE]:tse_init_mysql_client failed, ret:%d, conn_id:%u, tse_instance_id:%u", + tse_log_error("[TSE_LOCK_TABLE]:tse_init_mysql_client failed, ret:%d, conn_id:%u, ctc_instance_id:%u", ret, tch->thd_id, tch->inst_id); return ret; } @@ -591,7 +591,7 @@ __attribute__((visibility("default"))) int tse_ddl_execute_lock_tables(tianchi_h ret = tse_mysql_query(curr_conn, lock_str.c_str()); if (ret != 0 || mysql_errno(curr_conn) != 0) { *err_code = mysql_errno(curr_conn); - tse_log_error("[TSE_LOCK_TABLE]:return_err:%d, err_code:%d, err_msg:%s, lock_sql_str:%s, conn_id:%u, tse_instance_id:%u", + tse_log_error("[TSE_LOCK_TABLE]:return_err:%d, err_code:%d, err_msg:%s, lock_sql_str:%s, conn_id:%u, ctc_instance_id:%u", ret, *err_code, mysql_error(curr_conn), lock_str.c_str(), tch->thd_id, tch->inst_id); } } @@ -610,11 +610,11 @@ __attribute__((visibility("default"))) int tse_ddl_execute_unlock_tables(tianchi return 0; } - bool is_same_node = (tch->inst_id == tse_instance_id); + bool is_same_node = (tch->inst_id == ctc_instance_id); uint64_t conn_map_key = tse_get_conn_key(tch->inst_id, tch->thd_id, !is_same_node); MYSQL *curr_conn = get_mysql_conn_by_key(conn_map_key); if (curr_conn == NULL) { - tse_log_system("[TSE_UNLOCK_TABLE]: curr_conn is NULL, conn_map_key=%lu, conn_id=%u, tse_instance_id=%u", + tse_log_system("[TSE_UNLOCK_TABLE]: curr_conn is NULL, conn_map_key=%lu, conn_id=%u, ctc_instance_id=%u", conn_map_key, tch->thd_id, tch->inst_id); return 0; } @@ -685,18 +685,18 @@ __attribute__((visibility("default"))) int close_mysql_connection(uint32_t thd_i close_mysql_conn_by_inst_id((mysql_inst_id >> 16), false); } else { /* 清理整个mysqld节点相关的连接 */ - tse_log_system("[TSE_CLOSE_SESSION]:Close All connects by tse_instance_id:%u", mysql_inst_id); + tse_log_system("[TSE_CLOSE_SESSION]:Close All connects by ctc_instance_id:%u", mysql_inst_id); close_mysql_conn_by_inst_id(mysql_inst_id, true); } } else { /* 通过把mysql_inst_id左移32位 与 thd_id拼接在一起 用来唯一标识一个连接 */ uint64_t proxy_conn_map_key = tse_get_conn_key(mysql_inst_id, thd_id, true); - tse_log_note("[TSE_CLOSE_SESSION]: Close connect by conn_id=%u, tse_instance_id=%u, proxy_conn_map_key=%lu", + tse_log_note("[TSE_CLOSE_SESSION]: Close connect by conn_id=%u, ctc_instance_id=%u, proxy_conn_map_key=%lu", thd_id, mysql_inst_id, proxy_conn_map_key); close_mysql_conn_by_key(proxy_conn_map_key); uint64_t agent_conn_map_key = tse_get_conn_key(mysql_inst_id, thd_id, false); - tse_log_note("[TSE_CLOSE_SESSION]: Close connect by conn_id=%u, tse_instance_id=%u, agent_conn_map_key=%lu", + tse_log_note("[TSE_CLOSE_SESSION]: Close connect by conn_id=%u, ctc_instance_id=%u, agent_conn_map_key=%lu", thd_id, mysql_inst_id, agent_conn_map_key); close_mysql_conn_by_key(agent_conn_map_key); } diff --git a/storage/tianchi/tse_srv_mq_stub.cc b/storage/tianchi/tse_srv_mq_stub.cc index 6b71d78c55e894786d5fedf825d5f0855b26a599..43842137595a629088a02b5e1f599863434c4e59 100644 --- a/storage/tianchi/tse_srv_mq_stub.cc +++ b/storage/tianchi/tse_srv_mq_stub.cc @@ -1020,9 +1020,9 @@ int tse_pre_create_db(tianchi_handler_t *tch, const char *sql_str, tse_db_infos_ assert(strlen(db_infos->name) + 1 <= sizeof(req->db_name)); memcpy(req->db_name, db_infos->name, strlen(db_infos->name) + 1); - req->tse_db_datafile_size = db_infos->datafile_size; - req->tse_db_datafile_autoextend = db_infos->datafile_autoextend; - req->tse_db_datafile_extend_size = db_infos->datafile_extend_size; + req->ctc_db_datafile_size = db_infos->datafile_size; + req->ctc_db_datafile_autoextend = db_infos->datafile_autoextend; + req->ctc_db_datafile_extend_size = db_infos->datafile_extend_size; req->tch = *tch; TSE_RESET_SHM_REQ_ERROR_CODE(req); int ret = tse_mq_deal_func(shm_inst, TSE_FUNC_PRE_CREATE_DB, req, tch->msg_buf); diff --git a/storage/tianchi/tse_util.cc b/storage/tianchi/tse_util.cc index d0ae5e8c179be82860f71b96e380d8c906360b3a..310b34d96e1322621cef989f2559abbd335a0495 100644 --- a/storage/tianchi/tse_util.cc +++ b/storage/tianchi/tse_util.cc @@ -34,7 +34,7 @@ #include "ha_tse_ddl.h" using namespace std; -extern bool tse_enable_x_lock_instance; +extern bool ctc_enable_x_lock_instance; string cnvrt_name_for_sql(string name) { string res = ""; @@ -733,7 +733,7 @@ int tse_check_lock_instance(MYSQL_THD thd, bool &need_forward) { tse_lock_table_mode_t lock_mode; bool is_mysqld_starting = is_starting(); - if (tse_enable_x_lock_instance || is_mysqld_starting) { + if (ctc_enable_x_lock_instance || is_mysqld_starting) { lock_mode = TSE_LOCK_MODE_EXCLUSIVE; } else { lock_mode = TSE_LOCK_MODE_SHARE;