[CP] fix major compaction ddl trans check_newest_schema

This commit is contained in:
obdev 2023-06-21 13:48:16 +00:00 committed by ob-robot
parent 769236241b
commit 1a09fe9ab3
3 changed files with 19 additions and 12 deletions

View File

@ -281,22 +281,19 @@ int ObFreezeInfoManager::set_freeze_info()
ObRecursiveMutexGuard guard(lock_);
int64_t tenant_schema_version = -1;
// not to check newest schema_version
int64_t fake_schema_version = 1000;
if (OB_FAIL(check_inner_stat())) {
LOG_WARN("inner stat error", KR(ret));
} else if (OB_ISNULL(GCTX.schema_service_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("schema_service is null", KR(ret));
} else if (OB_FAIL(GCTX.schema_service_->get_tenant_refreshed_schema_version(tenant_id_, tenant_schema_version))) {
LOG_WARN("fail to get tenant refreshed schema version", KR(ret), K_(tenant_id));
} else {
ObFreezeInfoProxy freeze_info_proxy(tenant_id_);
// freeze get_schema_version need interactive with ddl trans but don't use gen_new_schema_version so no need check_in_rs
ObDDLSQLTransaction trans(GCTX.schema_service_, false/*need_end_signal*/, false/*stash*/, false/*parallel*/, false/*check_in_rs*/);
// freeze disable check_newest_schema so not to use schema_guard
ObDDLSQLTransaction trans(GCTX.schema_service_, false/*need_end_signal*/, false/*stash*/, false/*parallel*/, false/*check_in_rs*/, false/*check_newest_schema*/);
// In 'ddl_sql_transaction.start()', it implements the semantics of 'lock_all_ddl_operation'.
if (OB_FAIL(trans.start(sql_proxy_, tenant_id_, tenant_schema_version))) {
LOG_WARN("fail to start transaction", KR(ret), K_(tenant_id), K(tenant_schema_version));
if (OB_FAIL(trans.start(sql_proxy_, tenant_id_, fake_schema_version))) {
LOG_WARN("fail to start transaction", KR(ret), K_(tenant_id), K(fake_schema_version));
// 1. lock snapshot_gc_ts in __all_global_stat
} else if (OB_FAIL(ObGlobalStatProxy::select_snapshot_gc_scn_for_update(
trans, tenant_id_, remote_snapshot_gc_scn))) {

View File

@ -31531,6 +31531,11 @@ int ObDDLSQLTransaction::start(ObISQLClient *proxy,
start_operation_schema_version_ = tsi_oper->last_operation_schema_version_;
start_operation_tenant_id_ = tsi_oper->last_operation_tenant_id_;
}
if (enable_ddl_parallel_) {
enable_check_newest_schema_ = false;
}
if (FAILEDx(common::ObMySQLTransaction::start(proxy, tenant_id, with_snapshot))) {
LOG_WARN("fail to start trans", KR(ret), K(with_snapshot), K(tenant_id_));
} else if (0 == tenant_refreshed_schema_version) {
@ -31539,7 +31544,7 @@ int ObDDLSQLTransaction::start(ObISQLClient *proxy,
K(tenant_id), K(tenant_refreshed_schema_version));
} else if (OB_FAIL(lock_all_ddl_operation(*this, tenant_id_, enable_ddl_parallel_))) {
LOG_WARN("fail to lock all ddl operation", K(ret), K(tenant_id_));
} else if (!enable_ddl_parallel_) {
} else if (enable_check_newest_schema_) {
//double check, after lock success, check schema_version is newest before lock
ObRefreshSchemaStatus schema_status;
schema_status.tenant_id_ = tenant_id;

View File

@ -2367,7 +2367,8 @@ public:
const bool need_end_signal = true,
const bool enable_query_stash = false,
const bool enable_ddl_parallel = false,
const bool enable_check_ddl_epoch = true)
const bool enable_check_ddl_epoch = true,
const bool enable_check_newest_schema = true)
: common::ObMySQLTransaction(enable_query_stash),
schema_service_(schema_service),
tenant_id_(OB_INVALID_TENANT_ID),
@ -2377,7 +2378,8 @@ public:
trans_start_schema_version_(0),
enable_ddl_parallel_(enable_ddl_parallel),
enable_check_ddl_epoch_(enable_check_ddl_epoch),
trans_start_ddl_epoch_(OB_INVALID_VERSION)
trans_start_ddl_epoch_(OB_INVALID_VERSION),
enable_check_newest_schema_(enable_check_newest_schema)
{}
virtual ~ObDDLSQLTransaction();
@ -2462,6 +2464,9 @@ private:
bool enable_check_ddl_epoch_;
// for compare
int64_t trans_start_ddl_epoch_;
// default true to check newest schema; daily major set false not check just use schema from inner table
bool enable_check_newest_schema_;
};
// Fill in the partition name and the high values of the last partition
template<typename SCHEMA, typename ALTER_SCHEMA>