diff --git a/src/observer/table/ob_table_rpc_processor.cpp b/src/observer/table/ob_table_rpc_processor.cpp index e686d6d0b7..4d85232136 100644 --- a/src/observer/table/ob_table_rpc_processor.cpp +++ b/src/observer/table/ob_table_rpc_processor.cpp @@ -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 { diff --git a/src/share/parameter/ob_parameter_seed.ipp b/src/share/parameter/ob_parameter_seed.ipp index f489287df7..2bb2e1edc2 100755 --- a/src/share/parameter/ob_parameter_seed.ipp +++ b/src/share/parameter/ob_parameter_seed.ipp @@ -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]", diff --git a/src/sql/ob_sql_trans_control.cpp b/src/sql/ob_sql_trans_control.cpp index 912954716c..9fec6b6127 100644 --- a/src/sql/ob_sql_trans_control.cpp +++ b/src/sql/ob_sql_trans_control.cpp @@ -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(); diff --git a/src/storage/concurrency_control/ob_multi_version_garbage_collector.cpp b/src/storage/concurrency_control/ob_multi_version_garbage_collector.cpp index a0887fec7c..6fcff54097 100644 --- a/src/storage/concurrency_control/ob_multi_version_garbage_collector.cpp +++ b/src/storage/concurrency_control/ob_multi_version_garbage_collector.cpp @@ -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) { diff --git a/src/storage/tx/ob_tx_api.cpp b/src/storage/tx/ob_tx_api.cpp index bac1931435..64c01490d6 100644 --- a/src/storage/tx/ob_tx_api.cpp +++ b/src/storage/tx/ob_tx_api.cpp @@ -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 (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)); + 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)); + } } - monotinic_read = false; // 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)); diff --git a/src/storage/tx/ob_tx_api.h b/src/storage/tx/ob_tx_api.h index e1a080fc91..7ce8d33bb2 100644 --- a/src/storage/tx/ob_tx_api.h +++ b/src/storage/tx/ob_tx_api.h @@ -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