lock wait mgr refactor compatibility placeholder

This commit is contained in:
felix-w15
2024-07-26 09:59:10 +00:00
committed by ob-robot
parent 489f709899
commit 2746e10229
13 changed files with 330 additions and 7 deletions

View File

@ -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_LS_STATE_LENGTH = 16;
const int64_t MAX_LOCK_ID_BUF_LENGTH = 64; const int64_t MAX_LOCK_ID_BUF_LENGTH = 64;
const int64_t MAX_LOCK_ROWKEY_BUF_LENGTH = 512; 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_MODE_BUF_LENGTH = 8;
const int64_t MAX_LOCK_OBJ_TYPE_BUF_LENGTH = 16; const int64_t MAX_LOCK_OBJ_TYPE_BUF_LENGTH = 16;
const int64_t MAX_LOCK_OP_TYPE_BUF_LENGTH = 32; const int64_t MAX_LOCK_OP_TYPE_BUF_LENGTH = 32;

View File

@ -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_CHECK_ALIVE_RESP, 0x681)
PCODE_DEF(OB_TX_FREE_ROUTE_PUSH_STATE, 0x682) 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 // transaction
PCODE_DEF(OB_TRANS, 0x701) PCODE_DEF(OB_TRANS, 0x701)
PCODE_DEF(OB_DUMP_MEMTABLE, 0x702) PCODE_DEF(OB_DUMP_MEMTABLE, 0x702)

View File

@ -168,6 +168,11 @@ void oceanbase::observer::init_srv_xlator_for_transaction(ObSrvRpcXlator *xlator
RPC_PROCESSOR(ObTxFreeRoutePushStateP); RPC_PROCESSOR(ObTxFreeRoutePushStateP);
// for tx state check of 4377 // for tx state check of 4377
RPC_PROCESSOR(ObAskTxStateFor4377P); 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) { void oceanbase::observer::init_srv_xlator_for_clog(ObSrvRpcXlator *xlator) {

View File

@ -203,7 +203,7 @@ int ObAllVirtualLockWaitStat::process_curr_tenant(ObNewRow *&row)
// If the waiter is waitting on the row, we need to get the // 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 // real holder from the hash_holder, instead of the holder_tx_id
// on the ObLockWaitNode. // on the ObLockWaitNode.
if (type == 2) { if (type == 1) {
// TODO(yangyifei.yyf): rowkey holder is unstable now, so we use // 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. // 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))) { 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: case HOLDER_SESSION_ID:
cur_row_.cells_[i].set_int(node_iter_->holder_sessid_); cur_row_.cells_[i].set_int(node_iter_->holder_sessid_);
break; 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: default:
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "invalid col_id", K(ret), K(col_id)); SERVER_LOG(WARN, "invalid col_id", K(ret), K(col_id));

View File

@ -62,12 +62,21 @@ private:
TOTAL_UPDATE_CNT, TOTAL_UPDATE_CNT,
TRANS_ID, TRANS_ID,
HOLDER_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 *node_iter_;
rpc::ObLockWaitNode cur_node_; rpc::ObLockWaitNode cur_node_;
char rowkey_[common::MAX_LOCK_ROWKEY_BUF_LENGTH]; char rowkey_[common::MAX_LOCK_ROWKEY_BUF_LENGTH];
char lock_mode_[common::MAX_LOCK_MODE_BUF_LENGTH]; char lock_mode_[common::MAX_LOCK_MODE_BUF_LENGTH];
char remote_addr_[common::MAX_LOCK_REMOTE_ADDR_BUF_LENGTH];
private: private:
DISALLOW_COPY_AND_ASSIGN(ObAllVirtualLockWaitStat); DISALLOW_COPY_AND_ASSIGN(ObAllVirtualLockWaitStat);

View File

@ -1789,6 +1789,126 @@ int ObInnerTableSchema::all_virtual_lock_wait_stat_schema(ObTableSchema &table_s
false, //is_nullable false, //is_nullable
false); //is_autoincrement 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)) { if (OB_SUCC(ret)) {
table_schema.get_part_option().set_part_num(1); table_schema.get_part_option().set_part_num(1);
table_schema.set_part_level(PARTITION_LEVEL_ONE); table_schema.set_part_level(PARTITION_LEVEL_ONE);

View File

@ -1971,6 +1971,126 @@ int ObInnerTableSchema::all_virtual_lock_wait_stat_ora_schema(ObTableSchema &tab
false, //is_nullable false, //is_nullable
false); //is_autoincrement 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)) { if (OB_SUCC(ret)) {
table_schema.get_part_option().set_part_num(1); table_schema.get_part_option().set_part_num(1);
table_schema.set_part_level(PARTITION_LEVEL_ONE); table_schema.set_part_level(PARTITION_LEVEL_ONE);

View File

@ -10219,7 +10219,15 @@ def_table_schema(
('total_update_cnt', 'int'), ('total_update_cnt', 'int'),
('trans_id', 'int'), ('trans_id', 'int'),
('holder_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'], partition_columns = ['svr_ip', 'svr_port'],

View File

@ -1695,6 +1695,9 @@ DEF_BOOL(_enable_protocol_diagnose, OB_CLUSTER_PARAMETER, "True",
DEF_BOOL(_enable_transaction_internal_routing, OB_TENANT_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", "enable SQLs of transaction routed to any servers in the cluster on demand",
ObParameterAttr(Section::TRANS, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); 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", DEF_STR(_load_tde_encrypt_engine, OB_CLUSTER_PARAMETER, "NONE",
"load the engine that meet the security classification requirement to encrypt data. default NONE", "load the engine that meet the security classification requirement to encrypt data. default NONE",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));

View File

@ -31,24 +31,25 @@ enum {
SQL_BATCH_REQ_NODELAY1 = 5, SQL_BATCH_REQ_NODELAY1 = 5,
SQL_BATCH_REQ_NODELAY2 = 6, SQL_BATCH_REQ_NODELAY2 = 6,
CLOG_BATCH_REQ_NODELAY2 = 7, 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) 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; 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) 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; return batch_buffer_size_k[batch_type] * 1024;
} }
inline bool is_hp_rpc(const int batch_type) 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; return (batch_type >= 0 && batch_type < BATCH_REQ_TYPE_COUNT) ? hp_rpc_map[batch_type] : false;
} }

View File

@ -340,6 +340,7 @@ _enable_trace_tablet_leak
_enable_transaction_internal_routing _enable_transaction_internal_routing
_enable_values_table_folding _enable_values_table_folding
_enable_var_assign_use_das _enable_var_assign_use_das
_enable_wait_remote_lock
_endpoint_tenant_mapping _endpoint_tenant_mapping
_faststack_min_interval _faststack_min_interval
_faststack_req_queue_size_threshold _faststack_req_queue_size_threshold

View File

@ -1604,6 +1604,14 @@ total_update_cnt bigint(20) NO NULL
trans_id bigint(20) NO NULL trans_id bigint(20) NO NULL
holder_trans_id bigint(20) NO NULL holder_trans_id bigint(20) NO NULL
holder_session_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; select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_lock_wait_stat;
IF(count(*) >= 0, 1, 0) IF(count(*) >= 0, 1, 0)
1 1

View File

@ -2101,6 +2101,14 @@ total_update_cnt bigint(20) NO NULL
trans_id bigint(20) NO NULL trans_id bigint(20) NO NULL
holder_trans_id bigint(20) NO NULL holder_trans_id bigint(20) NO NULL
holder_session_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; select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_lock_wait_stat;
IF(count(*) >= 0, 1, 0) IF(count(*) >= 0, 1, 0)
1 1