From 24fc9752d84cbf4a2fb5865dfda8a7a97ea87253 Mon Sep 17 00:00:00 2001 From: jiang_tiancheng Date: Tue, 27 May 2025 19:03:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?WSR=E6=8A=A5=E5=91=8A=E5=AF=B9=E6=8E=A5mysq?= =?UTF-8?q?l=EF=BC=8C=E6=9E=81=E9=99=90=E6=80=A7=E8=83=BD=E4=B8=8B?= =?UTF-8?q?=E9=99=8D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- storage/ctc/ha_ctc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/ctc/ha_ctc.cc b/storage/ctc/ha_ctc.cc index 994054c..a8770db 100644 --- a/storage/ctc/ha_ctc.cc +++ b/storage/ctc/ha_ctc.cc @@ -1529,7 +1529,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); -- Gitee From 732a02763d097b40b8cd7a7d06231c9369bb6b27 Mon Sep 17 00:00:00 2001 From: yuanyazhi Date: Mon, 26 May 2025 20:33:46 +0800 Subject: [PATCH 2/2] 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