fix get ori schema version failed.

This commit is contained in:
obdev
2023-03-16 02:10:45 +00:00
committed by ob-robot
parent 8814cc8bd6
commit 475c344f8b

View File

@ -1898,16 +1898,14 @@ int ObDDLService::create_tables_in_trans(const bool if_not_exist,
schema_guard, schema_guard,
sql_proxy_); sql_proxy_);
common::ObArray<share::ObLSID> ls_id_array; common::ObArray<share::ObLSID> ls_id_array;
int64_t last_schema_version = OB_INVALID_VERSION; if (OB_FAIL(table_creator.init())) {
if (OB_FAIL(get_last_schema_version(last_schema_version))) {
LOG_WARN("fail to get last schema version", KR(ret));
} else if (OB_FAIL(table_creator.init())) {
LOG_WARN("fail to init table creator", KR(ret)); LOG_WARN("fail to init table creator", KR(ret));
} else if (OB_FAIL(new_table_tablet_allocator.init())) { } else if (OB_FAIL(new_table_tablet_allocator.init())) {
LOG_WARN("fail to init new table tablet allocator", KR(ret)); LOG_WARN("fail to init new table tablet allocator", KR(ret));
} }
ObArray<const ObTableSchema*> schemas; ObArray<const ObTableSchema*> schemas;
int64_t last_schema_version = OB_INVALID_VERSION;
for (int64_t i = 0; OB_SUCC(ret) && i < table_schemas.count(); i++) { for (int64_t i = 0; OB_SUCC(ret) && i < table_schemas.count(); i++) {
const share::schema::ObTableSchema &this_table = table_schemas.at(i); const share::schema::ObTableSchema &this_table = table_schemas.at(i);
const int64_t table_id = this_table.get_table_id(); const int64_t table_id = this_table.get_table_id();
@ -1925,12 +1923,14 @@ int ObDDLService::create_tables_in_trans(const bool if_not_exist,
} else if (OB_FAIL(table_creator.add_create_tablets_of_table_arg( } else if (OB_FAIL(table_creator.add_create_tablets_of_table_arg(
this_table, this_table,
ls_id_array))) { ls_id_array))) {
LOG_WARN("create table partitions failed", KR(ret), K(this_table), LOG_WARN("create table partitions failed", KR(ret), K(this_table));
K(last_schema_version));
} }
} }
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
if (OB_FAIL(ddl_operator.insert_ori_schema_version( if (OB_INVALID_VERSION == last_schema_version
&& OB_FAIL(get_last_schema_version(last_schema_version))) {
LOG_WARN("get last schema version failed", K(ret));
} else if (OB_FAIL(ddl_operator.insert_ori_schema_version(
trans, tenant_id, table_id, last_schema_version))) { trans, tenant_id, table_id, last_schema_version))) {
LOG_WARN("failed to insert_ori_schema_version!", LOG_WARN("failed to insert_ori_schema_version!",
K(ret), K(tenant_id), K(table_id), K(last_schema_version)); K(ret), K(tenant_id), K(table_id), K(last_schema_version));
@ -12920,16 +12920,15 @@ int ObDDLService::truncate_table_in_trans(const obrpc::ObTruncateTableArg &arg,
schema_guard, schema_guard,
sql_proxy_); sql_proxy_);
common::ObArray<share::ObLSID> ls_id_array; common::ObArray<share::ObLSID> ls_id_array;
int64_t last_schema_version = OB_INVALID_VERSION;
if (OB_FAIL(get_last_schema_version(last_schema_version))) { if (OB_FAIL(table_creator.init())) {
LOG_WARN("fail to get last schema version", KR(ret));
} else if (OB_FAIL(table_creator.init())) {
LOG_WARN("fail to init table creator", KR(ret)); LOG_WARN("fail to init table creator", KR(ret));
} else if (OB_FAIL(new_table_tablet_allocator.init())) { } else if (OB_FAIL(new_table_tablet_allocator.init())) {
LOG_WARN("fail to init new table tablet allocator", KR(ret)); LOG_WARN("fail to init new table tablet allocator", KR(ret));
} }
ObArray<const ObTableSchema*> schemas; ObArray<const ObTableSchema*> schemas;
int64_t last_schema_version = OB_INVALID_VERSION;
for (int64_t i = 0; OB_SUCC(ret) && i < table_schemas.count(); i++) { for (int64_t i = 0; OB_SUCC(ret) && i < table_schemas.count(); i++) {
const share::schema::ObTableSchema &this_table = table_schemas.at(i); const share::schema::ObTableSchema &this_table = table_schemas.at(i);
const int64_t table_id = this_table.get_table_id(); const int64_t table_id = this_table.get_table_id();
@ -12947,12 +12946,14 @@ int ObDDLService::truncate_table_in_trans(const obrpc::ObTruncateTableArg &arg,
} else if (OB_FAIL(table_creator.add_create_tablets_of_table_arg( } else if (OB_FAIL(table_creator.add_create_tablets_of_table_arg(
this_table, this_table,
ls_id_array))) { ls_id_array))) {
LOG_WARN("create table partitions failed", KR(ret), K(this_table), LOG_WARN("create table partitions failed", KR(ret), K(this_table));
K(last_schema_version));
} }
} }
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
if (OB_FAIL(ddl_operator.insert_ori_schema_version( if (OB_INVALID_VERSION == last_schema_version
&& OB_FAIL(get_last_schema_version(last_schema_version))) {
LOG_WARN("get last schema version failed", K(ret));
} else if (OB_FAIL(ddl_operator.insert_ori_schema_version(
trans, tenant_id, table_id, last_schema_version))) { trans, tenant_id, table_id, last_schema_version))) {
LOG_WARN("failed to insert_ori_schema_version!", LOG_WARN("failed to insert_ori_schema_version!",
K(ret), K(tenant_id), K(table_id), K(last_schema_version)); K(ret), K(tenant_id), K(table_id), K(last_schema_version));
@ -13568,15 +13569,14 @@ int ObDDLService::create_user_hidden_table(const ObTableSchema &orig_table_schem
LOG_WARN("failed to insert temp table info", K(ret), KPC(table_schema)); LOG_WARN("failed to insert temp table info", K(ret), KPC(table_schema));
} }
} }
int64_t last_schema_version = OB_INVALID_VERSION; int64_t last_schema_version = OB_INVALID_VERSION;
if (OB_SUCC(ret)) {
if (OB_FAIL(get_last_schema_version(last_schema_version))) {
LOG_WARN("fail to get last schema version", KR(ret));
}
}
for (int64_t i = 0; OB_SUCC(ret) && i < schemas.count(); i++) { for (int64_t i = 0; OB_SUCC(ret) && i < schemas.count(); i++) {
share::schema::ObTableSchema *table_schema = const_cast<ObTableSchema*>(schemas.at(i)); share::schema::ObTableSchema *table_schema = const_cast<ObTableSchema*>(schemas.at(i));
if (OB_FAIL(ddl_operator.insert_ori_schema_version(trans, tenant_id, if (OB_INVALID_VERSION == last_schema_version
&& OB_FAIL(get_last_schema_version(last_schema_version))) {
LOG_WARN("get last schema version failed", K(ret), K(last_schema_version));
} else if (OB_FAIL(ddl_operator.insert_ori_schema_version(trans, tenant_id,
table_schema->get_table_id(), last_schema_version))) { table_schema->get_table_id(), last_schema_version))) {
LOG_WARN("failed to insert_ori_schema_version!", K(ret), KPC(table_schema), K(last_schema_version)); LOG_WARN("failed to insert_ori_schema_version!", K(ret), KPC(table_schema), K(last_schema_version));
} }
@ -14227,9 +14227,6 @@ int ObDDLService::rebuild_hidden_table_index_in_trans(
} }
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
int64_t last_schema_version = OB_INVALID_VERSION; int64_t last_schema_version = OB_INVALID_VERSION;
if (OB_FAIL(get_last_schema_version(last_schema_version))) {
LOG_WARN("fail to get last schema version", KR(ret));
}
for (int64_t i = 0; OB_SUCC(ret) && i < new_table_schemas.count(); i++) { for (int64_t i = 0; OB_SUCC(ret) && i < new_table_schemas.count(); i++) {
const share::schema::ObTableSchema &this_table = new_table_schemas.at(i); const share::schema::ObTableSchema &this_table = new_table_schemas.at(i);
uint64_t table_id = this_table.get_table_id(); uint64_t table_id = this_table.get_table_id();
@ -14244,7 +14241,10 @@ int ObDDLService::rebuild_hidden_table_index_in_trans(
LOG_WARN("create table tablets failed", K(ret), K(this_table)); LOG_WARN("create table tablets failed", K(ret), K(this_table));
} else {} } else {}
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
if (OB_FAIL(ddl_operator.insert_ori_schema_version( if (OB_INVALID_VERSION == last_schema_version
&& OB_FAIL(get_last_schema_version(last_schema_version))) {
LOG_WARN("get last schema version failed", K(ret), K(last_schema_version));
} else if (OB_FAIL(ddl_operator.insert_ori_schema_version(
trans, tenant_id, table_id, last_schema_version))) { trans, tenant_id, table_id, last_schema_version))) {
LOG_WARN("failed to insert_ori_schema_version!", LOG_WARN("failed to insert_ori_schema_version!",
K(ret), K(tenant_id), K(table_id), K(last_schema_version)); K(ret), K(tenant_id), K(table_id), K(last_schema_version));