diff --git a/deps/oblib/src/lib/ob_define.h b/deps/oblib/src/lib/ob_define.h index 3818940ea7..e10e05f4ed 100644 --- a/deps/oblib/src/lib/ob_define.h +++ b/deps/oblib/src/lib/ob_define.h @@ -102,6 +102,7 @@ const int64_t MAX_LONG_OPS_MESSAGE_LENGTH = 512; const int64_t MAX_LS_STATE_LENGTH = 16; 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_OP_TYPE_BUF_LENGTH = 32; diff --git a/deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h b/deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h index 92e566f78b..cbe5b4b8d1 100644 --- a/deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h +++ b/deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h @@ -651,6 +651,12 @@ PCODE_DEF(OB_TX_FREE_ROUTE_CHECK_ALIVE, 0x680) PCODE_DEF(OB_TX_FREE_ROUTE_CHECK_ALIVE_RESP, 0x681) PCODE_DEF(OB_TX_FREE_ROUTE_PUSH_STATE, 0x682) +// lock wait mgr +// PCODE_DEF(OB_LOCK_WAIT_MGR_DST_ENQUEUE, 0x690) +// PCODE_DEF(OB_LOCK_WAIT_MGR_DST_ENQUEUE_RESP, 0x691) +// PCODE_DEF(OB_LOCK_WAIT_MGR_LOCK_RELEASE, 0x692) +// PCODE_DEF(OB_LOCK_WAIT_MGR_WAKE_UP_REMOTE, 0x693) + // transaction PCODE_DEF(OB_TRANS, 0x701) PCODE_DEF(OB_DUMP_MEMTABLE, 0x702) diff --git a/src/observer/ob_srv_xlator_primary.cpp b/src/observer/ob_srv_xlator_primary.cpp index eee8b09768..c533c9d1a7 100644 --- a/src/observer/ob_srv_xlator_primary.cpp +++ b/src/observer/ob_srv_xlator_primary.cpp @@ -168,6 +168,11 @@ void oceanbase::observer::init_srv_xlator_for_transaction(ObSrvRpcXlator *xlator RPC_PROCESSOR(ObTxFreeRoutePushStateP); // for tx state check of 4377 RPC_PROCESSOR(ObAskTxStateFor4377P); + // for lock wait mgr + // RPC_PROCESSOR(ObLockWaitMgrDstEnqueueP); + // RPC_PROCESSOR(ObLockWaitMgrDstEnqueueRespP); + // RPC_PROCESSOR(ObLockWaitMgrLockReleaseP); + // RPC_PROCESSOR(ObLockWaitMgrWakeUpP); } void oceanbase::observer::init_srv_xlator_for_clog(ObSrvRpcXlator *xlator) { 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 55ab975d06..55e33c30fd 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 @@ -203,7 +203,7 @@ int ObAllVirtualLockWaitStat::process_curr_tenant(ObNewRow *&row) // If the waiter is waitting on the row, we need to get the // real holder from the hash_holder, instead of the holder_tx_id // on the ObLockWaitNode. - if (type == 2) { + if (type == 1) { // TODO(yangyifei.yyf): rowkey holder is unstable now, so we use // tmp ret to catch error code here. We we fix it in the future. if (OB_TMP_FAIL(get_rowkey_holder(node_iter_->hash_, holder_tx_id))) { @@ -218,6 +218,39 @@ int ObAllVirtualLockWaitStat::process_curr_tenant(ObNewRow *&row) case HOLDER_SESSION_ID: cur_row_.cells_[i].set_int(node_iter_->holder_sessid_); break; + case LS_ID: { + cur_row_.cells_[i].set_int(0); + break; + } + case ASSOC_SESS_ID: { + cur_row_.cells_[i].set_int(0); + break; + } + case WAIT_TIMEOUT: { + cur_row_.cells_[i].set_int(0); + break; + } + case TX_ACTIVE_TS: { + cur_row_.cells_[i].set_int(0); + break; + } + case NODE_ID: { + cur_row_.cells_[i].set_int(0); + break; + } + case NODE_TYPE: { + cur_row_.cells_[i].set_int(0); + break; + } + case REMTOE_ADDR: { + cur_row_.cells_[i].set_varchar("0.0.0.0"); + cur_row_.cells_[i].set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + break; + } + case IS_PLACEHOLDER: { + cur_row_.cells_[i].set_int(0); + break; + } default: ret = OB_ERR_UNEXPECTED; SERVER_LOG(WARN, "invalid col_id", K(ret), K(col_id)); diff --git a/src/observer/virtual_table/ob_all_virtual_lock_wait_stat.h b/src/observer/virtual_table/ob_all_virtual_lock_wait_stat.h index 6dc75635b0..57304a99b3 100644 --- a/src/observer/virtual_table/ob_all_virtual_lock_wait_stat.h +++ b/src/observer/virtual_table/ob_all_virtual_lock_wait_stat.h @@ -62,12 +62,21 @@ private: TOTAL_UPDATE_CNT, TRANS_ID, HOLDER_TRANS_ID, - HOLDER_SESSION_ID + HOLDER_SESSION_ID, + LS_ID, + ASSOC_SESS_ID, + WAIT_TIMEOUT, + TX_ACTIVE_TS, + NODE_ID, + NODE_TYPE, + REMTOE_ADDR, + IS_PLACEHOLDER, }; rpc::ObLockWaitNode *node_iter_; rpc::ObLockWaitNode cur_node_; char rowkey_[common::MAX_LOCK_ROWKEY_BUF_LENGTH]; char lock_mode_[common::MAX_LOCK_MODE_BUF_LENGTH]; + char remote_addr_[common::MAX_LOCK_REMOTE_ADDR_BUF_LENGTH]; private: DISALLOW_COPY_AND_ASSIGN(ObAllVirtualLockWaitStat); diff --git a/src/share/inner_table/ob_inner_table_schema.12001_12050.cpp b/src/share/inner_table/ob_inner_table_schema.12001_12050.cpp index 1c3aea30fc..28ef082c8b 100644 --- a/src/share/inner_table/ob_inner_table_schema.12001_12050.cpp +++ b/src/share/inner_table/ob_inner_table_schema.12001_12050.cpp @@ -1789,6 +1789,126 @@ int ObInnerTableSchema::all_virtual_lock_wait_stat_schema(ObTableSchema &table_s false, //is_nullable false); //is_autoincrement } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("ls_id", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("assoc_session_id", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("wait_timeout", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tx_active_ts", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("node_id", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("node_type", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("remote_addr", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_INVALID, //column_collation_type + MAX_LOCK_REMOTE_ADDR_BUF_LENGTH, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("is_placeholder", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } if (OB_SUCC(ret)) { table_schema.get_part_option().set_part_num(1); table_schema.set_part_level(PARTITION_LEVEL_ONE); diff --git a/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp b/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp index 44fd866378..a702cad25e 100644 --- a/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp +++ b/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp @@ -1971,6 +1971,126 @@ int ObInnerTableSchema::all_virtual_lock_wait_stat_ora_schema(ObTableSchema &tab false, //is_nullable false); //is_autoincrement } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("LS_ID", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObNumberType, //column_type + CS_TYPE_INVALID, //column_collation_type + 38, //column_length + 38, //column_precision + 0, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("ASSOC_SESSION_ID", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObNumberType, //column_type + CS_TYPE_INVALID, //column_collation_type + 38, //column_length + 38, //column_precision + 0, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("WAIT_TIMEOUT", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObNumberType, //column_type + CS_TYPE_INVALID, //column_collation_type + 38, //column_length + 38, //column_precision + 0, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("TX_ACTIVE_TS", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObNumberType, //column_type + CS_TYPE_INVALID, //column_collation_type + 38, //column_length + 38, //column_precision + 0, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("NODE_ID", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObNumberType, //column_type + CS_TYPE_INVALID, //column_collation_type + 38, //column_length + 38, //column_precision + 0, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("NODE_TYPE", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObNumberType, //column_type + CS_TYPE_INVALID, //column_collation_type + 38, //column_length + 38, //column_precision + 0, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("REMOTE_ADDR", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_UTF8MB4_BIN, //column_collation_type + MAX_LOCK_REMOTE_ADDR_BUF_LENGTH, //column_length + 2, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("IS_PLACEHOLDER", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObNumberType, //column_type + CS_TYPE_INVALID, //column_collation_type + 38, //column_length + 38, //column_precision + 0, //column_scale + false, //is_nullable + false); //is_autoincrement + } if (OB_SUCC(ret)) { table_schema.get_part_option().set_part_num(1); table_schema.set_part_level(PARTITION_LEVEL_ONE); diff --git a/src/share/inner_table/ob_inner_table_schema_def.py b/src/share/inner_table/ob_inner_table_schema_def.py index 5a38fab2b4..1a81fdf41e 100644 --- a/src/share/inner_table/ob_inner_table_schema_def.py +++ b/src/share/inner_table/ob_inner_table_schema_def.py @@ -10219,7 +10219,15 @@ def_table_schema( ('total_update_cnt', 'int'), ('trans_id', 'int'), ('holder_trans_id', 'int'), - ('holder_session_id', 'int') + ('holder_session_id', 'int'), + ('ls_id', 'int'), + ('assoc_session_id', 'int'), + ('wait_timeout', 'int'), + ('tx_active_ts', 'int'), + ('node_id', 'int'), + ('node_type', 'int'), + ('remote_addr', 'varchar:MAX_LOCK_REMOTE_ADDR_BUF_LENGTH'), + ('is_placeholder', 'int') ], partition_columns = ['svr_ip', 'svr_port'], diff --git a/src/share/parameter/ob_parameter_seed.ipp b/src/share/parameter/ob_parameter_seed.ipp index 0b37f5c86d..2f7a19b71d 100644 --- a/src/share/parameter/ob_parameter_seed.ipp +++ b/src/share/parameter/ob_parameter_seed.ipp @@ -1695,6 +1695,9 @@ DEF_BOOL(_enable_protocol_diagnose, OB_CLUSTER_PARAMETER, "True", DEF_BOOL(_enable_transaction_internal_routing, OB_TENANT_PARAMETER, "True", "enable SQLs of transaction routed to any servers in the cluster on demand", ObParameterAttr(Section::TRANS, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); +DEF_BOOL(_enable_wait_remote_lock, OB_TENANT_PARAMETER, "True", + "enable remote execution wait in lock wait mgr when lock conflict occurs", + ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); DEF_STR(_load_tde_encrypt_engine, OB_CLUSTER_PARAMETER, "NONE", "load the engine that meet the security classification requirement to encrypt data. default NONE", ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); diff --git a/src/share/rpc/ob_batch_proxy.h b/src/share/rpc/ob_batch_proxy.h index 290ff5a69c..bc0732a52e 100644 --- a/src/share/rpc/ob_batch_proxy.h +++ b/src/share/rpc/ob_batch_proxy.h @@ -31,24 +31,25 @@ enum { SQL_BATCH_REQ_NODELAY1 = 5, SQL_BATCH_REQ_NODELAY2 = 6, CLOG_BATCH_REQ_NODELAY2 = 7, - BATCH_REQ_TYPE_COUNT = 8 + LOCK_WAIT_MGR_REQ = 8, + BATCH_REQ_TYPE_COUNT = 9 }; inline int64_t get_batch_delay_us(const int batch_type) { - int64_t delay[BATCH_REQ_TYPE_COUNT] = {2 * 1000, 2 * 1000, 500, 0, 0, 0, 0, 0}; + int64_t delay[BATCH_REQ_TYPE_COUNT] = {2 * 1000, 2 * 1000, 500, 0, 0, 0, 0, 0, 2 * 1000}; return (batch_type >= 0 && batch_type < BATCH_REQ_TYPE_COUNT) ? delay[batch_type]: 0; } inline int64_t get_batch_buffer_size(const int batch_type) { - int64_t batch_buffer_size_k[BATCH_REQ_TYPE_COUNT] = {256, 256, 256, 2048, 256, 256, 256, 2048}; + int64_t batch_buffer_size_k[BATCH_REQ_TYPE_COUNT] = {256, 256, 256, 2048, 256, 256, 256, 2048, 256}; return batch_buffer_size_k[batch_type] * 1024; } inline bool is_hp_rpc(const int batch_type) { - static const bool hp_rpc_map[BATCH_REQ_TYPE_COUNT] = {true, true, false, false, false, false, false, false}; + static const bool hp_rpc_map[BATCH_REQ_TYPE_COUNT] = {true, true, false, false, false, false, false, false, false}; return (batch_type >= 0 && batch_type < BATCH_REQ_TYPE_COUNT) ? hp_rpc_map[batch_type] : false; } diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result index 47c97163ee..56bb67f63a 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result @@ -340,6 +340,7 @@ _enable_trace_tablet_leak _enable_transaction_internal_routing _enable_values_table_folding _enable_var_assign_use_das +_enable_wait_remote_lock _endpoint_tenant_mapping _faststack_min_interval _faststack_req_queue_size_threshold 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 358fbb519b..5a30dd5beb 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 @@ -1604,6 +1604,14 @@ total_update_cnt bigint(20) NO NULL trans_id bigint(20) NO NULL holder_trans_id bigint(20) NO NULL holder_session_id bigint(20) NO NULL +ls_id bigint(20) NO NULL +assoc_session_id bigint(20) NO NULL +wait_timeout bigint(20) NO NULL +tx_active_ts bigint(20) NO NULL +node_id bigint(20) NO NULL +node_type bigint(20) NO NULL +remote_addr varchar(64) NO NULL +is_placeholder bigint(20) NO NULL select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_lock_wait_stat; IF(count(*) >= 0, 1, 0) 1 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 30cec4f78e..a9921fc4d5 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 @@ -2101,6 +2101,14 @@ total_update_cnt bigint(20) NO NULL trans_id bigint(20) NO NULL holder_trans_id bigint(20) NO NULL holder_session_id bigint(20) NO NULL +ls_id bigint(20) NO NULL +assoc_session_id bigint(20) NO NULL +wait_timeout bigint(20) NO NULL +tx_active_ts bigint(20) NO NULL +node_id bigint(20) NO NULL +node_type bigint(20) NO NULL +remote_addr varchar(64) NO NULL +is_placeholder bigint(20) NO NULL select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_lock_wait_stat; IF(count(*) >= 0, 1, 0) 1