Commit 7baea2ef authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-14905 Fulltext index modification committed during shutdown

If CREATE TABLE...FULLTEXT INDEX was initiated right before shutdown,
then the function fts_load_stopword() could commit modifications
after shutdown was initiated, causing an assertion failure in
the function trx_purge_add_update_undo_to_history().

Mark as internal all the read/write transactions that
modify fulltext indexes, so that they will be ignored by
the assertion that guards against transaction commits
after shutdown has been initiated.

fts_optimize_free(): Invoke trx_commit_for_mysql() just in case,
because in fts_optimize_create() we started the transaction as
internal, and fts_free_for_backgruond() would assert that the
flag is clear. Transaction commit would clear the flag.
parent 5fe9b4a7
...@@ -2699,6 +2699,7 @@ fts_cmp_set_sync_doc_id( ...@@ -2699,6 +2699,7 @@ fts_cmp_set_sync_doc_id(
fts_table.parent = table->name.m_name; fts_table.parent = table->name.m_name;
trx = trx_allocate_for_background(); trx = trx_allocate_for_background();
trx_start_internal(trx);
trx->op_info = "update the next FTS document id"; trx->op_info = "update the next FTS document id";
...@@ -2819,6 +2820,7 @@ fts_update_sync_doc_id( ...@@ -2819,6 +2820,7 @@ fts_update_sync_doc_id(
if (!trx) { if (!trx) {
trx = trx_allocate_for_background(); trx = trx_allocate_for_background();
trx_start_internal(trx);
trx->op_info = "setting last FTS document id"; trx->op_info = "setting last FTS document id";
local_trx = TRUE; local_trx = TRUE;
...@@ -3056,6 +3058,8 @@ fts_commit_table( ...@@ -3056,6 +3058,8 @@ fts_commit_table(
fts_cache_t* cache = ftt->table->fts->cache; fts_cache_t* cache = ftt->table->fts->cache;
trx_t* trx = trx_allocate_for_background(); trx_t* trx = trx_allocate_for_background();
trx_start_internal(trx);
rows = ftt->rows; rows = ftt->rows;
ftt->fts_trx->trx = trx; ftt->fts_trx->trx = trx;
...@@ -3792,6 +3796,7 @@ fts_doc_fetch_by_doc_id( ...@@ -3792,6 +3796,7 @@ fts_doc_fetch_by_doc_id(
trx_t* trx = trx_allocate_for_background(); trx_t* trx = trx_allocate_for_background();
que_t* graph; que_t* graph;
trx_start_internal(trx);
trx->op_info = "fetching indexed FTS document"; trx->op_info = "fetching indexed FTS document";
/* The FTS index can be supplied by caller directly with /* The FTS index can be supplied by caller directly with
...@@ -4138,6 +4143,7 @@ fts_sync_begin( ...@@ -4138,6 +4143,7 @@ fts_sync_begin(
sync->start_time = ut_time(); sync->start_time = ut_time();
sync->trx = trx_allocate_for_background(); sync->trx = trx_allocate_for_background();
trx_start_internal(sync->trx);
if (fts_enable_diag_print) { if (fts_enable_diag_print) {
ib::info() << "FTS SYNC for table " << sync->table->name ib::info() << "FTS SYNC for table " << sync->table->name
...@@ -5008,7 +5014,6 @@ fts_get_rows_count( ...@@ -5008,7 +5014,6 @@ fts_get_rows_count(
char table_name[MAX_FULL_NAME_LEN]; char table_name[MAX_FULL_NAME_LEN];
trx = trx_allocate_for_background(); trx = trx_allocate_for_background();
trx->op_info = "fetching FT table rows count"; trx->op_info = "fetching FT table rows count";
info = pars_info_create(); info = pars_info_create();
...@@ -7350,6 +7355,7 @@ fts_load_stopword( ...@@ -7350,6 +7355,7 @@ fts_load_stopword(
if (!trx) { if (!trx) {
trx = trx_allocate_for_background(); trx = trx_allocate_for_background();
trx_start_internal(trx);
trx->op_info = "upload FTS stopword"; trx->op_info = "upload FTS stopword";
new_trx = TRUE; new_trx = TRUE;
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, MariaDB Corporation. All Rights reserved. Copyright (c) 2016, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -989,6 +989,7 @@ fts_table_fetch_doc_ids( ...@@ -989,6 +989,7 @@ fts_table_fetch_doc_ids(
if (!trx) { if (!trx) {
trx = trx_allocate_for_background(); trx = trx_allocate_for_background();
trx_start_internal(trx);
alloc_bk_trx = TRUE; alloc_bk_trx = TRUE;
} }
...@@ -1619,6 +1620,7 @@ fts_optimize_create( ...@@ -1619,6 +1620,7 @@ fts_optimize_create(
optim->table = table; optim->table = table;
optim->trx = trx_allocate_for_background(); optim->trx = trx_allocate_for_background();
trx_start_internal(optim->trx);
optim->fts_common_table.parent = table->name.m_name; optim->fts_common_table.parent = table->name.m_name;
optim->fts_common_table.table_id = table->id; optim->fts_common_table.table_id = table->id;
...@@ -1741,6 +1743,7 @@ fts_optimize_free( ...@@ -1741,6 +1743,7 @@ fts_optimize_free(
{ {
mem_heap_t* heap = static_cast<mem_heap_t*>(optim->self_heap->arg); mem_heap_t* heap = static_cast<mem_heap_t*>(optim->self_heap->arg);
trx_commit_for_mysql(optim->trx);
trx_free_for_background(optim->trx); trx_free_for_background(optim->trx);
fts_doc_ids_free(optim->to_delete); fts_doc_ids_free(optim->to_delete);
......
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