[OB_LOCKS] fix the compatibility problem about __all_virtual_lock_wait_stat table

This commit is contained in:
obdev 2024-09-20 08:32:57 +00:00 committed by ob-robot
parent a5d1780574
commit 97fc5b6833
4 changed files with 41 additions and 3 deletions

View File

@ -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;

View File

@ -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: {

View File

@ -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;

View File

@ -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;