From 97fc5b68333c641c8aad807223541f666502ca61 Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 20 Sep 2024 08:32:57 +0000 Subject: [PATCH] [OB_LOCKS] fix the compatibility problem about __all_virtual_lock_wait_stat table --- deps/oblib/src/lib/ob_define.h | 2 +- .../ob_all_virtual_lock_wait_stat.cpp | 38 +++++++++++++++++++ .../mysql/desc_virtual_table_in_mysql.result | 2 +- .../r/mysql/desc_virtual_table_in_sys.result | 2 +- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/deps/oblib/src/lib/ob_define.h b/deps/oblib/src/lib/ob_define.h index 65812bb57..87f7a13cc 100644 --- a/deps/oblib/src/lib/ob_define.h +++ b/deps/oblib/src/lib/ob_define.h @@ -104,7 +104,7 @@ const int64_t MAX_LOCK_ID_BUF_LENGTH = 64; const int64_t MAX_LOCK_ROWKEY_BUF_LENGTH = 512; const int64_t MAX_LOCK_REMOTE_ADDR_BUF_LENGTH = 64; const int64_t MAX_LOCK_MODE_BUF_LENGTH = 8; -const int64_t MAX_LOCK_OBJ_TYPE_BUF_LENGTH = 16; +const int64_t MAX_LOCK_OBJ_TYPE_BUF_LENGTH = 32; const int64_t MAX_LOCK_OP_TYPE_BUF_LENGTH = 32; const int64_t MAX_LOCK_OP_STATUS_BUF_LENGTH = 16; const int64_t MAX_LOCK_OP_EXTRA_INFO_LENGTH = 256; diff --git a/src/observer/virtual_table/ob_all_virtual_lock_wait_stat.cpp b/src/observer/virtual_table/ob_all_virtual_lock_wait_stat.cpp index 55e33c30f..1ba85ed2b 100644 --- a/src/observer/virtual_table/ob_all_virtual_lock_wait_stat.cpp +++ b/src/observer/virtual_table/ob_all_virtual_lock_wait_stat.cpp @@ -79,8 +79,46 @@ int ObAllVirtualLockWaitStat::process_curr_tenant(ObNewRow *&row) get_lock_type(node_iter_->hash_, type); const int64_t col_count = output_column_ids_.count(); ObString ipstr; + + // resolve compatibility problem + const int column_id_fix_offset = BLOCK_SESSION_ID; + ObString column_name; + bool exist = false; + bool need_align = false; + if (OB_ISNULL(table_schema_)) { + ret = OB_ERR_UNEXPECTED; + SERVER_LOG(ERROR, "table_schema of all_virtual_lock_wait_stat is NULL", K(ret)); + } else { + table_schema_->get_column_name_by_column_id(column_id_fix_offset, column_name, exist); + if (!exist) { + // no need align + } else if (column_name == "holder_session_id" || column_name == "HOLDER_SESSION_ID") { + /* + * ... + * | session_id | + * | holder_session_id | <---- is here in the first version of 4.3.2 + * | block_session_id | + * ... + * + * ... + * | trans_id | + * | holder_trans_id | + * | holder_session_id | <---- is here in later version + * ... + * */ + need_align = true; + } + } + for (int64_t i = 0; OB_SUCC(ret) && i < col_count; ++i) { uint64_t col_id = output_column_ids_.at(i); + if (need_align) { + if (col_id > column_id_fix_offset) { + col_id -= 1; + } else if (col_id == column_id_fix_offset) { + col_id = HOLDER_SESSION_ID; + } + } switch (col_id) { // svr_ip case SVR_IP: { diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result index 684ec87a2..f98049837 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result @@ -2928,7 +2928,7 @@ create_timestamp bigint(20) NO NULL create_schema_version bigint(20) NO NULL extra_info varchar(256) NO NULL time_after_create bigint(20) NO NULL -obj_type varchar(16) NO NULL +obj_type varchar(32) NO NULL obj_id bigint(20) NO NULL owner_type bigint(20) NO NULL select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_obj_lock; diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result index 0cc96b7df..370f8ef49 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result @@ -6546,7 +6546,7 @@ create_timestamp bigint(20) NO NULL create_schema_version bigint(20) NO NULL extra_info varchar(256) NO NULL time_after_create bigint(20) NO NULL -obj_type varchar(16) NO NULL +obj_type varchar(32) NO NULL obj_id bigint(20) NO NULL owner_type bigint(20) NO NULL select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_obj_lock;