From 1e1e5a0416fa7754163d4d707b756b7bbcc0181a Mon Sep 17 00:00:00 2001 From: solid-yang Date: Fri, 29 Mar 2024 09:46:58 +0800 Subject: [PATCH 1/4] do not broadcast lock or unlock table sql cmds for ddl replay --- storage/tianchi/tse_ddl_rewriter_plugin.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/storage/tianchi/tse_ddl_rewriter_plugin.cc b/storage/tianchi/tse_ddl_rewriter_plugin.cc index 4519838..c3f13b9 100644 --- a/storage/tianchi/tse_ddl_rewriter_plugin.cc +++ b/storage/tianchi/tse_ddl_rewriter_plugin.cc @@ -706,6 +706,13 @@ static int tse_read_only_ddl(string &, MYSQL_THD thd, bool &need_forward) { return 0; } +static int tse_check_lock_unlock_replay(string &, MYSQL_THD thd, bool &need_forward) { + if (user_var_set(thd, "ctc_ddl_local_enabled") && user_var_set(thd, "ctc_replay_ddl")) { + need_forward = false; + } + return 0; +} + typedef struct ddl_broadcast_cmd_s { bool need_select_db; // 需要指定数据库 @@ -753,8 +760,8 @@ static unordered_map {SQLCOM_SET_OPTION, {true, tse_check_set_opt}}, // Locking, broadcast - {SQLCOM_LOCK_TABLES, {true, NULL}}, - {SQLCOM_UNLOCK_TABLES, {true, NULL}}, + {SQLCOM_LOCK_TABLES, {true, tse_check_lock_unlock_replay}}, + {SQLCOM_UNLOCK_TABLES, {true, tse_check_lock_unlock_replay}}, {SQLCOM_LOCK_INSTANCE, {false, NULL}}, {SQLCOM_UNLOCK_INSTANCE, {false, NULL}}, -- Gitee From d1f30e0166c4cccb1a382c6b171d61b0c4fd20bc Mon Sep 17 00:00:00 2001 From: Jiachen1018 Date: Fri, 29 Mar 2024 17:46:38 +0800 Subject: [PATCH 2/4] rm useless in cache_variant_t --- storage/tianchi/tse_cbo.cc | 3 --- storage/tianchi/tse_srv.h | 10 ---------- 2 files changed, 13 deletions(-) diff --git a/storage/tianchi/tse_cbo.cc b/storage/tianchi/tse_cbo.cc index 7b24310..205ffaa 100644 --- a/storage/tianchi/tse_cbo.cc +++ b/storage/tianchi/tse_cbo.cc @@ -22,7 +22,6 @@ void r_key2variant(tse_key *rKey, KEY_PART_INFO *cur_index_part, cache_variant_t *ret_val, cache_variant_t * value, uint32_t key_offset) { - ret_val->is_null = 0; if (rKey->cmp_type == CMP_TYPE_NULL) { *ret_val = *value; rKey->cmp_type = CMP_TYPE_CLOSE_INTERNAL; @@ -30,7 +29,6 @@ void r_key2variant(tse_key *rKey, KEY_PART_INFO *cur_index_part, cache_variant_t } enum_field_types field_type = cur_index_part->field->real_type(); - ret_val->type = field_type; uint32_t offset = 0; if (cur_index_part->field->is_nullable()) { /* The first byte in the field tells if this is an SQL NULL value */ @@ -59,7 +57,6 @@ void r_key2variant(tse_key *rKey, KEY_PART_INFO *cur_index_part, cache_variant_t ret_val->v_bigint = *(int64_t *)const_cast(key); break; default: - ret_val->is_null = 1; break; } } diff --git a/storage/tianchi/tse_srv.h b/storage/tianchi/tse_srv.h index 56c59fb..1922adb 100644 --- a/storage/tianchi/tse_srv.h +++ b/storage/tianchi/tse_srv.h @@ -112,16 +112,6 @@ typedef struct cache_st_variant { unsigned long long v_ubigint; double v_real; }; - - union { - struct { - short type; - unsigned char is_null; - unsigned char is_hex; - }; - - unsigned int ctrl; - }; } cache_variant_t; typedef enum { -- Gitee From 5503b1c9e9b483d237e81ff104142970ef71f7b1 Mon Sep 17 00:00:00 2001 From: solid-yang Date: Fri, 29 Mar 2024 19:33:03 +0800 Subject: [PATCH 3/4] Revert "!103 do not braodcast sql cmd for ddl replay" This reverts commit 4b4b19cb294f7af0141841b2281c75c6e31bc592, reversing changes made to c47deda5b80a62573f882ad0807ee834a6a4629e. --- storage/tianchi/tse_ddl_rewriter_plugin.cc | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/storage/tianchi/tse_ddl_rewriter_plugin.cc b/storage/tianchi/tse_ddl_rewriter_plugin.cc index c3f13b9..4519838 100644 --- a/storage/tianchi/tse_ddl_rewriter_plugin.cc +++ b/storage/tianchi/tse_ddl_rewriter_plugin.cc @@ -706,13 +706,6 @@ static int tse_read_only_ddl(string &, MYSQL_THD thd, bool &need_forward) { return 0; } -static int tse_check_lock_unlock_replay(string &, MYSQL_THD thd, bool &need_forward) { - if (user_var_set(thd, "ctc_ddl_local_enabled") && user_var_set(thd, "ctc_replay_ddl")) { - need_forward = false; - } - return 0; -} - typedef struct ddl_broadcast_cmd_s { bool need_select_db; // 需要指定数据库 @@ -760,8 +753,8 @@ static unordered_map {SQLCOM_SET_OPTION, {true, tse_check_set_opt}}, // Locking, broadcast - {SQLCOM_LOCK_TABLES, {true, tse_check_lock_unlock_replay}}, - {SQLCOM_UNLOCK_TABLES, {true, tse_check_lock_unlock_replay}}, + {SQLCOM_LOCK_TABLES, {true, NULL}}, + {SQLCOM_UNLOCK_TABLES, {true, NULL}}, {SQLCOM_LOCK_INSTANCE, {false, NULL}}, {SQLCOM_UNLOCK_INSTANCE, {false, NULL}}, -- Gitee From 17f2b8835fff6582e2c18fa2102c4eab6c131421 Mon Sep 17 00:00:00 2001 From: solid-yang Date: Fri, 29 Mar 2024 19:33:25 +0800 Subject: [PATCH 4/4] Revert "!101 fix lock table" This reverts commit c47deda5b80a62573f882ad0807ee834a6a4629e, reversing changes made to 1120aa989867eb782c994aed89f8e3a1949c70e1. --- storage/tianchi/tse_ddl_rewriter_plugin.cc | 2 +- storage/tianchi/tse_mysql_proxy.cc | 2 +- storage/tianchi/tse_util.h | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/storage/tianchi/tse_ddl_rewriter_plugin.cc b/storage/tianchi/tse_ddl_rewriter_plugin.cc index 4519838..82978d9 100644 --- a/storage/tianchi/tse_ddl_rewriter_plugin.cc +++ b/storage/tianchi/tse_ddl_rewriter_plugin.cc @@ -1219,7 +1219,7 @@ static int tse_ddl_rewrite(MYSQL_THD thd, mysql_event_class_t event_class, // for non-metadata-normalization's gate test DBUG_EXECUTE_IF("non_metadata_normalization", { check_metadata_switch_result = 1; }); // broadcast SET_OPTION query with subselect item - if (check_metadata_switch_result != 1 && !(need_forward && g_rewrite_sqls.find(sql_cmd) != g_rewrite_sqls.end())) { + if (check_metadata_switch_result != 1 && !(need_forward && sql_cmd == SQLCOM_SET_OPTION)) { return check_metadata_switch_result; } diff --git a/storage/tianchi/tse_mysql_proxy.cc b/storage/tianchi/tse_mysql_proxy.cc index b9977a6..178f674 100644 --- a/storage/tianchi/tse_mysql_proxy.cc +++ b/storage/tianchi/tse_mysql_proxy.cc @@ -369,7 +369,7 @@ __attribute__((visibility("default"))) int tse_ddl_execute_update(uint32_t thd_i } bool is_meta_normalization = IS_METADATA_NORMALIZATION(); - if (is_meta_normalization && g_rewrite_sqls.find(broadcast_req->sql_command) == g_rewrite_sqls.end()) { + if (is_meta_normalization && broadcast_req->sql_command != SQLCOM_SET_OPTION) { return 0; } else if (is_meta_normalization && broadcast_req->sql_command == SQLCOM_SET_OPTION && (broadcast_req->options & TSE_SET_VARIABLE_WITH_SUBSELECT) == 0){ diff --git a/storage/tianchi/tse_util.h b/storage/tianchi/tse_util.h index a2c6adf..3cad7f2 100644 --- a/storage/tianchi/tse_util.h +++ b/storage/tianchi/tse_util.h @@ -22,7 +22,6 @@ #include #include #include -#include #include "sql/table.h" #include "datatype_cnvrtr.h" #include "sql/item_timefunc.h" @@ -32,7 +31,6 @@ using namespace std; static unordered_set mysql_system_db{"information_schema", "mysql", "performance_schema", "sys"}; -static set g_rewrite_sqls {SQLCOM_SET_OPTION, SQLCOM_LOCK_TABLES, SQLCOM_UNLOCK_TABLES}; #define CM_IS_EMPTY_STR(str) (((str) == NULL) || ((str)[0] == 0)) -- Gitee