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.
This commit is contained in:
Marko Mäkelä 2018-02-15 09:46:02 +02:00 committed by Vladislav Vaintroub
parent 6f314edac7
commit 37af958d23
2 changed files with 11 additions and 2 deletions

View file

@ -2699,6 +2699,7 @@ retry:
fts_table.parent = table->name.m_name;
trx = trx_allocate_for_background();
trx_start_internal(trx);
trx->op_info = "update the next FTS document id";
@ -2819,6 +2820,7 @@ fts_update_sync_doc_id(
if (!trx) {
trx = trx_allocate_for_background();
trx_start_internal(trx);
trx->op_info = "setting last FTS document id";
local_trx = TRUE;
@ -3056,6 +3058,8 @@ fts_commit_table(
fts_cache_t* cache = ftt->table->fts->cache;
trx_t* trx = trx_allocate_for_background();
trx_start_internal(trx);
rows = ftt->rows;
ftt->fts_trx->trx = trx;
@ -3792,6 +3796,7 @@ 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
@ -4138,6 +4143,7 @@ fts_sync_begin(
sync->start_time = ut_time();
sync->trx = trx_allocate_for_background();
trx_start_internal(sync->trx);
if (fts_enable_diag_print) {
ib::info() << "FTS SYNC for table " << sync->table->name
@ -5008,7 +5014,6 @@ fts_get_rows_count(
char table_name[MAX_FULL_NAME_LEN];
trx = trx_allocate_for_background();
trx->op_info = "fetching FT table rows count";
info = pars_info_create();
@ -7350,6 +7355,7 @@ fts_load_stopword(
if (!trx) {
trx = trx_allocate_for_background();
trx_start_internal(trx);
trx->op_info = "upload FTS stopword";
new_trx = TRUE;
}

View file

@ -1,7 +1,7 @@
/*****************************************************************************
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
the terms of the GNU General Public License as published by the Free Software
@ -989,6 +989,7 @@ fts_table_fetch_doc_ids(
if (!trx) {
trx = trx_allocate_for_background();
trx_start_internal(trx);
alloc_bk_trx = TRUE;
}
@ -1619,6 +1620,7 @@ fts_optimize_create(
optim->table = table;
optim->trx = trx_allocate_for_background();
trx_start_internal(optim->trx);
optim->fts_common_table.parent = table->name.m_name;
optim->fts_common_table.table_id = table->id;
@ -1741,6 +1743,7 @@ fts_optimize_free(
{
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);
fts_doc_ids_free(optim->to_delete);