Skip to content

Commit 37af958

Browse files
dr-mvaintroub
authored andcommitted
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.
1 parent 6f314ed commit 37af958

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

storage/innobase/fts/fts0fts.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2699,6 +2699,7 @@ 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);
27022703

27032704
trx->op_info = "update the next FTS document id";
27042705

@@ -2819,6 +2820,7 @@ fts_update_sync_doc_id(
28192820

28202821
if (!trx) {
28212822
trx = trx_allocate_for_background();
2823+
trx_start_internal(trx);
28222824

28232825
trx->op_info = "setting last FTS document id";
28242826
local_trx = TRUE;
@@ -3056,6 +3058,8 @@ fts_commit_table(
30563058
fts_cache_t* cache = ftt->table->fts->cache;
30573059
trx_t* trx = trx_allocate_for_background();
30583060

3061+
trx_start_internal(trx);
3062+
30593063
rows = ftt->rows;
30603064

30613065
ftt->fts_trx->trx = trx;
@@ -3792,6 +3796,7 @@ fts_doc_fetch_by_doc_id(
37923796
trx_t* trx = trx_allocate_for_background();
37933797
que_t* graph;
37943798

3799+
trx_start_internal(trx);
37953800
trx->op_info = "fetching indexed FTS document";
37963801

37973802
/* The FTS index can be supplied by caller directly with
@@ -4138,6 +4143,7 @@ fts_sync_begin(
41384143
sync->start_time = ut_time();
41394144

41404145
sync->trx = trx_allocate_for_background();
4146+
trx_start_internal(sync->trx);
41414147

41424148
if (fts_enable_diag_print) {
41434149
ib::info() << "FTS SYNC for table " << sync->table->name
@@ -5008,7 +5014,6 @@ fts_get_rows_count(
50085014
char table_name[MAX_FULL_NAME_LEN];
50095015

50105016
trx = trx_allocate_for_background();
5011-
50125017
trx->op_info = "fetching FT table rows count";
50135018

50145019
info = pars_info_create();
@@ -7350,6 +7355,7 @@ fts_load_stopword(
73507355

73517356
if (!trx) {
73527357
trx = trx_allocate_for_background();
7358+
trx_start_internal(trx);
73537359
trx->op_info = "upload FTS stopword";
73547360
new_trx = TRUE;
73557361
}

storage/innobase/fts/fts0opt.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2016, MariaDB Corporation. All Rights reserved.
4+
Copyright (c) 2016, 2018, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -989,6 +989,7 @@ fts_table_fetch_doc_ids(
989989

990990
if (!trx) {
991991
trx = trx_allocate_for_background();
992+
trx_start_internal(trx);
992993
alloc_bk_trx = TRUE;
993994
}
994995

@@ -1619,6 +1620,7 @@ fts_optimize_create(
16191620
optim->table = table;
16201621

16211622
optim->trx = trx_allocate_for_background();
1623+
trx_start_internal(optim->trx);
16221624

16231625
optim->fts_common_table.parent = table->name.m_name;
16241626
optim->fts_common_table.table_id = table->id;
@@ -1741,6 +1743,7 @@ fts_optimize_free(
17411743
{
17421744
mem_heap_t* heap = static_cast<mem_heap_t*>(optim->self_heap->arg);
17431745

1746+
trx_commit_for_mysql(optim->trx);
17441747
trx_free_for_background(optim->trx);
17451748

17461749
fts_doc_ids_free(optim->to_delete);

0 commit comments

Comments
 (0)