From 3f05711d88fc9873b0e9a4d260ac353b6d7f15ad Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 13 Dec 2024 03:14:42 +0000 Subject: [PATCH] [FTS][BUG.FIX] prohibit building many fulltext or multivalue indexes at the same time in same alter --- src/rootserver/ob_ddl_service.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/rootserver/ob_ddl_service.cpp b/src/rootserver/ob_ddl_service.cpp index b394745be..5cc7bfe07 100755 --- a/src/rootserver/ob_ddl_service.cpp +++ b/src/rootserver/ob_ddl_service.cpp @@ -4664,14 +4664,18 @@ int ObDDLService::check_alter_table_index(const obrpc::ObAlterTableArg &alter_ta const ObSArray &index_arg_list = alter_table_arg.index_arg_list_; bool has_drop_index = false; bool has_create_index = false; + bool is_add_many_fts_indexes = false; has_drop_and_add_index = false; for (int64_t i = 0; OB_SUCC(ret) && i < index_arg_list.size(); ++i) { ObIndexArg *index_arg = const_cast(index_arg_list.at(i)); - if (OB_ISNULL(index_arg)) { + ObCreateIndexArg *create_index_arg = static_cast(index_arg); + if (OB_ISNULL(index_arg) || OB_ISNULL(create_index_arg)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("index arg should not be null", K(ret)); } else { const ObIndexArg::IndexActionType type = index_arg->index_action_type_; + bool is_add_fts_or_multivalue_index = share::schema::is_fts_or_multivalue_index(create_index_arg->index_type_) + && ObIndexArg::ADD_INDEX == type; switch(type) { case ObIndexArg::DROP_PRIMARY_KEY: { if (!is_invalid_ddl_type(ddl_type)) { @@ -4771,6 +4775,14 @@ int ObDDLService::check_alter_table_index(const obrpc::ObAlterTableArg &alter_ta if (!has_drop_and_add_index) { has_drop_and_add_index = has_drop_index && has_create_index; } + if (!is_add_many_fts_indexes) { + is_add_many_fts_indexes = is_add_fts_or_multivalue_index; + } else if (is_add_fts_or_multivalue_index) { + ret = OB_OP_NOT_ALLOW; + LOG_WARN("adding many fulltext or multivalue indexes at the same time is a high-risk operation, which is not support", K(ret)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, + "adding many fulltext or multivalue indexes at the same time is a high-risk operation, which is"); + } } } }