[SCN REFACTOR] replace flash back snapshot and remove read snapshot session
This commit is contained in:
@ -578,7 +578,8 @@ int ObMultiTenant::create_tenant_without_unit(const uint64_t tenant_id,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMultiTenant::convert_hidden_to_real_sys_tenant(const ObUnitInfoGetter::ObTenantConfig &unit)
|
||||
int ObMultiTenant::convert_hidden_to_real_sys_tenant(const ObUnitInfoGetter::ObTenantConfig &unit,
|
||||
const int64_t abs_timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -590,12 +591,14 @@ int ObMultiTenant::convert_hidden_to_real_sys_tenant(const ObUnitInfoGetter::ObT
|
||||
ObTenantSuperBlock new_super_block;
|
||||
bool lock_succ = false;
|
||||
int64_t bucket_lock_idx = -1;
|
||||
int64_t lock_timeout_ts = abs_timeout_us - 3000000; // reserve 3s for converting tenant
|
||||
|
||||
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not init", K(ret));
|
||||
} else if (OB_FAIL(bucket_lock_.try_wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id)))) {
|
||||
LOG_WARN("fail to try_wrlock for convert_hidden_to_real_sys_tenant", K(ret), K(bucket_lock_idx));
|
||||
} else if (OB_FAIL(bucket_lock_.wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id), lock_timeout_ts))) {
|
||||
LOG_WARN("fail to wrlock for convert_hidden_to_real_sys_tenant", K(ret), K(bucket_lock_idx), K(lock_timeout_ts));
|
||||
} else if (FALSE_IT(lock_succ = true)) {
|
||||
} else if (OB_FAIL(get_tenant(tenant_id, tenant))) {
|
||||
LOG_WARN("fail to get sys tenant", K(tenant_id), K(ret));
|
||||
@ -622,7 +625,7 @@ int ObMultiTenant::convert_hidden_to_real_sys_tenant(const ObUnitInfoGetter::ObT
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMultiTenant::create_tenant(const ObTenantMeta &meta, bool write_slog)
|
||||
int ObMultiTenant::create_tenant(const ObTenantMeta &meta, bool write_slog, const int64_t abs_timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -635,6 +638,7 @@ int ObMultiTenant::create_tenant(const ObTenantMeta &meta, bool write_slog)
|
||||
ObTenantCreateStep create_step = ObTenantCreateStep::STEP_BEGIN; // step0
|
||||
bool lock_succ = false;
|
||||
int64_t bucket_lock_idx = -1;
|
||||
int64_t lock_timeout_ts = abs_timeout_us - 5000000; // reserve 5s for creating tenant
|
||||
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
@ -645,8 +649,8 @@ int ObMultiTenant::create_tenant(const ObTenantMeta &meta, bool write_slog)
|
||||
} else if (OB_ISNULL(malloc_allocator)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("malloc allocator is NULL", K(ret));
|
||||
} else if (OB_FAIL(bucket_lock_.try_wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id)))) {
|
||||
LOG_WARN("fail to try_wrlock for create tenant", K(ret), K(tenant_id), K(bucket_lock_idx));
|
||||
} else if (OB_FAIL(bucket_lock_.wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id), lock_timeout_ts))) {
|
||||
LOG_WARN("fail to wrlock for create tenant", K(ret), K(tenant_id), K(bucket_lock_idx), K(lock_timeout_ts));
|
||||
} else if (FALSE_IT(lock_succ = true)) {
|
||||
} else if (OB_SUCC(get_tenant(tenant_id, tenant))) {
|
||||
ret = OB_TENANT_EXIST;
|
||||
@ -854,7 +858,7 @@ int ObMultiTenant::update_tenant_unit(const ObUnitInfoGetter::ObTenantConfig &un
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not init", K(ret));
|
||||
} else if (OB_FAIL(bucket_lock_.try_wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id)))) {
|
||||
} else if (OB_FAIL(bucket_lock_.wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id)))) {
|
||||
LOG_WARN("fail to try_wrlock for update tenant unit", K(ret), K(tenant_id), K(bucket_lock_idx));
|
||||
} else if (FALSE_IT(lock_succ = true)) {
|
||||
} else if (OB_FAIL(update_tenant_unit_no_lock(unit))) {
|
||||
@ -1283,13 +1287,6 @@ int ObMultiTenant::remove_tenant(const uint64_t tenant_id)
|
||||
} else if (OB_FAIL(GCTX.session_mgr_->kill_tenant(tenant_id))) {
|
||||
LOG_ERROR("fail to kill tenant session", K(ret), K(tenant_id));
|
||||
} else {
|
||||
LOG_INFO("removed_tenant begin to stop", K(tenant_id));
|
||||
removed_tenant->stop();
|
||||
LOG_INFO("removed_tenant begin to wait", K(tenant_id));
|
||||
removed_tenant->wait();
|
||||
// wait for some outstanding requests to complete, which may need to switch tenant,
|
||||
// so here call try_wrlock after wait, otherwise, some req may be hang in the th_worker.
|
||||
// https://work.aone.alibaba-inc.com/issue/44705579
|
||||
LOG_INFO("removed_tenant begin to try wlock", K(tenant_id));
|
||||
bool locked = false;
|
||||
ObLDHandle handle;
|
||||
@ -1305,6 +1302,10 @@ int ObMultiTenant::remove_tenant(const uint64_t tenant_id)
|
||||
LOG_WARN("can't get tenant wlock to remove tenant", K(tenant_id), K(ret));
|
||||
removed_tenant->lock_.ld_.print();
|
||||
} else {
|
||||
LOG_INFO("removed_tenant begin to stop", K(tenant_id));
|
||||
removed_tenant->stop();
|
||||
LOG_INFO("removed_tenant begin to wait", K(tenant_id));
|
||||
removed_tenant->wait();
|
||||
ObTenant *removed_tenant_tmp = nullptr;
|
||||
SpinWLockGuard guard(lock_);
|
||||
|
||||
@ -1560,13 +1561,20 @@ int ObMultiTenant::get_tenant_with_tenant_lock(
|
||||
const uint64_t tenant_id, ObLDHandle &handle, ObTenant *&tenant) const
|
||||
{
|
||||
SpinRLockGuard guard(lock_);
|
||||
int ret = get_tenant_unsafe(tenant_id, tenant);
|
||||
ObTenant *tenant_tmp = nullptr;
|
||||
int ret = get_tenant_unsafe(tenant_id, tenant_tmp);
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(tenant->try_rdlock(handle)) && tenant->has_stopped()) {
|
||||
// in some cases this error code is handled specially
|
||||
ret = OB_IN_STOP_STATE;
|
||||
LOG_WARN("fail to try rdlock tenant", K(ret), K(tenant_id));
|
||||
} else if (OB_UNLIKELY(tenant->has_stopped())) {
|
||||
if (OB_FAIL(tenant_tmp->try_rdlock(handle))) {
|
||||
if (tenant_tmp->has_stopped()) {
|
||||
// in some cases this error code is handled specially
|
||||
ret = OB_IN_STOP_STATE;
|
||||
LOG_WARN("fail to try rdlock tenant", K(ret), K(tenant_id));
|
||||
}
|
||||
} else {
|
||||
// assign tenant when get rdlock succ
|
||||
tenant = tenant_tmp;
|
||||
}
|
||||
if (OB_UNLIKELY(tenant_tmp->has_stopped())) {
|
||||
LOG_WARN("get rdlock when tenant has stopped", K(tenant_id), K(lbt()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user