@@ -65,7 +65,8 @@ ObFtsIndexBuildTask::ObFtsIndexBuildTask()
6565 dependent_task_result_map_(),
6666 is_retryable_ddl_(true ),
6767 use_doc_id_(true ),
68- rowkey_doc_schema_version_(0 )
68+ rowkey_doc_schema_version_(0 ),
69+ charset_type_(CHARSET_INVALID )
6970{
7071}
7172
@@ -639,7 +640,13 @@ int ObFtsIndexBuildTask::prepare_aux_index_tables()
639640 } else if (is_fts_task () && OB_FAIL (ObFtsIndexBuilderUtil::check_need_to_load_dic (tenant_id_, parser_name, need_to_load_dic))) {
640641 LOG_WARN (" fail to check need to load dic" , K (ret), K (tenant_id_), K (parser_name), K (need_to_load_dic));
641642 } else if (need_to_load_dic) {
642- if (OB_FAIL (get_charset_type (charset_type))) {
643+ ObMySQLTransaction trans;
644+ if (OB_ISNULL (GCTX .sql_proxy_ )) {
645+ ret = OB_ERR_UNEXPECTED ;
646+ LOG_WARN (" sql proxy is null" , K (ret));
647+ } else if (OB_FAIL (trans.start (GCTX .sql_proxy_ , tenant_id_))) {
648+ LOG_WARN (" failed to start trans" , K (ret), K (tenant_id_));
649+ } else if (OB_FAIL (get_charset_type (charset_type))) {
643650 LOG_WARN (" fail to get charset type" , K (ret), K (tenant_id_), K (charset_type));
644651 } else if (OB_FAIL (ObGenDicLoader::get_instance ().get_dic_loader (tenant_id_,
645652 parser_name,
@@ -655,9 +662,20 @@ int ObFtsIndexBuildTask::prepare_aux_index_tables()
655662 } else if (OB_FAIL (ObDicLock::lock_dic_tables_out_trans (tenant_id_,
656663 *dic_loader_handle.get_loader (),
657664 transaction::tablelock::SHARE ,
658- owner_id))) {
665+ owner_id,
666+ trans))) {
659667 LOG_WARN (" failed to lock all dictionary table" ,
660668 K (ret), K (tenant_id_), K (dic_loader_handle), K (owner_id));
669+ } else if (OB_FAIL (update_task_message (trans))) {
670+ LOG_WARN (" fail to update fulltext index build task message" ,
671+ K (ret), K (tenant_id_), K (task_id_));
672+ }
673+ if (trans.is_started ()) {
674+ int tmp_ret = OB_SUCCESS ;
675+ if (OB_SUCCESS != (tmp_ret = trans.end (OB_SUCC (ret)))) {
676+ LOG_WARN (" failed to commit trans" , K (ret), K (tmp_ret));
677+ ret = OB_SUCC (ret) ? tmp_ret : ret;
678+ }
661679 }
662680 }
663681 if (OB_SUCC (ret)) {
@@ -911,7 +929,9 @@ int ObFtsIndexBuildTask::get_charset_type(ObCharsetType &charset_type)
911929 const ObTableSchema *data_schema = nullptr ;
912930 const ObColumnSchemaV2 *col_schema = nullptr ;
913931 charset_type = CHARSET_INVALID ;
914- if (OB_FAIL (schema_service.get_tenant_schema_guard (tenant_id_, schema_guard))) {
932+ if (CHARSET_INVALID != charset_type_) {
933+ charset_type = charset_type_;
934+ } else if (OB_FAIL (schema_service.get_tenant_schema_guard (tenant_id_, schema_guard))) {
915935 LOG_WARN (" get tenant schema guard failed" , K (ret), K (tenant_id_));
916936 } else if (OB_FAIL (schema_guard.get_table_schema (tenant_id_, object_id_, data_schema))) {
917937 LOG_WARN (" fail to get table schema" , K (ret), K (tenant_id_), K (object_id_));
@@ -931,6 +951,7 @@ int ObFtsIndexBuildTask::get_charset_type(ObCharsetType &charset_type)
931951 LOG_WARN (" the column is not exist" , K (ret), K (tenant_id_), K (column_name));
932952 } else {
933953 charset_type = static_cast <ObCharsetType>(col_schema->get_charset_type ());
954+ charset_type_ = charset_type;
934955 }
935956 return ret;
936957}
@@ -1086,6 +1107,7 @@ int ObFtsIndexBuildTask::serialize_params_to_message(
10861107 int8_t is_fts_doc_word_succ = static_cast <int8_t >(is_fts_doc_word_succ_);
10871108 int8_t is_retryable_ddl = static_cast <int8_t >(is_retryable_ddl_);
10881109 int8_t use_doc_id = static_cast <int8_t >(use_doc_id_);
1110+ int64_t charset_type = static_cast <int64_t >(charset_type_);
10891111
10901112 if (OB_UNLIKELY (nullptr == buf || buf_len <= 0 )) {
10911113 ret = OB_INVALID_ARGUMENT ;
@@ -1199,6 +1221,11 @@ int ObFtsIndexBuildTask::serialize_params_to_message(
11991221 pos,
12001222 rowkey_doc_schema_version_))) {
12011223 LOG_WARN (" serialize rowkey doc schema version failed" , K (ret));
1224+ } else if (OB_FAIL (serialization::encode_i64 (buf,
1225+ buf_len,
1226+ pos,
1227+ charset_type))) {
1228+ LOG_WARN (" serialize charset type failed" , K (ret));
12021229 }
12031230 return ret;
12041231}
@@ -1223,6 +1250,7 @@ int ObFtsIndexBuildTask::deserialize_params_from_message(
12231250 int8_t is_fts_doc_word_succ = false ;
12241251 int8_t is_retryable_ddl = true ;
12251252 int8_t use_doc_id = true ;
1253+ int64_t charset_type = 0 ;
12261254 SMART_VAR (obrpc::ObCreateIndexArg, tmp_arg) {
12271255 if (OB_UNLIKELY (!is_valid_tenant_id (tenant_id) ||
12281256 nullptr == buf ||
@@ -1344,6 +1372,11 @@ int ObFtsIndexBuildTask::deserialize_params_from_message(
13441372 pos,
13451373 &rowkey_doc_schema_version_))) {
13461374 LOG_WARN (" fail to deserialize rowkey doc table schema version" , K (ret));
1375+ } else if (OB_FAIL (serialization::decode_i64 (buf,
1376+ data_len,
1377+ pos,
1378+ &charset_type))) {
1379+ LOG_WARN (" fail to deserialize charset type" , K (ret));
13471380 }
13481381
13491382 if (OB_SUCC (ret) && !dependent_task_result_map_.created ()
@@ -1401,6 +1434,7 @@ int ObFtsIndexBuildTask::deserialize_params_from_message(
14011434 is_fts_doc_word_succ_ = is_fts_doc_word_succ;
14021435 is_retryable_ddl_ = is_retryable_ddl;
14031436 use_doc_id_ = use_doc_id;
1437+ charset_type_ = static_cast <ObCharsetType>(charset_type);
14041438 }
14051439 return ret;
14061440}
@@ -1419,6 +1453,7 @@ int64_t ObFtsIndexBuildTask::get_serialize_param_size() const
14191453 int8_t is_fts_doc_word_succ = static_cast <int8_t >(is_fts_doc_word_succ_);
14201454 int8_t is_retryable_ddl = static_cast <int8_t >(is_retryable_ddl_);
14211455 int8_t use_doc_id = static_cast <int8_t >(use_doc_id_);
1456+ int64_t charset_type = static_cast <int64_t >(charset_type_);
14221457
14231458 return create_index_arg_.get_serialize_size () + ObDDLTask::get_serialize_param_size ()
14241459 + serialization::encoded_length (rowkey_doc_aux_table_id_)
@@ -1441,7 +1476,8 @@ int64_t ObFtsIndexBuildTask::get_serialize_param_size() const
14411476 + serialization::encoded_length_i8 (is_fts_doc_word_succ)
14421477 + serialization::encoded_length_i8 (is_retryable_ddl)
14431478 + serialization::encoded_length_i8 (use_doc_id)
1444- + serialization::encoded_length_i64 (rowkey_doc_schema_version_);
1479+ + serialization::encoded_length_i64 (rowkey_doc_schema_version_)
1480+ + serialization::encoded_length_i64 (charset_type);
14451481}
14461482
14471483int ObFtsIndexBuildTask::get_task_status (int64_t task_id, uint64_t aux_table_id, bool & is_succ)
@@ -1984,7 +2020,11 @@ int ObFtsIndexBuildTask::cleanup_impl()
19842020 } else if (is_fts_task () && OB_FAIL (ObFtsIndexBuilderUtil::check_need_to_load_dic (tenant_id_, parser_name, need_to_load_dic))) {
19852021 LOG_WARN (" fail to check need to load dic" , K (ret), K (tenant_id_), K (parser_name), K (need_to_load_dic));
19862022 } else if (need_to_load_dic) {
1987- if (OB_FAIL (get_charset_type (charset_type))) {
2023+ const bool try_unlock_dictionaries = charset_type_ != CHARSET_INVALID ;
2024+ if (!try_unlock_dictionaries) {
2025+ LOG_INFO (" The dictionaries table is not locked, skip unlock dictionaries" ,
2026+ K (ret), K (tenant_id_), K (charset_type_), K (parser_name));
2027+ } else if (OB_FAIL (get_charset_type (charset_type))) {
19882028 LOG_WARN (" fail to get charset type" , K (ret), K (tenant_id_), K (charset_type));
19892029 } else if (OB_FAIL (ObGenDicLoader::get_instance ().get_dic_loader (tenant_id_,
19902030 parser_name,
0 commit comments