diff --git a/mittest/simple_server/test_ob_black_list_service.cpp b/mittest/simple_server/test_ob_black_list_service.cpp index 219af97a5b..0e9eb6c807 100644 --- a/mittest/simple_server/test_ob_black_list_service.cpp +++ b/mittest/simple_server/test_ob_black_list_service.cpp @@ -65,8 +65,7 @@ TEST_F(TestObBlackListService, black_list_inner_func) } // get max_stale_time_for_weak_consistency - uint64_t max_stale_time = 0; - ASSERT_EQ(OB_SUCCESS, bl_service.get_tenant_max_stale_time_(bl_key.get_tenant_id(), max_stale_time)); + int64_t max_stale_time = bl_service.get_tenant_max_stale_time_(bl_key.get_tenant_id()); LOG_INFO("get_tenant_max_stale_time_ ", K(bl_key), K(max_stale_time)); // do blacklist check diff --git a/src/storage/tx/wrs/ob_black_list.cpp b/src/storage/tx/wrs/ob_black_list.cpp index dc274a1a59..8b6ec8984d 100644 --- a/src/storage/tx/wrs/ob_black_list.cpp +++ b/src/storage/tx/wrs/ob_black_list.cpp @@ -234,8 +234,8 @@ void ObBLService::do_thread_task_(const int64_t begin_tstamp, int ObBLService::do_black_list_check_(sqlclient::ObMySQLResult *result) { int ret = OB_SUCCESS; - uint64_t max_stale_time = 0; - uint64_t curr_time_ns = static_cast(ObTimeUtility::current_time_ns()); + int64_t max_stale_time = 0; + int64_t curr_time_ns = ObTimeUtility::current_time_ns(); while (OB_SUCC(result->next())) { 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)); } else if (LEADER == ls_info.ls_state_) { // 该日志流是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 { - 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 (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 id = ObLSID::INVALID_LS_ID; ObString ls_state_str; - uint64_t weak_read_scn = 0; + uint64_t weak_read_scn_uint = 0; int64_t migrate_status_int = -1; (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, "ls_id", id); (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); ObLSID ls_id(id); common::ObAddr server; ObRole ls_state = INVALID_ROLE; + int64_t weak_read_scn = static_cast(weak_read_scn_uint); ObMigrateStatus migrate_status = ObMigrateStatus(migrate_status_int); if (false == server.set_ip_addr(ip, static_cast(port))) { @@ -319,18 +319,9 @@ int ObBLService::get_info_from_result_(sqlclient::ObMySQLResult &result, ObBLKey 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; - 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(max_stale_time_int); - } - return ret; + return ObWeakReadUtil::max_stale_time_for_weak_consistency(tenant_id, ObWeakReadUtil::IGNORE_TENANT_EXIST_WARN); } void ObBLService::print_stat_() diff --git a/src/storage/tx/wrs/ob_black_list.h b/src/storage/tx/wrs/ob_black_list.h index c80d68d55a..57b550164e 100644 --- a/src/storage/tx/wrs/ob_black_list.h +++ b/src/storage/tx/wrs/ob_black_list.h @@ -123,7 +123,7 @@ public: weak_read_scn_(0), 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; if (OB_MIGRATE_STATUS_MAX == migrate_status) { @@ -144,7 +144,7 @@ public: // 日志流状态(角色):LEADER、FOLLOWER,其他角色对于日志流是没有意义的 ObRole ls_state_; // 弱读时间戳,如果落后超过一定时间就要加入黑名单,单位ns - uint64_t weak_read_scn_; + int64_t weak_read_scn_; // 迁移状态,正在迁移的日志流一定不可读 ObMigrateStatus migrate_status_; }; @@ -367,7 +367,7 @@ private: int do_black_list_check_(sqlclient::ObMySQLResult *result); int do_clean_up_(); 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_(); private: