From b23f28968a4cf23b5e4d9685a015e8f48b357e48 Mon Sep 17 00:00:00 2001 From: Tyshawn Date: Wed, 18 Sep 2024 06:28:10 +0000 Subject: [PATCH] [BUG.FIX] fix no ddl stmt str while drop fts index. --- src/rootserver/ddl_task/ob_ddl_scheduler.cpp | 8 ++++-- src/rootserver/ddl_task/ob_ddl_scheduler.h | 1 + .../ddl_task/ob_drop_fts_index_task.cpp | 26 ++++++++++++++++--- .../ddl_task/ob_drop_fts_index_task.h | 1 + src/rootserver/ob_index_builder.cpp | 3 ++- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/rootserver/ddl_task/ob_ddl_scheduler.cpp b/src/rootserver/ddl_task/ob_ddl_scheduler.cpp index 25d92bb39..cf320a5b5 100755 --- a/src/rootserver/ddl_task/ob_ddl_scheduler.cpp +++ b/src/rootserver/ddl_task/ob_ddl_scheduler.cpp @@ -1069,6 +1069,7 @@ int ObDDLScheduler::create_ddl_task(const ObCreateDDLTaskParam ¶m, break; case DDL_DROP_FTS_INDEX: case DDL_DROP_MULVALUE_INDEX: + drop_index_arg = static_cast(param.ddl_arg_); if (OB_FAIL(create_drop_fts_index_task(proxy, param.src_table_schema_, param.schema_version_, @@ -1076,6 +1077,7 @@ int ObDDLScheduler::create_ddl_task(const ObCreateDDLTaskParam ¶m, param.aux_rowkey_doc_schema_, param.aux_doc_rowkey_schema_, param.aux_doc_word_schema_, + drop_index_arg, *param.allocator_, task_record))) { LOG_WARN("fail to create drop fts index task", K(ret)); @@ -1796,6 +1798,7 @@ int ObDDLScheduler::create_drop_fts_index_task( const share::schema::ObTableSchema *rowkey_doc_schema, const share::schema::ObTableSchema *doc_rowkey_schema, const share::schema::ObTableSchema *doc_word_schema, + const obrpc::ObDropIndexArg *drop_index_arg, ObIAllocator &allocator, ObDDLTaskRecord &task_record) { @@ -1811,9 +1814,9 @@ int ObDDLScheduler::create_drop_fts_index_task( if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("not init", K(ret)); - } else if (OB_ISNULL(index_schema)) { + } else if (OB_ISNULL(index_schema) || OB_ISNULL(drop_index_arg)) { ret = OB_INVALID_ARGUMENT; - LOG_WARN("invalid argument", K(ret), KP(index_schema)); + LOG_WARN("invalid argument", K(ret), KP(index_schema), KP(drop_index_arg)); } else if (FALSE_IT(is_fts_index = index_schema->is_fts_index_aux())) { } else if (OB_UNLIKELY(schema_version <= 0)) { ret = OB_INVALID_ARGUMENT; @@ -1860,6 +1863,7 @@ int ObDDLScheduler::create_drop_fts_index_task( doc_rowkey, domain_index, fts_doc_word, + drop_index_arg->ddl_stmt_str_, schema_version, consumer_group_id))) { LOG_WARN("init drop index task failed", K(ret), K(data_table_id), K(domain_index)); diff --git a/src/rootserver/ddl_task/ob_ddl_scheduler.h b/src/rootserver/ddl_task/ob_ddl_scheduler.h index 989cac5df..78e6b4e5d 100755 --- a/src/rootserver/ddl_task/ob_ddl_scheduler.h +++ b/src/rootserver/ddl_task/ob_ddl_scheduler.h @@ -497,6 +497,7 @@ private: const share::schema::ObTableSchema *rowkey_doc_schema, const share::schema::ObTableSchema *doc_rowkey_schema, const share::schema::ObTableSchema *doc_word_schema, + const obrpc::ObDropIndexArg *drop_index_arg, ObIAllocator &allocator, ObDDLTaskRecord &task_record); diff --git a/src/rootserver/ddl_task/ob_drop_fts_index_task.cpp b/src/rootserver/ddl_task/ob_drop_fts_index_task.cpp index cf33c287b..956bfe361 100644 --- a/src/rootserver/ddl_task/ob_drop_fts_index_task.cpp +++ b/src/rootserver/ddl_task/ob_drop_fts_index_task.cpp @@ -48,6 +48,7 @@ int ObDropFTSIndexTask::init( const ObFTSDDLChildTaskInfo &doc_rowkey, const ObFTSDDLChildTaskInfo &domain_index, const ObFTSDDLChildTaskInfo &fts_doc_word, + const ObString &ddl_stmt_str, const int64_t schema_version, const int64_t consumer_group_id) { @@ -73,6 +74,8 @@ int ObDropFTSIndexTask::init( LOG_WARN("fail to deep copy from other", K(ret), K(domain_index)); } else if (is_fts_task && OB_FAIL(fts_doc_word_.deep_copy_from_other(fts_doc_word, allocator_))) { LOG_WARN("fail to deep copy from other", K(ret), K(fts_doc_word)); + } else if (OB_FAIL(set_ddl_stmt_str(ddl_stmt_str))) { + LOG_WARN("fail to deep copy drop index arg", K(ret)); } else { task_type_ = ddl_type; set_gmt_create(ObTimeUtility::current_time()); @@ -188,6 +191,8 @@ int ObDropFTSIndexTask::serialize_params_to_message(char *buf, const int64_t buf LOG_WARN("fail to serialize aux fts index table info", K(ret), K(domain_index_)); } else if (OB_FAIL(fts_doc_word_.serialize(buf, buf_size, pos))) { LOG_WARN("fail to serialize aux doc word aux table info", K(ret), K(fts_doc_word_)); + } else if (OB_FAIL(ddl_stmt_str_.serialize(buf, buf_size, pos))) { + LOG_WARN("fail to serialize ddl stmt string", K(ret)); } return ret; } @@ -199,8 +204,8 @@ int ObDropFTSIndexTask::deserialize_params_from_message( int64_t &pos) { int ret = OB_SUCCESS; - obrpc::ObDropIndexArg tmp_drop_index_arg; ObFTSDDLChildTaskInfo tmp_info; + ObString tmp_ddl_stmt_str; if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id) || nullptr == buf || buf_size <= 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid arguments", K(ret), K(tenant_id), KP(buf), K(buf_size)); @@ -222,6 +227,13 @@ int ObDropFTSIndexTask::deserialize_params_from_message( LOG_WARN("fail to deserialize aux doc word table info", K(ret)); } else if (OB_FAIL(fts_doc_word_.deep_copy_from_other(tmp_info, allocator_))) { LOG_WARN("fail to deep copy from tmp info", K(ret), K(tmp_info)); + } else if (OB_UNLIKELY(pos >= buf_size)) { + // The end of the message has been reached. It is an old version message without drop index arg. + // just skip. + } else if (OB_FAIL(tmp_ddl_stmt_str.deserialize(buf, buf_size, pos))) { + LOG_WARN("fail to deserialize drop index arg", K(ret)); + } else if (OB_FAIL(ob_write_string(allocator_, tmp_ddl_stmt_str, ddl_stmt_str_))) { + LOG_WARN("fail to copy ddl stmt string", K(ret), K(tmp_ddl_stmt_str)); } return ret; } @@ -232,7 +244,8 @@ int64_t ObDropFTSIndexTask::get_serialize_param_size() const + rowkey_doc_.get_serialize_size() + doc_rowkey_.get_serialize_size() + domain_index_.get_serialize_size() - + fts_doc_word_.get_serialize_size(); + + fts_doc_word_.get_serialize_size() + + ddl_stmt_str_.get_serialize_size(); } int ObDropFTSIndexTask::check_switch_succ() @@ -417,6 +430,7 @@ int ObDropFTSIndexTask::create_drop_index_task( const ObTableSchema *index_schema = nullptr; const ObDatabaseSchema *database_schema = nullptr; const ObTableSchema *data_table_schema = nullptr; + ObSqlString drop_index_sql; bool is_index_exist = false; if (OB_ISNULL(root_service_)) { ret = OB_ERR_UNEXPECTED; @@ -444,6 +458,8 @@ int ObDropFTSIndexTask::create_drop_index_task( } else if (OB_UNLIKELY(nullptr == database_schema || nullptr == data_table_schema)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected error, schema is nullptr", K(ret), KP(database_schema), KP(data_table_schema)); + } else if (index_schema->is_fts_index_aux() && OB_FAIL(drop_index_sql.assign(ddl_stmt_str_))) { + LOG_WARN("fail to assign drop index sql", K(ret)); } else { int64_t ddl_rpc_timeout_us = 0; obrpc::ObDropIndexArg arg; @@ -460,6 +476,9 @@ int ObDropFTSIndexTask::create_drop_index_task( arg.ddl_stmt_str_ = nullptr; arg.is_add_to_scheduler_ = true; arg.task_id_ = task_id_; + if (index_schema->is_fts_index_aux()) { + arg.ddl_stmt_str_ = drop_index_sql.string(); + } if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout( index_schema->get_all_part_num() + data_table_schema->get_all_part_num(), ddl_rpc_timeout_us))) { LOG_WARN("fail to get ddl rpc timeout", K(ret)); @@ -470,7 +489,8 @@ int ObDropFTSIndexTask::create_drop_index_task( } LOG_INFO("drop index", K(ret), K(index_tid), K(index_name), K(task_id), "data table name", data_table_schema->get_table_name_str(), - "database name", database_schema->get_database_name_str()); + "database name", database_schema->get_database_name_str(), + K(drop_index_sql.ptr())); } return ret; } diff --git a/src/rootserver/ddl_task/ob_drop_fts_index_task.h b/src/rootserver/ddl_task/ob_drop_fts_index_task.h index 710fff73b..e0f0b3868 100644 --- a/src/rootserver/ddl_task/ob_drop_fts_index_task.h +++ b/src/rootserver/ddl_task/ob_drop_fts_index_task.h @@ -48,6 +48,7 @@ public: const ObFTSDDLChildTaskInfo &doc_rowkey, const ObFTSDDLChildTaskInfo &domain_index, const ObFTSDDLChildTaskInfo &fts_doc_word, + const ObString &ddl_stmt_str, const int64_t schema_version, const int64_t consumer_group_id); int init(const ObDDLTaskRecord &task_record); diff --git a/src/rootserver/ob_index_builder.cpp b/src/rootserver/ob_index_builder.cpp index 1f1b6a87a..40adab6c8 100644 --- a/src/rootserver/ob_index_builder.cpp +++ b/src/rootserver/ob_index_builder.cpp @@ -774,7 +774,8 @@ int ObIndexBuilder::submit_drop_index_task(ObMySQLTransaction &trans, index_schema.get_schema_version(), 0/*parallelism*/, arg.consumer_group_id_, - &allocator); + &allocator, + &arg); param.aux_rowkey_doc_schema_ = &(index_schemas.at(aux_rowkey_doc_ith)); param.aux_doc_rowkey_schema_ = &(index_schemas.at(aux_doc_rowkey_ith));