Skip to content

Commit 5ab4602

Browse files
committed
MDEV-15323 Follow-up to MDEV-14905: Skip FTS processing if innodb_read_only
fts_cmp_set_sync_doc_id(), fts_load_stopword(): Start the transaction in read-only mode if innodb_read_only is set. fts_update_sync_doc_id(), fts_commit_table(), fts_sync(), fts_optimize_table(): Return DB_READ_ONLY if innodb_read_only is set. fts_doc_fetch_by_doc_id(), fts_table_fetch_doc_ids(): Remove the code to start an internal transaction or to roll back, because this is a read-only operation.
1 parent 27ea296 commit 5ab4602

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

storage/innobase/fts/fts0fts.cc

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2699,7 +2699,11 @@ fts_cmp_set_sync_doc_id(
26992699
fts_table.parent = table->name.m_name;
27002700

27012701
trx = trx_allocate_for_background();
2702-
trx_start_internal(trx);
2702+
if (srv_read_only_mode) {
2703+
trx_start_internal_read_only(trx);
2704+
} else {
2705+
trx_start_internal(trx);
2706+
}
27032707

27042708
trx->op_info = "update the next FTS document id";
27052709

@@ -2808,6 +2812,10 @@ fts_update_sync_doc_id(
28082812
fts_cache_t* cache = table->fts->cache;
28092813
char fts_name[MAX_FULL_NAME_LEN];
28102814

2815+
if (srv_read_only_mode) {
2816+
return DB_READ_ONLY;
2817+
}
2818+
28112819
fts_table.suffix = "CONFIG";
28122820
fts_table.table_id = table->id;
28132821
fts_table.type = FTS_COMMON_TABLE;
@@ -3052,6 +3060,10 @@ fts_commit_table(
30523060
/*=============*/
30533061
fts_trx_table_t* ftt) /*!< in: FTS table to commit*/
30543062
{
3063+
if (srv_read_only_mode) {
3064+
return DB_READ_ONLY;
3065+
}
3066+
30553067
const ib_rbt_node_t* node;
30563068
ib_rbt_t* rows;
30573069
dberr_t error = DB_SUCCESS;
@@ -3796,7 +3808,6 @@ fts_doc_fetch_by_doc_id(
37963808
trx_t* trx = trx_allocate_for_background();
37973809
que_t* graph;
37983810

3799-
trx_start_internal(trx);
38003811
trx->op_info = "fetching indexed FTS document";
38013812

38023813
/* The FTS index can be supplied by caller directly with
@@ -3884,13 +3895,7 @@ fts_doc_fetch_by_doc_id(
38843895
}
38853896

38863897
error = fts_eval_sql(trx, graph);
3887-
3888-
if (error == DB_SUCCESS) {
3889-
fts_sql_commit(trx);
3890-
} else {
3891-
fts_sql_rollback(trx);
3892-
}
3893-
3898+
fts_sql_commit(trx);
38943899
trx_free_for_background(trx);
38953900

38963901
if (!get_doc) {
@@ -4359,6 +4364,10 @@ fts_sync(
43594364
bool wait,
43604365
bool has_dict)
43614366
{
4367+
if (srv_read_only_mode) {
4368+
return DB_READ_ONLY;
4369+
}
4370+
43624371
ulint i;
43634372
dberr_t error = DB_SUCCESS;
43644373
fts_cache_t* cache = sync->table->fts->cache;
@@ -7355,7 +7364,11 @@ fts_load_stopword(
73557364

73567365
if (!trx) {
73577366
trx = trx_allocate_for_background();
7358-
trx_start_internal(trx);
7367+
if (srv_read_only_mode) {
7368+
trx_start_internal_read_only(trx);
7369+
} else {
7370+
trx_start_internal(trx);
7371+
}
73597372
trx->op_info = "upload FTS stopword";
73607373
new_trx = TRUE;
73617374
}

storage/innobase/fts/fts0opt.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,6 @@ fts_table_fetch_doc_ids(
989989

990990
if (!trx) {
991991
trx = trx_allocate_for_background();
992-
trx_start_internal(trx);
993992
alloc_bk_trx = TRUE;
994993
}
995994

@@ -1018,17 +1017,14 @@ fts_table_fetch_doc_ids(
10181017
"CLOSE c;");
10191018

10201019
error = fts_eval_sql(trx, graph);
1020+
fts_sql_commit(trx);
10211021

10221022
mutex_enter(&dict_sys->mutex);
10231023
que_graph_free(graph);
10241024
mutex_exit(&dict_sys->mutex);
10251025

10261026
if (error == DB_SUCCESS) {
1027-
fts_sql_commit(trx);
1028-
10291027
ib_vector_sort(doc_ids->doc_ids, fts_update_doc_id_cmp);
1030-
} else {
1031-
fts_sql_rollback(trx);
10321028
}
10331029

10341030
if (alloc_bk_trx) {
@@ -2442,6 +2438,10 @@ fts_optimize_table(
24422438
/*===============*/
24432439
dict_table_t* table) /*!< in: table to optimiza */
24442440
{
2441+
if (srv_read_only_mode) {
2442+
return DB_READ_ONLY;
2443+
}
2444+
24452445
dberr_t error = DB_SUCCESS;
24462446
fts_optimize_t* optim = NULL;
24472447
fts_t* fts = table->fts;

0 commit comments

Comments
 (0)