From 732a02763d097b40b8cd7a7d06231c9369bb6b27 Mon Sep 17 00:00:00 2001 From: yuanyazhi Date: Mon, 26 May 2025 20:33:46 +0800 Subject: [PATCH] invalidate all dd cache --- storage/ctc/ctc_meta_data.cc | 10 ++++++++-- storage/ctc/ha_ctc.cc | 7 ++++++- storage/ctc/ha_ctc.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/storage/ctc/ctc_meta_data.cc b/storage/ctc/ctc_meta_data.cc index 5fc9b3a..89207c1 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 994054c..8b30f8c 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; diff --git a/storage/ctc/ha_ctc.h b/storage/ctc/ha_ctc.h index bede217..e635898 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) -- Gitee