Skip to content

Commit 42c0d19

Browse files
obdevob-robot
authored andcommitted
[FTS.BUGFIX] hidden table has been deleted, fail to exit fulltext index build task
1 parent 4cb9dde commit 42c0d19

4 files changed

Lines changed: 80 additions & 14 deletions

File tree

src/rootserver/ddl_task/ob_fts_index_build_task.cpp

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

14471483
int 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,

src/rootserver/ddl_task/ob_fts_index_build_task.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ class ObFtsIndexBuildTask : public ObDDLTask
9494
K(create_index_arg_),
9595
K(is_retryable_ddl_),
9696
K(use_doc_id_),
97-
K(rowkey_doc_schema_version_));
97+
K(rowkey_doc_schema_version_),
98+
K(charset_type_));
9899

99100
public:
100101
void set_rowkey_doc_aux_table_id(const uint64_t id) { rowkey_doc_aux_table_id_ = id; }
@@ -229,6 +230,7 @@ class ObFtsIndexBuildTask : public ObDDLTask
229230
bool is_retryable_ddl_;
230231
bool use_doc_id_;
231232
int64_t rowkey_doc_schema_version_;
233+
ObCharsetType charset_type_;
232234
};
233235

234236
} // end namespace rootserver

src/storage/fts/dict/ob_dic_lock.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,8 @@ int ObDicLock::lock_dic_tables_out_trans(
4040
LOG_WARN("sql proxy is null", K(ret));
4141
} else if (OB_FAIL(trans.start(GCTX.sql_proxy_, tenant_id))) {
4242
LOG_WARN("failed to start trans", K(ret), K(tenant_id));
43-
} else {
44-
for (int64_t i = 0; OB_SUCC(ret) && i < dic_tables_info.count(); ++i) {
45-
const uint64_t table_id = dic_tables_info.at(i).table_id_;
46-
if (OB_FAIL(do_table_lock(tenant_id, table_id, lock_mode, lock_owner, DEFAULT_TIMEOUT, true/*is_lock*/, trans))) {
47-
LOG_WARN("fail to do lock table", K(ret), K(tenant_id));
48-
}
49-
}
43+
} else if (OB_FAIL(lock_dic_tables_out_trans(tenant_id, dic_loader, lock_mode, lock_owner, trans))) {
44+
LOG_WARN("fail to lock dic tables", K(ret), K(tenant_id));
5045
}
5146
if (trans.is_started()) {
5247
int tmp_ret = OB_SUCCESS;
@@ -58,6 +53,29 @@ int ObDicLock::lock_dic_tables_out_trans(
5853
return ret;
5954
}
6055

56+
int ObDicLock::lock_dic_tables_out_trans(
57+
const uint64_t tenant_id,
58+
const ObTenantDicLoader &dic_loader,
59+
const transaction::tablelock::ObTableLockMode lock_mode,
60+
const transaction::tablelock::ObTableLockOwnerID &lock_owner,
61+
ObMySQLTransaction &trans)
62+
{
63+
int ret = OB_SUCCESS;
64+
const ObArray<ObTenantDicLoader::ObDicTableInfo> &dic_tables_info = dic_loader.get_dic_tables_info();
65+
if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id) || dic_tables_info.count() <= 0)) {
66+
ret = OB_INVALID_ARGUMENT;
67+
LOG_WARN("the tenant id or dic loader is invalid", K(ret), K(tenant_id), K(dic_tables_info));
68+
} else {
69+
for (int64_t i = 0; OB_SUCC(ret) && i < dic_tables_info.count(); ++i) {
70+
const uint64_t table_id = dic_tables_info.at(i).table_id_;
71+
if (OB_FAIL(do_table_lock(tenant_id, table_id, lock_mode, lock_owner, DEFAULT_TIMEOUT, true/*is_lock*/, trans))) {
72+
LOG_WARN("fail to do lock table", K(ret), K(tenant_id));
73+
}
74+
}
75+
}
76+
return ret;
77+
}
78+
6179
int ObDicLock::unlock_dic_tables(
6280
const uint64_t tenant_id,
6381
const ObTenantDicLoader &dic_loader,

src/storage/fts/dict/ob_dic_lock.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ class ObDicLock : public ObDDLLock
3131
const ObTenantDicLoader &dic_loader,
3232
const transaction::tablelock::ObTableLockMode lock_mode,
3333
const transaction::tablelock::ObTableLockOwnerID &lock_owner);
34+
static int lock_dic_tables_out_trans(
35+
const uint64_t tenant_id,
36+
const ObTenantDicLoader &dic_loader,
37+
const transaction::tablelock::ObTableLockMode lock_mode,
38+
const transaction::tablelock::ObTableLockOwnerID &lock_owner,
39+
ObMySQLTransaction &trans);
3440
static int unlock_dic_tables(
3541
const uint64_t tenant_id,
3642
const ObTenantDicLoader &dic_loader,

0 commit comments

Comments
 (0)