replace ts related to ddl with scn.

This commit is contained in:
obdev
2022-11-28 02:21:13 +00:00
committed by ob-robot
parent bbec6aff49
commit 8a4d14122f
539 changed files with 17685 additions and 173434 deletions

View File

@ -540,26 +540,14 @@ int ObSqlTransControl::stmt_sanity_check_(ObSQLSessionInfo *session,
auto current_consist_level = plan_ctx->get_consistency_level();
CK (current_consist_level != ObConsistencyLevel::INVALID_CONSISTENCY);
bool is_plain_select = plan->is_plain_select();
// adjust stmt's consistency level
if (OB_SUCC(ret) && !is_plain_select && current_consist_level != ObConsistencyLevel::STRONG) {
plan_ctx->set_consistency_level(ObConsistencyLevel::STRONG);
}
// check consistency type volatile
if (OB_SUCC(ret) && session->is_in_transaction()) {
auto current_consist_level = plan_ctx->get_consistency_level();
auto last_consist_level = session->get_last_consistency_level();
auto last_cl_valid = ObConsistencyLevel::INVALID_CONSISTENCY != last_consist_level;
if (last_cl_valid && last_consist_level != current_consist_level) {
// weak-read -> DML, reject
if (ObConsistencyLevel::WEAK == last_consist_level && !is_plain_select) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("different consistency type in one transaction, unexpected error", K(ret),
K(last_consist_level), "trans_id", session->get_tx_id());
LOG_USER_ERROR(OB_NOT_SUPPORTED, "different consistency type in one transaction");
} else {
plan_ctx->set_consistency_level(last_consist_level);
}
// adjust stmt's consistency level
if (OB_SUCC(ret)) {
// Weak read statement with inner table should be converted to strong read.
// For example, schema refresh statement;
if (plan->is_contain_inner_table() ||
(!is_plain_select && current_consist_level != ObConsistencyLevel::STRONG)) {
plan_ctx->set_consistency_level(ObConsistencyLevel::STRONG);
}
}
@ -574,9 +562,6 @@ int ObSqlTransControl::stmt_sanity_check_(ObSQLSessionInfo *session,
LOG_USER_ERROR(OB_NOT_SUPPORTED, "weak consistency under SERIALIZABLE isolation level");
}
}
if (OB_SUCC(ret)) {
session->set_last_consistency_level(plan_ctx->get_consistency_level());
}
return ret;
}
@ -589,9 +574,8 @@ int ObSqlTransControl::stmt_setup_snapshot_(ObSQLSessionInfo *session,
int ret = OB_SUCCESS;
auto cl = plan_ctx->get_consistency_level();
auto &snapshot = das_ctx.get_snapshot();
if ((cl == ObConsistencyLevel::WEAK || cl == ObConsistencyLevel::FROZEN)
&& !plan->is_contain_inner_table()) {
palf::SCN snapshot_version;
if (cl == ObConsistencyLevel::WEAK || cl == ObConsistencyLevel::FROZEN) {
palf::SCN snapshot_version = palf::SCN::min_scn();
if (OB_FAIL(txs->get_weak_read_snapshot_version(snapshot_version))) {
TRANS_LOG(WARN, "get weak read snapshot fail", KPC(txs));
} else {