Fix all_virtual_ls_info bug
This commit is contained in:
@ -110,8 +110,8 @@ STAT_EVENT_ADD_DEF(SQL_PS_EXECUTE_COUNT, "ps execute count", ObStatClassIds::SQL
|
||||
STAT_EVENT_ADD_DEF(SQL_PS_CLOSE_COUNT, "ps close count", ObStatClassIds::SQL, "ps close count", 40023, false, true)
|
||||
STAT_EVENT_ADD_DEF(SQL_PS_CLOSE_TIME, "ps close time", ObStatClassIds::SQL, "ps close time", 40024, false, true)
|
||||
|
||||
STAT_EVENT_ADD_DEF(SQL_OPEN_CURSORS_CURRENT, "opened cursors current", ObStatClassIds::SQL, "opened cursors current", 40030, false, true)
|
||||
STAT_EVENT_ADD_DEF(SQL_OPEN_CURSORS_CUMULATIVE, "opened cursors cumulative", ObStatClassIds::SQL, "opened cursors cumulative", 40031, false, true)
|
||||
STAT_EVENT_ADD_DEF(SQL_OPEN_CURSORS_CURRENT, "opened cursors current", ObStatClassIds::SQL, "opened cursors current", 40030, true, true)
|
||||
STAT_EVENT_ADD_DEF(SQL_OPEN_CURSORS_CUMULATIVE, "opened cursors cumulative", ObStatClassIds::SQL, "opened cursors cumulative", 40031, true, true)
|
||||
|
||||
STAT_EVENT_ADD_DEF(SQL_LOCAL_COUNT, "sql local count", ObStatClassIds::SQL, "sql local count", 40010, false, true)
|
||||
STAT_EVENT_ADD_DEF(SQL_REMOTE_COUNT, "sql remote count", ObStatClassIds::SQL, "sql remote count", 40011, false, true)
|
||||
|
||||
@ -186,18 +186,14 @@ int ObAllVirtualLSInfo::process_curr_tenant(ObNewRow *&row)
|
||||
cur_row_.cells_[i].set_int(ls_info.rebuild_seq_);
|
||||
break;
|
||||
case OB_APP_MIN_COLUMN_ID + 13:
|
||||
// clog_checkpoint_ts
|
||||
cur_row_.cells_[i].set_uint64(!ls_info.tablet_change_checkpoint_scn_.is_valid() ? 0 : ls_info.tablet_change_checkpoint_scn_.get_val_for_tx());
|
||||
break;
|
||||
case OB_APP_MIN_COLUMN_ID + 14:
|
||||
// tablet_change_checkpoint_scn
|
||||
cur_row_.cells_[i].set_uint64(!ls_info.tablet_change_checkpoint_scn_.is_valid() ? 0 : ls_info.tablet_change_checkpoint_scn_.get_val_for_inner_table_field());
|
||||
break;
|
||||
case OB_APP_MIN_COLUMN_ID + 15:
|
||||
case OB_APP_MIN_COLUMN_ID + 14:
|
||||
// transfer_scn
|
||||
cur_row_.cells_[i].set_uint64(!ls_info.transfer_scn_.is_valid() ? 0 : ls_info.transfer_scn_.get_val_for_inner_table_field());
|
||||
break;
|
||||
case OB_APP_MIN_COLUMN_ID + 16:
|
||||
case OB_APP_MIN_COLUMN_ID + 15:
|
||||
// tx blocked
|
||||
cur_row_.cells_[i].set_int(ls_info.tx_blocked_);
|
||||
break;
|
||||
|
||||
@ -9528,9 +9528,9 @@ int ObInnerTableSchema::all_virtual_ls_info_schema(ObTableSchema &table_schema)
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObUInt64Type, //column_type
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(uint64_t), //column_length
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
|
||||
@ -10835,7 +10835,7 @@ def_table_schema(
|
||||
('rebuild_seq', 'int'),
|
||||
('tablet_change_checkpoint_scn', 'uint'),
|
||||
('transfer_scn', 'uint'),
|
||||
('tx_blocked', 'uint'),
|
||||
('tx_blocked', 'int'),
|
||||
],
|
||||
partition_columns = ['svr_ip', 'svr_port'],
|
||||
vtable_route_policy = 'distributed',
|
||||
|
||||
@ -295,9 +295,8 @@ int ObBLService::get_info_from_result_(sqlclient::ObMySQLResult &result, ObBLKey
|
||||
int64_t ls_role = -1;
|
||||
int64_t weak_read_scn = 0;
|
||||
int64_t migrate_status_int = -1;
|
||||
int64_t tx_blocked = 0;
|
||||
int64_t tx_blocked = -1;
|
||||
common::number::ObNumber weak_read_number;
|
||||
common::number::ObNumber tx_blocked_number;
|
||||
|
||||
(void)GET_COL_IGNORE_NULL(result.get_varchar, "svr_ip", ip);
|
||||
(void)GET_COL_IGNORE_NULL(result.get_int, "svr_port", port);
|
||||
@ -306,7 +305,7 @@ int ObBLService::get_info_from_result_(sqlclient::ObMySQLResult &result, ObBLKey
|
||||
(void)GET_COL_IGNORE_NULL(result.get_int, "role", ls_role);
|
||||
(void)GET_COL_IGNORE_NULL(result.get_number, "weak_read_scn", weak_read_number);
|
||||
(void)GET_COL_IGNORE_NULL(result.get_int, "migrate_status", migrate_status_int);
|
||||
(void)GET_COL_IGNORE_NULL(result.get_number, "tx_blocked", tx_blocked_number);
|
||||
(void)GET_COL_IGNORE_NULL(result.get_int, "tx_blocked", tx_blocked);
|
||||
|
||||
ObLSID ls_id(id);
|
||||
common::ObAddr server;
|
||||
@ -317,15 +316,20 @@ int ObBLService::get_info_from_result_(sqlclient::ObMySQLResult &result, ObBLKey
|
||||
TRANS_LOG(WARN, "invalid server address", K(ip), K(port));
|
||||
} else if (OB_FAIL(weak_read_number.cast_to_int64(weak_read_scn))) {
|
||||
TRANS_LOG(WARN, "failed to cast int", K(ret), K(weak_read_number));
|
||||
} else if (OB_FAIL(tx_blocked_number.cast_to_int64(tx_blocked))) {
|
||||
TRANS_LOG(WARN, "failed to cast int", K(ret), K(tx_blocked_number));
|
||||
} else if (OB_FAIL(bl_key.init(server, tenant_id, ls_id))) {
|
||||
TRANS_LOG(WARN, "bl_key init fail", K(server), K(tenant_id), K(ls_id));
|
||||
} else if (OB_FAIL(ls_info.init(ls_role, weak_read_scn, migrate_status, tx_blocked))) {
|
||||
} else if (OB_FAIL(ls_info.init(ls_role, weak_read_scn, migrate_status, (1 == tx_blocked) ? true : false))) {
|
||||
TRANS_LOG(WARN, "ls_info init fail", K(ls_role), K(weak_read_scn), K(migrate_status), K(tx_blocked));
|
||||
}
|
||||
if (tx_blocked) {
|
||||
TRANS_LOG(INFO, "current ls is blocked, need to put blacklist", K(bl_key), K(ls_info));
|
||||
if (OB_SUCC(ret)) {
|
||||
if (1 == tx_blocked) {
|
||||
TRANS_LOG(INFO, "current ls is blocked, need to put blacklist", K(bl_key), K(ls_info));
|
||||
} else if (0 != tx_blocked) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
TRANS_LOG(ERROR, "unexpected tx blocked", K(ret), K(tx_blocked), K(bl_key), K(ls_info));
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#define BLACK_LIST_MAX_FAIL_COUNT 3
|
||||
|
||||
// 查询 __all_virtual_ls_info 的语句,设置了2s超时时间
|
||||
// select /*+query_timeout(2000000)*/ a.svr_ip, a.svr_port, a.tenant_id, a.ls_id, a.role, nvl(b.weak_read_scn, 1) as weak_read_scn, nvl(b.migrate_status, 0) as migrate_status, nvl(b.tx_blocked, 0) as tx_blocked from oceanbase.__all_virtual_ls_meta_table a left join oceanbase.__all_virtual_ls_info b on a.svr_ip = b.svr_ip and a.svr_port = b.svr_port and a.tenant_id = b.tenant_id and a.ls_id = b.ls_id;
|
||||
#define BLACK_LIST_SELECT_LS_INFO_STMT \
|
||||
"select /*+query_timeout(2000000)*/ a.svr_ip, a.svr_port, a.tenant_id, a.ls_id, a.role, \
|
||||
nvl(b.weak_read_scn, 1) as weak_read_scn, nvl(b.migrate_status, 0) as migrate_status, nvl(b.tx_blocked, 0) as tx_blocked \
|
||||
@ -148,7 +149,7 @@ public:
|
||||
{
|
||||
return OB_MIGRATE_STATUS_MAX != migrate_status_;
|
||||
}
|
||||
TO_STRING_KV(K_(ls_state), K_(weak_read_scn), K_(migrate_status));
|
||||
TO_STRING_KV(K_(ls_state), K_(weak_read_scn), K_(migrate_status), K_(tx_blocked));
|
||||
|
||||
// 日志流状态(角色):LEADER(1)、FOLLOWER(2),其他角色对于日志流是没有意义的
|
||||
int64_t ls_state_;
|
||||
|
||||
@ -103,8 +103,8 @@ int ObLSWRSHandler::generate_ls_weak_read_snapshot_version(ObLS &ls,
|
||||
STORAGE_LOG(DEBUG, "fail to generate weak read timestamp", KR(ret), K(max_stale_time));
|
||||
need_skip = true;
|
||||
ret = OB_SUCCESS;
|
||||
} else if (OB_TS_MGR.get_gts(MTL_ID(), NULL, gts_scn)) {
|
||||
TRANS_LOG(WARN, "get gts scn error", K(max_stale_time), K(*this));
|
||||
} else if (OB_FAIL(OB_TS_MGR.get_gts(MTL_ID(), NULL, gts_scn))) {
|
||||
TRANS_LOG(WARN, "get gts scn error", K(ret), K(max_stale_time), K(*this));
|
||||
} else if (OB_FAIL(ls.get_migration_status(status))
|
||||
|| ObMigrationStatus::OB_MIGRATION_STATUS_NONE == status ) {
|
||||
// check the weak read timestamp of the migrated ls
|
||||
|
||||
Reference in New Issue
Block a user