Optimize snapshot acquiring when read write statement is spliting
This commit is contained in:
@ -400,6 +400,7 @@ int ObTableApiProcessorBase::setup_tx_snapshot_(transaction::ObTxDesc &trans_des
|
||||
SCN weak_read_snapshot;
|
||||
if (OB_FAIL(txs->get_weak_read_snapshot_version(
|
||||
-1, // system variable : max read stale time for user
|
||||
false,
|
||||
weak_read_snapshot))) {
|
||||
LOG_WARN("fail to get weak read snapshot", K(ret));
|
||||
} else {
|
||||
|
||||
@ -264,7 +264,7 @@ DEF_TIME_WITH_CHECKER(max_stale_time_for_weak_consistency, OB_TENANT_PARAMETER,
|
||||
"the max data stale time that cluster weak read version behind current timestamp,"
|
||||
"no smaller than weak_read_version_refresh_interval, range: [5s, +∞)",
|
||||
ObParameterAttr(Section::TENANT, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||
DEF_BOOL(enable_monotonic_weak_read, OB_TENANT_PARAMETER, "true",
|
||||
DEF_BOOL(enable_monotonic_weak_read, OB_TENANT_PARAMETER, "false",
|
||||
"specifies observer supportting atomicity and monotonic order read",
|
||||
ObParameterAttr(Section::TENANT, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||
DEF_DBL(server_cpu_quota_min, OB_CLUSTER_PARAMETER, "1", "[1,16]",
|
||||
|
||||
@ -656,7 +656,10 @@ int ObSqlTransControl::stmt_setup_snapshot_(ObSQLSessionInfo *session,
|
||||
auto &snapshot = das_ctx.get_snapshot();
|
||||
if (cl == ObConsistencyLevel::WEAK || cl == ObConsistencyLevel::FROZEN) {
|
||||
SCN snapshot_version = SCN::min_scn();
|
||||
const bool local_single_ls = plan->is_local_plan() &&
|
||||
OB_PHY_PLAN_LOCAL == plan->get_location_type();
|
||||
if (OB_FAIL(txs->get_weak_read_snapshot_version(session->get_ob_max_read_stale_time(),
|
||||
local_single_ls,
|
||||
snapshot_version))) {
|
||||
TRANS_LOG(WARN, "get weak read snapshot fail", KPC(txs));
|
||||
int64_t stale_time = session->get_ob_max_read_stale_time();
|
||||
|
||||
@ -444,6 +444,7 @@ int ObMultiVersionGarbageCollector::study_min_unallocated_WRS(
|
||||
|
||||
if (OB_FAIL(MTL(transaction::ObTransService*)->get_weak_read_snapshot_version(
|
||||
-1, // system variable : max read stale time for user
|
||||
false,
|
||||
min_unallocated_WRS))) {
|
||||
MVCC_LOG(WARN, "fail to get weak read snapshot", K(ret));
|
||||
if (OB_REPLICA_NOT_READABLE == ret) {
|
||||
|
||||
@ -716,6 +716,7 @@ int ObTransService::get_ls_read_snapshot_version(const share::ObLSID &local_ls_i
|
||||
}
|
||||
|
||||
int ObTransService::get_weak_read_snapshot_version(const int64_t max_read_stale_us_for_user,
|
||||
const bool local_single_ls,
|
||||
SCN &snapshot)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -724,10 +725,16 @@ int ObTransService::get_weak_read_snapshot_version(const int64_t max_read_stale_
|
||||
|
||||
// server weak read version
|
||||
if (!ObWeakReadUtil::enable_monotonic_weak_read(tenant_id_)) {
|
||||
if (local_single_ls) {
|
||||
if (OB_FAIL(GCTX.weak_read_service_->get_server_version(tenant_id_, wrs_scn))) {
|
||||
TRANS_LOG(WARN, "get server read snapshot fail", K(ret), KPC(this));
|
||||
}
|
||||
monotinic_read = false;
|
||||
} else {
|
||||
if (OB_FAIL(GCTX.weak_read_service_->get_cluster_version(tenant_id_, wrs_scn))) {
|
||||
TRANS_LOG(WARN, "get weak read snapshot fail", K(ret), KPC(this));
|
||||
}
|
||||
}
|
||||
// wrs cluster version
|
||||
} else if (OB_FAIL(GCTX.weak_read_service_->get_cluster_version(tenant_id_, wrs_scn))) {
|
||||
TRANS_LOG(WARN, "get weak read snapshot fail", K(ret), KPC(this));
|
||||
|
||||
@ -235,6 +235,7 @@ int get_ls_read_snapshot_version(const share::ObLSID &local_ls_id,
|
||||
* OB_REPLICA_NOT_READABLE - snapshot is too stale
|
||||
*/
|
||||
int get_weak_read_snapshot_version(const int64_t max_read_stale_time,
|
||||
const bool local_single_ls,
|
||||
share::SCN &snapshot_version);
|
||||
/*
|
||||
* release_snapshot - release snapshot
|
||||
|
||||
Reference in New Issue
Block a user