diff --git a/storage/ctc/ctc_meta_data.cc b/storage/ctc/ctc_meta_data.cc index 5fc9b3aa7bb3f4a49a1f0e72b4162f591da58605..89207c192b72488a347fbf0f559291f409cd7c11 100644 --- a/storage/ctc/ctc_meta_data.cc +++ b/storage/ctc/ctc_meta_data.cc @@ -431,7 +431,7 @@ static typename std::enable_if::type ctc_invalidate_mysql_dd_cache_impl(ctc_handler_t *tch, ctc_invalidate_broadcast_request *broadcast_req, int *err_code) { UNUSED_PARAM(err_code); // 相同节点不用执行 - if(broadcast_req->mysql_inst_id == ctc_instance_id) { + if (broadcast_req->mysql_inst_id == ctc_instance_id) { ctc_log_note("ctc_invalidate_mysql_dd_cache curnode not need execute,mysql_inst_id:%u", broadcast_req->mysql_inst_id); return 0; } @@ -440,7 +440,13 @@ static typename std::enable_if::type T *thd = nullptr; uint64_t thd_key = ctc_get_conn_key(tch->inst_id, tch->thd_id, true); ctc_init_thd(&thd, thd_key); - + + // invalidate all dd cache + if (broadcast_req->buff_len == 0 && broadcast_req->is_dcl == false) { + dd::cache::Shared_dictionary_cache::instance()->reset(true); + return 0; + } + if (broadcast_req->is_dcl == true) { error = reload_acl_caches(thd, false); ctc_log_system("[CTC_INVALID_DD]: remote invalidate acl cache, mysql_inst_id=%u", broadcast_req->mysql_inst_id); diff --git a/storage/ctc/ha_ctc.cc b/storage/ctc/ha_ctc.cc index 994054ce147002c2ef39b12819d2e6c2619ebcef..4267e323471eedf7ca163ef7a631d03175c4e13b 100644 --- a/storage/ctc/ha_ctc.cc +++ b/storage/ctc/ha_ctc.cc @@ -1361,8 +1361,13 @@ static typename std::enable_if::typ { ctc_invalidate_broadcast_request req; req.mysql_inst_id = ctc_instance_id; - req.buff_len = 1; req.is_dcl = false; + if (thd->invalidates().size() >= DD_BROADCAST_RECORD_SIZE) { + req.buff_len = 0; + (void)ctc_broadcast_mysql_dd_invalidate(tch, &req); + return; + } + req.buff_len = 1; req.is_flush = (tch->sql_command == SQLCOM_FLUSH) ? true : false; invalidate_obj_entry_t *obj = NULL; @@ -1529,7 +1534,7 @@ static int ctc_commit(handlerton *hton, THD *thd, bool commit_trx) { assert(sess_ctx != nullptr); bool is_dmlsql = false; bool enable_stat = get_enable_wsr_stat(); - if (thd->query().str != NULL && thd->query().length > 0) { + if (enable_stat && thd->query().str != NULL && thd->query().length > 0) { string dml_sql = string(thd->query().str).substr(0, thd->query().length); String dml_sql_string(dml_sql.c_str(), dml_sql.length(), thd->charset()); is_dmlsql = is_dml_cmd(dml_sql_string); diff --git a/storage/ctc/ha_ctc.h b/storage/ctc/ha_ctc.h index bede2173b2a7acbfadd91779b5f6c6496fb17f73..e635898c2d178d69661853822a35293ff7e0aa97 100644 --- a/storage/ctc/ha_ctc.h +++ b/storage/ctc/ha_ctc.h @@ -147,6 +147,7 @@ again. */ return HA_ERR_SE_OUT_OF_MEMORY; \ } +#define DD_BROADCAST_RECORD_SIZE (1000) #define IS_METADATA_NORMALIZATION() (ctc_get_metadata_switch() == (int32_t)metadata_switchs::MATCH_META) #define IS_PRIMARY_ROLE() (ctc_get_cluster_role() == (int32_t)dis_cluster_role::PRIMARY) #define IS_STANDBY_ROLE() (ctc_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY)