to avoid use get_tenant_info
This commit is contained in:
@ -29,7 +29,7 @@
|
||||
#include "share/rc/ob_tenant_base.h"
|
||||
#include "share/ls/ob_ls_life_manager.h"
|
||||
#include "storage/tx_storage/ob_ls_handle.h"
|
||||
#include "rootserver/ob_tenant_recovery_reportor.h" // ObTenantRecoveryReportor
|
||||
#include "rootserver/ob_tenant_info_loader.h" // ObTenantInfoLoader
|
||||
#include "share/ob_occam_time_guard.h"
|
||||
|
||||
namespace oceanbase
|
||||
@ -642,7 +642,19 @@ void ObGCHandler::try_check_and_set_wait_gc_(ObGarbageCollector::LSStatus &ls_st
|
||||
|
||||
int ObGCHandler::get_tenant_readable_scn_(SCN &readable_scn)
|
||||
{
|
||||
return MTL(rootserver::ObTenantRecoveryReportor *)->get_tenant_readable_scn(readable_scn);
|
||||
int ret = OB_SUCCESS;
|
||||
rootserver::ObTenantInfoLoader *tenant_info_loader = MTL(rootserver::ObTenantInfoLoader*);
|
||||
|
||||
if (OB_ISNULL(tenant_info_loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
CLOG_LOG(WARN, "mtl pointer is null", KR(ret), KP(tenant_info_loader));
|
||||
} else if (OB_FAIL(tenant_info_loader->get_readable_scn(readable_scn))) {
|
||||
CLOG_LOG(WARN, "get readable_scn failed", KR(ret));
|
||||
} else if (OB_UNLIKELY(! readable_scn.is_valid())) {
|
||||
ret = OB_EAGAIN;
|
||||
CLOG_LOG(WARN, "readable_scn not valid", KR(ret), K(readable_scn));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 由于日志流GC导致的归档日志不完整是无法被归档检查出来的异常, 因此需要保证GC与归档状态互斥;
|
||||
|
@ -152,8 +152,8 @@ int ObCreateStandbyFromNetActor::finish_restore_if_possible_()
|
||||
arg.exec_tenant_id_ = OB_SYS_TENANT_ID;
|
||||
arg.tenant_id_ = tenant_id_;
|
||||
obrpc::ObCommonRpcProxy *rs_rpc_proxy = GCTX.rs_rpc_proxy_;
|
||||
ObAllTenantInfo tenant_info;
|
||||
SCN min_user_ls_create_scn = SCN::base_scn();
|
||||
SCN readable_scn = SCN::base_scn();
|
||||
|
||||
if (OB_ISNULL(rs_rpc_proxy)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -177,11 +177,11 @@ int ObCreateStandbyFromNetActor::finish_restore_if_possible_()
|
||||
} else if (is_dropped) {
|
||||
ret = OB_TENANT_HAS_BEEN_DROPPED;
|
||||
LOG_WARN("tenant has been dropped", KR(ret), K_(tenant_id));
|
||||
} else if (OB_FAIL(tenant_info_loader->get_tenant_info(tenant_info))) {
|
||||
WSTAT("failed to get tenant info", KR(ret));
|
||||
} else if (tenant_info.get_standby_scn() >= min_user_ls_create_scn) {
|
||||
} else if (OB_FAIL(tenant_info_loader->get_readable_scn(readable_scn))) {
|
||||
WSTAT("failed to get readable_scn", KR(ret));
|
||||
} else if (readable_scn >= min_user_ls_create_scn) {
|
||||
retry_cnt_after_sync_user_ls++;
|
||||
ISTAT("tenant readable scn can read inner table", K(tenant_info), K(min_user_ls_create_scn),
|
||||
ISTAT("tenant readable scn can read inner table", K(readable_scn), K(min_user_ls_create_scn),
|
||||
K(retry_cnt_after_sync_user_ls));
|
||||
|
||||
bool is_refreshed = false;
|
||||
@ -207,7 +207,7 @@ int ObCreateStandbyFromNetActor::finish_restore_if_possible_()
|
||||
}
|
||||
}
|
||||
|
||||
ISTAT("finish_restore_if_possible", K(ret), K_(tenant_id), K(min_user_ls_create_scn), K(arg), K(tenant_info));
|
||||
ISTAT("finish_restore_if_possible", K(ret), K_(tenant_id), K(min_user_ls_create_scn), K(arg), K(readable_scn));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ int ObLSRecoveryStatHandler::increase_ls_replica_readable_scn_(SCN &readable_scn
|
||||
common::ObRole second_role;
|
||||
logservice::ObLogService *ls_svr = MTL(logservice::ObLogService*);
|
||||
rootserver::ObTenantInfoLoader *tenant_info_loader = MTL(rootserver::ObTenantInfoLoader*);
|
||||
share::ObAllTenantInfo tenant_info;
|
||||
SCN replayable_scn = SCN::base_scn();
|
||||
palf::PalfHandleGuard palf_handle_guard;
|
||||
|
||||
if (OB_FAIL(check_inner_stat_())) {
|
||||
@ -118,8 +118,8 @@ int ObLSRecoveryStatHandler::increase_ls_replica_readable_scn_(SCN &readable_scn
|
||||
} else if (OB_FAIL(ls_svr->open_palf(ls_->get_ls_id(), palf_handle_guard))) {
|
||||
LOG_WARN("failed to open palf", KR(ret), K_(ls));
|
||||
// scn get order: read_scn before replayable_scn before sync_scn
|
||||
} else if (OB_FAIL(tenant_info_loader->get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("failed to get_tenant_info", KR(ret));
|
||||
} else if (OB_FAIL(tenant_info_loader->get_replayable_scn(replayable_scn))) {
|
||||
LOG_WARN("failed to get replayable_scn", KR(ret));
|
||||
} else if (OB_FAIL(palf_handle_guard.get_end_scn(sync_scn))) {
|
||||
LOG_WARN("failed to get end ts", KR(ret), K_(ls));
|
||||
} else if (OB_FAIL(ls_svr->get_palf_role(ls_->get_ls_id(), second_role, second_proposal_id))) {
|
||||
@ -130,13 +130,13 @@ int ObLSRecoveryStatHandler::increase_ls_replica_readable_scn_(SCN &readable_scn
|
||||
LOG_WARN("not leader", KR(ret), K(first_proposal_id), K(second_proposal_id), K(first_role),
|
||||
K(second_role), KPC_(ls));
|
||||
} else {
|
||||
if (sync_scn < tenant_info.get_replayable_scn() && readable_scn == sync_scn
|
||||
&& sync_scn.is_valid_and_not_min() && tenant_info.get_replayable_scn().is_valid_and_not_min()
|
||||
if (sync_scn < replayable_scn && readable_scn == sync_scn
|
||||
&& sync_scn.is_valid_and_not_min() && replayable_scn.is_valid_and_not_min()
|
||||
&& readable_scn.is_valid_and_not_min()) {
|
||||
// two scenarios
|
||||
// 1. when sync scn is pushed forward in switchover
|
||||
// 2. wait offline LS
|
||||
sync_scn = readable_scn = tenant_info.get_replayable_scn();
|
||||
sync_scn = readable_scn = replayable_scn;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2165,13 +2165,7 @@ void ObPrimaryLSService::do_work()
|
||||
LOG_WARN("failed to drop tenant", KR(ret), KR(tmp_ret), K(user_tenant_id));
|
||||
}
|
||||
MTL_SWITCH(user_tenant_id) {
|
||||
ObTenantInfoLoader *tenant_info_loader = MTL(ObTenantInfoLoader*);
|
||||
if (OB_ISNULL(tenant_info_loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("tenant report is null", KR(ret), K(tenant_id_));
|
||||
} else if (OB_FAIL(tenant_info_loader->get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("failed to get tenant info", KR(ret));
|
||||
} else if (!tenant_info.is_primary()) {
|
||||
if (!MTL_IS_PRIMARY_TENANT()) {
|
||||
//standby and restore
|
||||
idle_time_us = 100 * 1000L;
|
||||
}
|
||||
|
@ -98,8 +98,8 @@ int ObStandbySchemaRefreshTrigger::check_inner_stat_()
|
||||
int ObStandbySchemaRefreshTrigger::submit_tenant_refresh_schema_task_()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObAllTenantInfo tenant_info;
|
||||
rootserver::ObTenantInfoLoader *tenant_info_loader = MTL(rootserver::ObTenantInfoLoader*);
|
||||
bool is_standby_normal_status = false;
|
||||
|
||||
if (OB_FAIL(check_inner_stat_())) {
|
||||
WSTAT("error unexpected", KR(ret), K(tenant_id_), KP(sql_proxy_));
|
||||
@ -109,9 +109,9 @@ int ObStandbySchemaRefreshTrigger::submit_tenant_refresh_schema_task_()
|
||||
} else if (OB_ISNULL(GCTX.ob_service_) || OB_ISNULL(GCTX.schema_service_) || OB_ISNULL(sql_proxy_) || OB_ISNULL(tenant_info_loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("pointer is null", KR(ret), KP(GCTX.ob_service_), KP(GCTX.schema_service_), KP(sql_proxy_), KP(tenant_info_loader));
|
||||
} else if (OB_FAIL(tenant_info_loader->get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("fail to get tenant info", KR(ret), K_(tenant_id));
|
||||
} else if (tenant_info.is_standby() && tenant_info.is_normal_status()) {
|
||||
} else if (OB_FAIL(tenant_info_loader->check_is_standby_normal_status(is_standby_normal_status))) {
|
||||
LOG_WARN("fail to get tenant status", KR(ret), K_(tenant_id));
|
||||
} else if (is_standby_normal_status) {
|
||||
ObRefreshSchemaStatus schema_status;
|
||||
ObSchemaStatusProxy *schema_status_proxy = GCTX.schema_status_proxy_;
|
||||
if (OB_ISNULL(schema_status_proxy)) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "rootserver/ob_tenant_info_loader.h"
|
||||
#include "rootserver/ob_rs_async_rpc_proxy.h"
|
||||
#include "logservice/ob_log_service.h" // ObLogService
|
||||
#include "storage/tx/ob_ts_mgr.h" // OB_TS_MGR
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -398,14 +399,93 @@ int ObTenantInfoLoader::get_valid_sts_after(const int64_t specified_time_us, sha
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTenantInfoLoader::get_readable_scn(share::SCN &readable_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
readable_scn.set_min();
|
||||
|
||||
if (OB_FAIL(OB_TS_MGR.get_gts(MTL_ID(), nullptr, readable_scn))) {
|
||||
LOG_WARN("failed to get gts as readable_scn", KR(ret));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTenantInfoLoader::check_is_standby_normal_status(bool &is_standby_normal_status)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_standby_normal_status = false;
|
||||
|
||||
if (OB_SYS_TENANT_ID == MTL_ID() || is_meta_tenant(MTL_ID())) {
|
||||
is_standby_normal_status = false;
|
||||
} else {
|
||||
// user tenant
|
||||
share::ObAllTenantInfo tenant_info;
|
||||
if (OB_FAIL(tenant_info_cache_.get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("failed to get tenant info", KR(ret));
|
||||
} else {
|
||||
is_standby_normal_status = tenant_info.is_standby() && tenant_info.is_normal_status();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTenantInfoLoader::check_is_primary_normal_status(bool &is_primary_normal_status)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_primary_normal_status = false;
|
||||
|
||||
if (OB_SYS_TENANT_ID == MTL_ID() || is_meta_tenant(MTL_ID())) {
|
||||
is_primary_normal_status = true;
|
||||
} else {
|
||||
// user tenant
|
||||
share::ObAllTenantInfo tenant_info;
|
||||
if (OB_FAIL(tenant_info_cache_.get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("failed to get tenant info", KR(ret));
|
||||
} else {
|
||||
is_primary_normal_status = tenant_info.is_primary() && tenant_info.is_normal_status();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTenantInfoLoader::get_replayable_scn(share::SCN &replayable_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
replayable_scn.set_min();
|
||||
|
||||
if (OB_SYS_TENANT_ID == MTL_ID() || is_meta_tenant(MTL_ID())) {
|
||||
// there isn't replayable_scn for SYS/META tenant
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("there isn't replayable_scn for SYS/META tenant", KR(ret));
|
||||
} else {
|
||||
// user tenant
|
||||
share::ObAllTenantInfo tenant_info;
|
||||
if (OB_FAIL(tenant_info_cache_.get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("failed to get tenant info", KR(ret));
|
||||
} else {
|
||||
replayable_scn = tenant_info.get_replayable_scn();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTenantInfoLoader::get_tenant_info(share::ObAllTenantInfo &tenant_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
tenant_info.reset();
|
||||
|
||||
if (OB_SYS_TENANT_ID == MTL_ID() || is_meta_tenant(MTL_ID())) {
|
||||
// there isn't tenant info for SYS/META tenant
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("there isn't tenant info for SYS/META tenant", KR(ret));
|
||||
} else {
|
||||
// user tenant
|
||||
if (OB_FAIL(tenant_info_cache_.get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("failed to get tenant info", KR(ret));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ class SCN;
|
||||
namespace rootserver
|
||||
{
|
||||
|
||||
class ObRecoveryLSService;
|
||||
class ObAllTenantInfoCache
|
||||
{
|
||||
public:
|
||||
@ -67,6 +68,7 @@ private:
|
||||
* Periodically cache tenant info.*/
|
||||
class ObTenantInfoLoader : public share::ObReentrantThread
|
||||
{
|
||||
friend class ObRecoveryLSService;
|
||||
public:
|
||||
ObTenantInfoLoader()
|
||||
: is_inited_(false),
|
||||
@ -90,7 +92,6 @@ public:
|
||||
BLOCKING_RUN_IMPLEMENT();
|
||||
}
|
||||
virtual void run2() override;
|
||||
int get_tenant_info(share::ObAllTenantInfo &tenant_info);
|
||||
/**
|
||||
* @description:
|
||||
* get valid sts, only return sts refreshed after specified_time
|
||||
@ -103,9 +104,55 @@ public:
|
||||
* 3. sts can not work for current tenant status
|
||||
*/
|
||||
int get_valid_sts_after(const int64_t specified_time_us, share::SCN &standby_scn);
|
||||
/**
|
||||
* @description:
|
||||
* get tenant standby scn.
|
||||
* for SYS/META/user tenant: use GTS/STS cache as readable_scn
|
||||
* @param[out] readable_scn
|
||||
*/
|
||||
int get_readable_scn(share::SCN &readable_scn);
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* get tenant replayable_scn.
|
||||
* for SYS/META tenant: there isn't replayable_scn
|
||||
* for user tenant: get replayable_scn from __all_tenant_info cache
|
||||
* @param[out] replayable_scn
|
||||
*/
|
||||
int get_replayable_scn(share::SCN &replayable_scn);
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* get tenant is_standby_normal_status
|
||||
* for SYS/META tenant: return false
|
||||
* for user tenant: return tenant_info.is_standby() && tenant_info.is_normal_status()
|
||||
* @param[out] is_standby_normal_status
|
||||
*/
|
||||
int check_is_standby_normal_status(bool &is_standby_normal_status);
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* get tenant is_primary_normal_status
|
||||
* for SYS/META tenant: return true
|
||||
* for user tenant: return tenant_info.is_primary() && tenant_info.is_normal_status()
|
||||
* @param[out] is_primary_normal_status
|
||||
*/
|
||||
int check_is_primary_normal_status(bool &is_primary_normal_status);
|
||||
|
||||
int refresh_tenant_info();
|
||||
int update_tenant_info_cache(const int64_t new_ora_rowscn, const ObAllTenantInfo &new_tenant_info);
|
||||
bool need_refresh(const int64_t refresh_time_interval_us);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @description:
|
||||
* get tenant info
|
||||
* for SYS/META tenant: do not support
|
||||
* for user tenant: tenant_info
|
||||
* @param[out] tenant_info
|
||||
*/
|
||||
int get_tenant_info(share::ObAllTenantInfo &tenant_info);
|
||||
|
||||
private:
|
||||
bool is_sys_ls_leader_();
|
||||
void broadcast_tenant_info_content_();
|
||||
|
@ -156,7 +156,7 @@ int64_t ObTenantRecoveryReportor::get_idle_time_()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
rootserver::ObTenantInfoLoader *tenant_info_loader = MTL(rootserver::ObTenantInfoLoader*);
|
||||
ObAllTenantInfo tenant_info;
|
||||
bool is_primary_normal_status = false;
|
||||
int64_t idle_time = ObTenantRoleTransitionConstants::STANDBY_UPDATE_LS_RECOVERY_STAT_TIME_US;
|
||||
|
||||
if (IS_NOT_INIT) {
|
||||
@ -165,9 +165,9 @@ int64_t ObTenantRecoveryReportor::get_idle_time_()
|
||||
} else if (OB_ISNULL(tenant_info_loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("pointer is null", KR(ret), KP(tenant_info_loader));
|
||||
} else if (OB_FAIL(tenant_info_loader->get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("fail to get tenant info", KR(ret), K_(tenant_id));
|
||||
} else if (tenant_info.is_primary() && tenant_info.is_normal_status()) {
|
||||
} else if (OB_FAIL(tenant_info_loader->check_is_primary_normal_status(is_primary_normal_status))) {
|
||||
LOG_WARN("fail to get tenant status", KR(ret), K_(tenant_id));
|
||||
} else if (is_primary_normal_status) {
|
||||
idle_time = ObTenantRoleTransitionConstants::PRIMARY_UPDATE_LS_RECOVERY_STAT_TIME_US;
|
||||
}
|
||||
return idle_time;
|
||||
@ -176,7 +176,7 @@ int64_t ObTenantRecoveryReportor::get_idle_time_()
|
||||
int ObTenantRecoveryReportor::submit_tenant_refresh_schema_task_()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObAllTenantInfo tenant_info;
|
||||
bool is_standby_normal_status = false;
|
||||
rootserver::ObTenantInfoLoader *tenant_info_loader = MTL(rootserver::ObTenantInfoLoader*);
|
||||
|
||||
if (IS_NOT_INIT) {
|
||||
@ -185,9 +185,9 @@ int ObTenantRecoveryReportor::submit_tenant_refresh_schema_task_()
|
||||
} else if (OB_ISNULL(GCTX.ob_service_) || OB_ISNULL(GCTX.schema_service_) || OB_ISNULL(sql_proxy_) || OB_ISNULL(tenant_info_loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("pointer is null", KR(ret), KP(GCTX.ob_service_), KP(GCTX.schema_service_), KP(sql_proxy_), KP(tenant_info_loader));
|
||||
} else if (OB_FAIL(tenant_info_loader->get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("fail to get tenant info", KR(ret), K_(tenant_id));
|
||||
} else if (tenant_info.is_standby() && tenant_info.is_normal_status()) {
|
||||
} else if (OB_FAIL(tenant_info_loader->check_is_standby_normal_status(is_standby_normal_status))) {
|
||||
LOG_WARN("fail to get tenant status", KR(ret), K_(tenant_id));
|
||||
} else if (is_standby_normal_status) {
|
||||
ObRefreshSchemaStatus schema_status;
|
||||
ObSchemaStatusProxy *schema_status_proxy = GCTX.schema_status_proxy_;
|
||||
if (OB_ISNULL(schema_status_proxy)) {
|
||||
@ -246,11 +246,11 @@ int ObTenantRecoveryReportor::update_ls_recovery_stat_()
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("ls is null", KR(ret), KP(ls));
|
||||
} else {
|
||||
ObAllTenantInfo tenant_info;
|
||||
if (OB_TMP_FAIL(tenant_info_loader->get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("failed to get_tenant_info", KR(ret), KPC(ls));
|
||||
} else if (OB_TMP_FAIL(ls->update_ls_replayable_point(tenant_info.get_replayable_scn()))) {
|
||||
LOG_WARN("failed to update_ls_replayable_point", KR(tmp_ret), KPC(ls), K(tenant_info));
|
||||
share::SCN replayable_scn = SCN::base_scn();;
|
||||
if (OB_TMP_FAIL(tenant_info_loader->get_replayable_scn(replayable_scn))) {
|
||||
LOG_WARN("failed to get replayable_scn", KR(ret), KPC(ls));
|
||||
} else if (OB_TMP_FAIL(ls->update_ls_replayable_point(replayable_scn))) {
|
||||
LOG_WARN("failed to update_ls_replayable_point", KR(tmp_ret), KPC(ls), K(replayable_scn));
|
||||
}
|
||||
|
||||
if (ls->is_sys_ls()) {
|
||||
@ -333,26 +333,6 @@ int ObTenantRecoveryReportor::update_ls_recovery(ObLS *ls, common::ObMySQLProxy
|
||||
|
||||
}
|
||||
|
||||
int ObTenantRecoveryReportor::get_tenant_readable_scn(SCN &readable_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
share::ObAllTenantInfo tenant_info;
|
||||
rootserver::ObTenantInfoLoader *tenant_info_loader = MTL(rootserver::ObTenantInfoLoader*);
|
||||
|
||||
if (OB_ISNULL(tenant_info_loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("mtl pointer is null", KR(ret), KP(tenant_info_loader));
|
||||
} else if (OB_FAIL(tenant_info_loader->get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("get_tenant_info failed", K(ret));
|
||||
} else if (OB_UNLIKELY(! tenant_info.is_valid())) {
|
||||
ret = OB_EAGAIN;
|
||||
LOG_WARN("tenant info not valid", K(ret), K(tenant_info));
|
||||
} else {
|
||||
readable_scn = tenant_info.get_standby_scn();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTenantRecoveryReportor::update_replayable_point_()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -375,18 +355,18 @@ int ObTenantRecoveryReportor::update_replayable_point_from_tenant_info_()
|
||||
int ret = OB_SUCCESS;
|
||||
logservice::ObLogService *log_service = MTL(logservice::ObLogService*);
|
||||
const int64_t PRINT_INTERVAL = 10 * 1000 * 1000L;
|
||||
ObAllTenantInfo tenant_info;
|
||||
SCN replayable_scn = SCN::base_scn();
|
||||
rootserver::ObTenantInfoLoader *tenant_info_loader = MTL(rootserver::ObTenantInfoLoader*);
|
||||
|
||||
if (OB_ISNULL(tenant_info_loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("mtl pointer is null", KR(ret), KP(tenant_info_loader));
|
||||
} else if (OB_FAIL(tenant_info_loader->get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("failed to get_tenant_info", KR(ret), K_(tenant_id));
|
||||
} else if (OB_FAIL(log_service->update_replayable_point(tenant_info.get_replayable_scn()))) {
|
||||
LOG_WARN("logservice update_replayable_point failed", KR(ret), K(tenant_info));
|
||||
} else if (OB_FAIL(tenant_info_loader->get_replayable_scn(replayable_scn))) {
|
||||
LOG_WARN("failed to get replayable_scn", KR(ret), K_(tenant_id));
|
||||
} else if (OB_FAIL(log_service->update_replayable_point(replayable_scn))) {
|
||||
LOG_WARN("logservice update_replayable_point failed", KR(ret), K(replayable_scn));
|
||||
} else if (REACH_TIME_INTERVAL(PRINT_INTERVAL)) {
|
||||
LOG_INFO("update_replayable_point_from_tenant_info_ success", KR(ret), K(tenant_info));
|
||||
LOG_INFO("update_replayable_point_from_tenant_info_ success", KR(ret), K(replayable_scn));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -62,7 +62,6 @@ public:
|
||||
//description: update ls recovery
|
||||
static int update_ls_recovery(storage::ObLS *ls, common::ObMySQLProxy *sql_proxy);
|
||||
|
||||
int get_tenant_readable_scn(share::SCN &readable_scn);
|
||||
static int get_readable_scn(const share::ObLSID &id, share::SCN &read_scn);
|
||||
private:
|
||||
static int get_sync_point_(const share::ObLSID &id, share::SCN &scn, share::SCN &read_scn);
|
||||
|
@ -262,6 +262,8 @@ using ObTableScanIteratorObjPool = common::ObServerObjectPool<oceanbase::storage
|
||||
#define MTL_ID() share::ObTenantEnv::get_tenant_local()->id()
|
||||
// 获取是否为主租户
|
||||
#define MTL_IS_PRIMARY_TENANT() share::ObTenantEnv::get_tenant()->is_primary_tenant()
|
||||
// 租户是否处于恢复中
|
||||
#define MTL_IS_RESTORE_TENANT() share::ObTenantEnv::get_tenant()->is_restore_tenant()
|
||||
// 更新租户role
|
||||
#define MTL_SET_TENANT_ROLE(tenant_role) share::ObTenantEnv::get_tenant()->set_tenant_role(tenant_role)
|
||||
// 获取租户role
|
||||
@ -429,17 +431,16 @@ public:
|
||||
return ATOMIC_LOAD(&tenant_role_value_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* Only when it is clear that it is a standby/restore tenant, it returns not primary tenant.
|
||||
* The correct value can be obtained after the tenant role loaded in subsequent retry.
|
||||
* @return whether allow strong consistency read write
|
||||
*/
|
||||
bool is_primary_tenant()
|
||||
{
|
||||
return share::is_primary_tenant(ATOMIC_LOAD(&tenant_role_value_));
|
||||
}
|
||||
|
||||
bool is_restore_tenant()
|
||||
{
|
||||
return share::is_restore_tenant(ATOMIC_LOAD(&tenant_role_value_));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T get() { return inner_get(Identity<T>()); }
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "observer/ob_service.h"
|
||||
#include "observer/ob_srv_network_frame.h"
|
||||
#include "share/rc/ob_tenant_module_init_ctx.h"
|
||||
#include "share/rc/ob_tenant_base.h" // MTL_IS_RESTORE_TENANT
|
||||
#include "storage/ls/ob_ls.h"
|
||||
#include "storage/ls/ob_ls_lock.h"
|
||||
#include "storage/ls/ob_ls_meta.h"
|
||||
@ -1319,21 +1320,14 @@ int ObLSService::get_restore_status_(
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const uint64_t tenant_id = MTL_ID();
|
||||
rootserver::ObTenantInfoLoader *tenant_info_loader = MTL(rootserver::ObTenantInfoLoader*);
|
||||
share::ObAllTenantInfo tenant_info;
|
||||
restore_status = ObLSRestoreStatus::RESTORE_NONE;
|
||||
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not init", K(ret));
|
||||
} else if (OB_ISNULL(tenant_info_loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("tenant info loader should not be NULL", K(ret), KP(tenant_info_loader));
|
||||
} else if (is_sys_tenant(tenant_id) || is_meta_tenant(tenant_id)) {
|
||||
restore_status = ObLSRestoreStatus::RESTORE_NONE;
|
||||
} else if (OB_FAIL(tenant_info_loader->get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("failed to get tenant info", K(ret));
|
||||
} else if (FALSE_IT(restore_status = tenant_info.is_restore() ?
|
||||
} else if (FALSE_IT(restore_status = MTL_IS_RESTORE_TENANT() ?
|
||||
ObLSRestoreStatus::RESTORE_START : ObLSRestoreStatus::RESTORE_NONE)) {
|
||||
}
|
||||
return ret;
|
||||
|
@ -346,21 +346,19 @@ int ObTabletGCHandler::check_tablet_gc_for_standby_(bool &cannot_gc, ObTabletHan
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
cannot_gc = false;
|
||||
SCN readable_scn;
|
||||
SCN readable_scn = SCN::base_scn();
|
||||
ObTablet *tablet = NULL;
|
||||
rootserver::ObTenantInfoLoader *info = MTL(rootserver::ObTenantInfoLoader*);
|
||||
ObTabletTxMultiSourceDataUnit tx_data;
|
||||
share::ObAllTenantInfo tenant_info;
|
||||
if (OB_ISNULL(info)) {
|
||||
if (MTL_IS_PRIMARY_TENANT()) {
|
||||
} else if (OB_ISNULL(info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "mtl ObTenantRecoveryReportor should not be null", KR(ret));
|
||||
} else if (OB_FAIL(info->get_tenant_info(tenant_info))) {
|
||||
LOG_WARN("fail to get_tennat_info", KPC(info));
|
||||
} else if (tenant_info.is_primary()) {
|
||||
} else if (FALSE_IT(readable_scn = tenant_info.get_standby_scn())) {
|
||||
} else if (OB_FAIL(info->get_readable_scn(readable_scn))) {
|
||||
LOG_WARN("fail to get readable_scn", KPC(info));
|
||||
} else if (!readable_scn.is_valid()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "readable scn is invalid", KR(ret), KPC(this->ls_), K(tenant_info));
|
||||
STORAGE_LOG(WARN, "readable scn is invalid", KR(ret), KPC(this->ls_), K(readable_scn));
|
||||
} else if (OB_ISNULL(tablet = tablet_handle.get_obj())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "tablet is NULL", KR(ret), KPC(this->ls_), K(tablet_handle));
|
||||
|
Reference in New Issue
Block a user