add defense when creating index tablet
This commit is contained in:
@ -1987,9 +1987,10 @@ int ObDDLWaitTransEndCtx::try_wait(bool &is_trans_end, int64_t &snapshot_version
|
|||||||
if (OB_SUCC(ret) && is_trans_end_) {
|
if (OB_SUCC(ret) && is_trans_end_) {
|
||||||
if (OB_FAIL(get_snapshot(snapshot_version))) {
|
if (OB_FAIL(get_snapshot(snapshot_version))) {
|
||||||
LOG_WARN("get snapshot version failed", K(ret));
|
LOG_WARN("get snapshot version failed", K(ret));
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
is_trans_end = is_trans_end_;
|
is_trans_end = is_trans_end_;
|
||||||
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2037,9 +2038,8 @@ int ObDDLWaitTransEndCtx::get_snapshot(int64_t &snapshot_version)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
int tmp_ret = OB_SUCCESS;
|
|
||||||
snapshot_version = max(max_snapshot, curr_ts.get_val_for_tx() - INDEX_SNAPSHOT_VERSION_DIFF);
|
snapshot_version = max(max_snapshot, curr_ts.get_val_for_tx() - INDEX_SNAPSHOT_VERSION_DIFF);
|
||||||
if (OB_SUCCESS != (tmp_ret = freeze_info_proxy.get_freeze_info(
|
if (OB_FAIL(freeze_info_proxy.get_freeze_info(
|
||||||
root_service->get_sql_proxy(), SCN::min_scn(), frozen_status))) {
|
root_service->get_sql_proxy(), SCN::min_scn(), frozen_status))) {
|
||||||
LOG_WARN("get freeze info failed", K(ret));
|
LOG_WARN("get freeze info failed", K(ret));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -2024,13 +2024,31 @@ int ObLSTabletService::create_tablet(
|
|||||||
table_store_flag.set_with_major_sstable();
|
table_store_flag.set_with_major_sstable();
|
||||||
tablet_handle.reset();
|
tablet_handle.reset();
|
||||||
|
|
||||||
if (OB_FAIL(ObTabletCreateDeleteHelper::prepare_create_msd_tablet())) {
|
// ddl schema version defense
|
||||||
|
if (table_schema.is_index_table()) {
|
||||||
|
const int64_t table_schema_version = table_schema.get_schema_version();
|
||||||
|
ObTenantFreezeInfoMgr::FreezeInfo freeze_info;
|
||||||
|
|
||||||
|
if (OB_FAIL(MTL_CALL_FREEZE_INFO_MGR(get_freeze_info_behind_snapshot_version, snapshot_version, freeze_info))) {
|
||||||
|
if (OB_ENTRY_NOT_EXIST != ret) {
|
||||||
|
LOG_WARN("failed to get freeze info behind snapshot version", K(ret), K(snapshot_version));
|
||||||
|
} else {
|
||||||
|
ret = OB_SUCCESS;
|
||||||
|
}
|
||||||
|
} else if (OB_UNLIKELY(table_schema_version > freeze_info.schema_version)) {
|
||||||
|
ret = OB_SCHEMA_ERROR;
|
||||||
|
LOG_ERROR("schema version in freeze info is less than table schema version", K(ret), K(ls_id), K(tablet_id), K(data_tablet_id),
|
||||||
|
K(snapshot_version), K(table_schema_version), K(freeze_info), K(create_scn), K(table_schema));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FAILEDx(ObTabletCreateDeleteHelper::prepare_create_msd_tablet())) {
|
||||||
LOG_WARN("fail to prepare create msd tablet", K(ret));
|
LOG_WARN("fail to prepare create msd tablet", K(ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if (OB_SUCC(ret)) {
|
||||||
ObBucketHashWLockGuard lock_guard(bucket_lock_, key.tablet_id_.hash());
|
ObBucketHashWLockGuard lock_guard(bucket_lock_, key.tablet_id_.hash());
|
||||||
if (FAILEDx(ObTabletCreateDeleteHelper::create_msd_tablet(key, tablet_handle))) {
|
if (OB_FAIL(ObTabletCreateDeleteHelper::create_msd_tablet(key, tablet_handle))) {
|
||||||
LOG_WARN("failed to create msd tablet", K(ret), K(key));
|
LOG_WARN("failed to create msd tablet", K(ret), K(key));
|
||||||
} else if (OB_ISNULL(tablet = tablet_handle.get_obj())
|
} else if (OB_ISNULL(tablet = tablet_handle.get_obj())
|
||||||
|| OB_ISNULL(allocator = tablet_handle.get_allocator())) {
|
|| OB_ISNULL(allocator = tablet_handle.get_allocator())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user