fix bug that index num in table is more than limited num
This commit is contained in:
@ -5426,17 +5426,19 @@ int ObDDLOperator::drop_obj_privs(
|
||||
|
||||
int ObDDLOperator::drop_table(const ObTableSchema& table_schema, ObMySQLTransaction& trans,
|
||||
const ObString* ddl_stmt_str /*=NULL*/, const bool is_truncate_table /*false*/,
|
||||
DropTableIdHashSet* drop_table_set /*=NULL*/, const bool is_drop_db /*false*/)
|
||||
DropTableIdHashSet* drop_table_set /*=NULL*/, const bool is_drop_db /*false*/, bool* is_delay_delete /*NULL*/)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool is_delay_delete = false;
|
||||
if (OB_FAIL(check_is_delay_delete(table_schema.get_tenant_id(), is_delay_delete))) {
|
||||
bool tmp = false;
|
||||
is_delay_delete = (NULL == is_delay_delete) ? &tmp : is_delay_delete;
|
||||
if (OB_FAIL(check_is_delay_delete(table_schema.get_tenant_id(), *is_delay_delete))) {
|
||||
LOG_WARN("check is delay delete failed", K(ret), K(table_schema.get_tenant_id()));
|
||||
} else if (is_delay_delete) {
|
||||
} else if (*is_delay_delete) {
|
||||
// do nothing
|
||||
} else if (table_schema.is_dropped_schema() && OB_FAIL(drop_table_for_inspection(table_schema, trans))) {
|
||||
LOG_WARN("drop table for dropped shema failed", K(ret));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (!table_schema.is_dropped_schema() &&
|
||||
OB_FAIL(drop_table_for_not_dropped_schema(
|
||||
|
||||
@ -349,7 +349,8 @@ public:
|
||||
|
||||
virtual int drop_table(const share::schema::ObTableSchema& table_schema, common::ObMySQLTransaction& trans,
|
||||
const common::ObString* ddl_stmt_str = NULL, const bool is_truncate_table = false,
|
||||
share::schema::DropTableIdHashSet* drop_table_set = NULL, const bool is_drop_db = false);
|
||||
share::schema::DropTableIdHashSet* drop_table_set = NULL, const bool is_drop_db = false,
|
||||
bool* is_delay_delete = NULL /* Bring out the delayed delete behavior */);
|
||||
virtual int drop_table_for_not_dropped_schema(const share::schema::ObTableSchema& table_schema,
|
||||
common::ObMySQLTransaction& trans, const common::ObString* ddl_stmt_str = NULL,
|
||||
const bool is_truncate_table = false, share::schema::DropTableIdHashSet* drop_table_set = NULL,
|
||||
|
||||
@ -3985,7 +3985,9 @@ int ObDDLService::update_global_index(ObAlterTableArg& arg, const uint64_t tenan
|
||||
} else if (OB_FAIL(orig_table_schema.get_simple_index_infos(simple_index_infos))) {
|
||||
LOG_WARN("get_index_tid_array failed", K(ret));
|
||||
} else {
|
||||
int64_t delay_deleted_global_index_count = 0;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < simple_index_infos.count(); ++i) {
|
||||
bool is_delay_delete = false;
|
||||
const ObTableSchema* index_table_schema = NULL;
|
||||
if (OB_FAIL(schema_guard.get_table_schema(simple_index_infos.at(i).table_id_, index_table_schema))) {
|
||||
LOG_WARN("get_table_schema failed", "table id", simple_index_infos.at(i).table_id_, K(ret));
|
||||
@ -4015,8 +4017,13 @@ int ObDDLService::update_global_index(ObAlterTableArg& arg, const uint64_t tenan
|
||||
ObTableSchema new_table_schema;
|
||||
if (OB_FAIL(new_table_schema.assign(*index_table_schema))) {
|
||||
LOG_WARN("fail to assign schema", K(ret));
|
||||
} else if (OB_FAIL(rebuild_index_in_trans(
|
||||
schema_guard, new_table_schema, frozen_version, NULL, arg.create_mode_, &trans))) {
|
||||
} else if (OB_FAIL(rebuild_index_in_trans(schema_guard,
|
||||
new_table_schema,
|
||||
frozen_version,
|
||||
NULL,
|
||||
arg.create_mode_,
|
||||
&trans,
|
||||
&is_delay_delete))) {
|
||||
LOG_WARN("ddl_service_ rebuild_index failed", KR(ret));
|
||||
} else {
|
||||
ObSArray<obrpc::ObIndexArg*>& index_arg_list = arg.index_arg_list_;
|
||||
@ -4033,12 +4040,23 @@ int ObDDLService::update_global_index(ObAlterTableArg& arg, const uint64_t tenan
|
||||
LOG_WARN("fail to assign index schema", KR(ret), K(new_table_schema));
|
||||
} else if (OB_FAIL(index_arg_list.push_back(create_index_arg))) {
|
||||
LOG_WARN("push back to index_arg_list failed", KR(ret), K(create_index_arg));
|
||||
} else if (is_delay_delete) {
|
||||
delay_deleted_global_index_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// In the case of delayed deletion, it is necessary to determine
|
||||
// whether the sum of rebuilt indexex exceeds the maximum index of the data table.
|
||||
if (OB_SUCC(ret) && 0 < delay_deleted_global_index_count &&
|
||||
orig_table_schema.get_index_tid_count() + delay_deleted_global_index_count > OB_MAX_INDEX_PER_TABLE) {
|
||||
ret = OB_ERR_TOO_MANY_KEYS;
|
||||
LOG_USER_ERROR(OB_ERR_TOO_MANY_KEYS, OB_MAX_INDEX_PER_TABLE);
|
||||
int64_t index_count = orig_table_schema.get_index_tid_count();
|
||||
LOG_WARN("too many index for table", K(OB_MAX_INDEX_PER_TABLE), K(index_count), K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -8401,7 +8419,7 @@ int ObDDLService::create_table_like(const ObCreateTableLikeArg& arg, const int64
|
||||
// If sql_trans is NULL, you need to create a transaction inside the function
|
||||
int ObDDLService::drop_table_in_trans(ObSchemaGetterGuard& schema_guard, const ObTableSchema& table_schema,
|
||||
const bool is_rebuild_index, const bool is_index, const bool to_recyclebin, const ObString* ddl_stmt_str,
|
||||
ObMySQLTransaction* sql_trans, DropTableIdHashSet* drop_table_set)
|
||||
ObMySQLTransaction* sql_trans, DropTableIdHashSet* drop_table_set, bool* is_delay_delete /*NULL*/)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(is_index);
|
||||
@ -8446,8 +8464,13 @@ int ObDDLService::drop_table_in_trans(ObSchemaGetterGuard& schema_guard, const O
|
||||
LOG_WARN("fail to try modify tenant primary zone entity count", KR(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && OB_FAIL(ddl_operator.drop_table(
|
||||
table_schema, trans, ddl_stmt_str, false /*is_truncate_table*/, drop_table_set))) {
|
||||
if (OB_SUCC(ret) && OB_FAIL(ddl_operator.drop_table(table_schema,
|
||||
trans,
|
||||
ddl_stmt_str,
|
||||
false /*is_truncate_table*/,
|
||||
drop_table_set,
|
||||
false,
|
||||
is_delay_delete))) {
|
||||
LOG_WARN("ddl_operator drop_table failed", K(table_schema), KR(ret));
|
||||
}
|
||||
}
|
||||
@ -10166,7 +10189,7 @@ int ObDDLService::rebuild_index(const ObRebuildIndexArg& arg, const int64_t froz
|
||||
// If sql_trans is NULL, you need to create a transaction inside the function
|
||||
int ObDDLService::rebuild_index_in_trans(ObSchemaGetterGuard& schema_guard, ObTableSchema& index_schema,
|
||||
const int64_t frozen_version, const ObString* ddl_stmt_str, const obrpc::ObCreateTableMode create_mode,
|
||||
ObMySQLTransaction* sql_trans)
|
||||
ObMySQLTransaction* sql_trans, bool* is_delay_delete /*NULL*/)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t new_table_id = index_schema.get_table_id();
|
||||
@ -10178,7 +10201,8 @@ int ObDDLService::rebuild_index_in_trans(ObSchemaGetterGuard& schema_guard, ObTa
|
||||
LOG_WARN("schema_service must not null", KR(ret));
|
||||
} else if (OB_ISNULL(sql_trans) && OB_FAIL(trans.start(sql_proxy_))) {
|
||||
LOG_WARN("start transaction failed", KR(ret));
|
||||
} else if (OB_FAIL(drop_table_in_trans(schema_guard, index_schema, true, true, false, ddl_stmt_str, &trans, NULL))) {
|
||||
} else if (OB_FAIL(drop_table_in_trans(
|
||||
schema_guard, index_schema, true, true, false, ddl_stmt_str, &trans, NULL, is_delay_delete))) {
|
||||
LOG_WARN("drop_table failed", K(index_schema), KR(ret));
|
||||
} else if (FALSE_IT(new_table_id = OB_INVALID_ID)) {
|
||||
} else if (OB_FAIL(schema_service->fetch_new_table_id(index_schema.get_tenant_id(), new_table_id))) {
|
||||
|
||||
@ -153,7 +153,8 @@ public:
|
||||
|
||||
int rebuild_index_in_trans(share::schema::ObSchemaGetterGuard& schema_guard,
|
||||
share::schema::ObTableSchema& table_schema, const int64_t frozen_version, const ObString* ddl_stmt_str,
|
||||
const obrpc::ObCreateTableMode create_mode, ObMySQLTransaction* sql_trans);
|
||||
const obrpc::ObCreateTableMode create_mode, ObMySQLTransaction* sql_trans,
|
||||
bool* is_delay_delete = NULL /* Bring out the delayed delete behavior */);
|
||||
|
||||
int create_inner_expr_index(const share::schema::ObTableSchema& orig_table_schema,
|
||||
share::schema::ObTableSchema& new_table_schema, common::ObIArray<share::schema::ObColumnSchemaV2*>& new_columns,
|
||||
@ -950,7 +951,8 @@ private:
|
||||
int drop_table_in_trans(share::schema::ObSchemaGetterGuard& schema_guard,
|
||||
const share::schema::ObTableSchema& table_schema, const bool is_rebuild_index, const bool is_index,
|
||||
const bool to_recyclebin, const common::ObString* ddl_stmt_str, ObMySQLTransaction* sql_trans,
|
||||
share::schema::DropTableIdHashSet* drop_table_set = NULL);
|
||||
share::schema::DropTableIdHashSet* drop_table_set = NULL,
|
||||
bool* is_delay_delete = NULL /* Bring out the delayed delete behavior */);
|
||||
int drop_aux_table_in_drop_table(common::ObMySQLTransaction& trans, ObDDLOperator& ddl_operator,
|
||||
share::schema::ObSchemaGetterGuard& schema_guard, const share::schema::ObTableSchema& table_schema,
|
||||
const share::schema::ObTableType table_type, const bool to_recyclebin);
|
||||
|
||||
Reference in New Issue
Block a user