Commit 5ab46028 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 27ea2963
......@@ -2699,7 +2699,11 @@ fts_cmp_set_sync_doc_id(
fts_table.parent = table->name.m_name;
trx = trx_allocate_for_background();
trx_start_internal(trx);
if (srv_read_only_mode) {
trx_start_internal_read_only(trx);
} else {
trx_start_internal(trx);
}
trx->op_info = "update the next FTS document id";
......@@ -2808,6 +2812,10 @@ fts_update_sync_doc_id(
fts_cache_t* cache = table->fts->cache;
char fts_name[MAX_FULL_NAME_LEN];
if (srv_read_only_mode) {
return DB_READ_ONLY;
}
fts_table.suffix = "CONFIG";
fts_table.table_id = table->id;
fts_table.type = FTS_COMMON_TABLE;
......@@ -3052,6 +3060,10 @@ fts_commit_table(
/*=============*/
fts_trx_table_t* ftt) /*!< in: FTS table to commit*/
{
if (srv_read_only_mode) {
return DB_READ_ONLY;
}
const ib_rbt_node_t* node;
ib_rbt_t* rows;
dberr_t error = DB_SUCCESS;
......@@ -3796,7 +3808,6 @@ fts_doc_fetch_by_doc_id(
trx_t* trx = trx_allocate_for_background();
que_t* graph;
trx_start_internal(trx);
trx->op_info = "fetching indexed FTS document";
/* The FTS index can be supplied by caller directly with
......@@ -3884,13 +3895,7 @@ fts_doc_fetch_by_doc_id(
}
error = fts_eval_sql(trx, graph);
if (error == DB_SUCCESS) {
fts_sql_commit(trx);
} else {
fts_sql_rollback(trx);
}
fts_sql_commit(trx);
trx_free_for_background(trx);
if (!get_doc) {
......@@ -4359,6 +4364,10 @@ fts_sync(
bool wait,
bool has_dict)
{
if (srv_read_only_mode) {
return DB_READ_ONLY;
}
ulint i;
dberr_t error = DB_SUCCESS;
fts_cache_t* cache = sync->table->fts->cache;
......@@ -7355,7 +7364,11 @@ fts_load_stopword(
if (!trx) {
trx = trx_allocate_for_background();
trx_start_internal(trx);
if (srv_read_only_mode) {
trx_start_internal_read_only(trx);
} else {
trx_start_internal(trx);
}
trx->op_info = "upload FTS stopword";
new_trx = TRUE;
}
......
......@@ -989,7 +989,6 @@ fts_table_fetch_doc_ids(
if (!trx) {
trx = trx_allocate_for_background();
trx_start_internal(trx);
alloc_bk_trx = TRUE;
}
......@@ -1018,17 +1017,14 @@ fts_table_fetch_doc_ids(
"CLOSE c;");
error = fts_eval_sql(trx, graph);
fts_sql_commit(trx);
mutex_enter(&dict_sys->mutex);
que_graph_free(graph);
mutex_exit(&dict_sys->mutex);
if (error == DB_SUCCESS) {
fts_sql_commit(trx);
ib_vector_sort(doc_ids->doc_ids, fts_update_doc_id_cmp);
} else {
fts_sql_rollback(trx);
}
if (alloc_bk_trx) {
......@@ -2442,6 +2438,10 @@ fts_optimize_table(
/*===============*/
dict_table_t* table) /*!< in: table to optimiza */
{
if (srv_read_only_mode) {
return DB_READ_ONLY;
}
dberr_t error = DB_SUCCESS;
fts_optimize_t* optim = NULL;
fts_t* fts = table->fts;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment