fix deadcode in ObBLService::get_tenant_max_stale_time_

This commit is contained in:
dimstars
2023-01-05 04:41:57 +00:00
committed by ob-robot
parent 3bf2afff17
commit 9726d0fd36
3 changed files with 13 additions and 23 deletions

View File

@ -65,8 +65,7 @@ TEST_F(TestObBlackListService, black_list_inner_func)
} }
// get max_stale_time_for_weak_consistency // get max_stale_time_for_weak_consistency
uint64_t max_stale_time = 0; int64_t max_stale_time = bl_service.get_tenant_max_stale_time_(bl_key.get_tenant_id());
ASSERT_EQ(OB_SUCCESS, bl_service.get_tenant_max_stale_time_(bl_key.get_tenant_id(), max_stale_time));
LOG_INFO("get_tenant_max_stale_time_ ", K(bl_key), K(max_stale_time)); LOG_INFO("get_tenant_max_stale_time_ ", K(bl_key), K(max_stale_time));
// do blacklist check // do blacklist check

View File

@ -234,8 +234,8 @@ void ObBLService::do_thread_task_(const int64_t begin_tstamp,
int ObBLService::do_black_list_check_(sqlclient::ObMySQLResult *result) int ObBLService::do_black_list_check_(sqlclient::ObMySQLResult *result)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
uint64_t max_stale_time = 0; int64_t max_stale_time = 0;
uint64_t curr_time_ns = static_cast<uint64_t>(ObTimeUtility::current_time_ns()); int64_t curr_time_ns = ObTimeUtility::current_time_ns();
while (OB_SUCC(result->next())) { while (OB_SUCC(result->next())) {
ObBLKey bl_key; ObBLKey bl_key;
@ -244,10 +244,9 @@ int ObBLService::do_black_list_check_(sqlclient::ObMySQLResult *result)
TRANS_LOG(WARN, "get_info_from_result_ fail ", KR(ret), K(result)); TRANS_LOG(WARN, "get_info_from_result_ fail ", KR(ret), K(result));
} else if (LEADER == ls_info.ls_state_) { } else if (LEADER == ls_info.ls_state_) {
// 该日志流是leader,不能加入黑名单 // 该日志流是leader,不能加入黑名单
} else if (OB_FAIL(get_tenant_max_stale_time_(bl_key.get_tenant_id(), max_stale_time))) {
TRANS_LOG(WARN, "get_tenant_max_stale_time_ fail ", KR(ret), K(bl_key));
} else { } else {
uint64_t max_stale_time_ns = max_stale_time * 1000; max_stale_time = get_tenant_max_stale_time_(bl_key.get_tenant_id());
int64_t max_stale_time_ns = max_stale_time * 1000;
if (curr_time_ns > ls_info.weak_read_scn_ + max_stale_time_ns) { if (curr_time_ns > ls_info.weak_read_scn_ + max_stale_time_ns) {
// 时间戳落后,将对应日志流加入黑名单 // 时间戳落后,将对应日志流加入黑名单
if (OB_FAIL(ls_bl_mgr_.update(bl_key, ls_info))) { if (OB_FAIL(ls_bl_mgr_.update(bl_key, ls_info))) {
@ -289,7 +288,7 @@ int ObBLService::get_info_from_result_(sqlclient::ObMySQLResult &result, ObBLKey
int64_t tenant_id = 0; int64_t tenant_id = 0;
int64_t id = ObLSID::INVALID_LS_ID; int64_t id = ObLSID::INVALID_LS_ID;
ObString ls_state_str; ObString ls_state_str;
uint64_t weak_read_scn = 0; uint64_t weak_read_scn_uint = 0;
int64_t migrate_status_int = -1; int64_t migrate_status_int = -1;
(void)GET_COL_IGNORE_NULL(result.get_varchar, "svr_ip", ip); (void)GET_COL_IGNORE_NULL(result.get_varchar, "svr_ip", ip);
@ -297,12 +296,13 @@ int ObBLService::get_info_from_result_(sqlclient::ObMySQLResult &result, ObBLKey
(void)GET_COL_IGNORE_NULL(result.get_int, "tenant_id", tenant_id); (void)GET_COL_IGNORE_NULL(result.get_int, "tenant_id", tenant_id);
(void)GET_COL_IGNORE_NULL(result.get_int, "ls_id", id); (void)GET_COL_IGNORE_NULL(result.get_int, "ls_id", id);
(void)GET_COL_IGNORE_NULL(result.get_varchar, "ls_state", ls_state_str); (void)GET_COL_IGNORE_NULL(result.get_varchar, "ls_state", ls_state_str);
(void)GET_COL_IGNORE_NULL(result.get_uint, "weak_read_scn", weak_read_scn); (void)GET_COL_IGNORE_NULL(result.get_uint, "weak_read_scn", weak_read_scn_uint);
(void)GET_COL_IGNORE_NULL(result.get_int, "migrate_status", migrate_status_int); (void)GET_COL_IGNORE_NULL(result.get_int, "migrate_status", migrate_status_int);
ObLSID ls_id(id); ObLSID ls_id(id);
common::ObAddr server; common::ObAddr server;
ObRole ls_state = INVALID_ROLE; ObRole ls_state = INVALID_ROLE;
int64_t weak_read_scn = static_cast<int64_t>(weak_read_scn_uint);
ObMigrateStatus migrate_status = ObMigrateStatus(migrate_status_int); ObMigrateStatus migrate_status = ObMigrateStatus(migrate_status_int);
if (false == server.set_ip_addr(ip, static_cast<uint32_t>(port))) { if (false == server.set_ip_addr(ip, static_cast<uint32_t>(port))) {
@ -319,18 +319,9 @@ int ObBLService::get_info_from_result_(sqlclient::ObMySQLResult &result, ObBLKey
return ret; return ret;
} }
int ObBLService::get_tenant_max_stale_time_(uint64_t tenant_id, uint64_t &max_stale_time) int64_t ObBLService::get_tenant_max_stale_time_(uint64_t tenant_id)
{ {
int ret = OB_SUCCESS; return ObWeakReadUtil::max_stale_time_for_weak_consistency(tenant_id, ObWeakReadUtil::IGNORE_TENANT_EXIST_WARN);
int64_t max_stale_time_int = ObWeakReadUtil::max_stale_time_for_weak_consistency(tenant_id,
ObWeakReadUtil::IGNORE_TENANT_EXIST_WARN);
if (max_stale_time_int <= 0) {
ret = OB_ERR_UNEXPECTED;
max_stale_time = 0;
} else {
max_stale_time = static_cast<uint64_t>(max_stale_time_int);
}
return ret;
} }
void ObBLService::print_stat_() void ObBLService::print_stat_()

View File

@ -123,7 +123,7 @@ public:
weak_read_scn_(0), weak_read_scn_(0),
migrate_status_(OB_MIGRATE_STATUS_MAX) migrate_status_(OB_MIGRATE_STATUS_MAX)
{} {}
int init(ObRole ls_state, uint64_t weak_read_scn, ObMigrateStatus migrate_status) int init(ObRole ls_state, int64_t weak_read_scn, ObMigrateStatus migrate_status)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (OB_MIGRATE_STATUS_MAX == migrate_status) { if (OB_MIGRATE_STATUS_MAX == migrate_status) {
@ -144,7 +144,7 @@ public:
// 日志流状态(角色):LEADER、FOLLOWER,其他角色对于日志流是没有意义的 // 日志流状态(角色):LEADER、FOLLOWER,其他角色对于日志流是没有意义的
ObRole ls_state_; ObRole ls_state_;
// 弱读时间戳,如果落后超过一定时间就要加入黑名单,单位ns // 弱读时间戳,如果落后超过一定时间就要加入黑名单,单位ns
uint64_t weak_read_scn_; int64_t weak_read_scn_;
// 迁移状态,正在迁移的日志流一定不可读 // 迁移状态,正在迁移的日志流一定不可读
ObMigrateStatus migrate_status_; ObMigrateStatus migrate_status_;
}; };
@ -367,7 +367,7 @@ private:
int do_black_list_check_(sqlclient::ObMySQLResult *result); int do_black_list_check_(sqlclient::ObMySQLResult *result);
int do_clean_up_(); int do_clean_up_();
int get_info_from_result_(sqlclient::ObMySQLResult &result, ObBLKey &bl_key, ObLsInfo &ls_info); int get_info_from_result_(sqlclient::ObMySQLResult &result, ObBLKey &bl_key, ObLsInfo &ls_info);
int get_tenant_max_stale_time_(uint64_t tenant_id, uint64_t &max_stale_time); int64_t get_tenant_max_stale_time_(uint64_t tenant_id);
void print_stat_(); void print_stat_();
private: private: