summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-05-07 17:03:47 +0530
committerMarko Mäkelä <marko.makela@mariadb.com>2018-05-16 12:02:39 +0300
commitc7c61ad746de513781c7176f09d0620cb1af1d0f (patch)
treeb19074b1c444a4db49708d3c00f21d24dd40fbe0
parentc17013b58ad21edf3704a9801cf0799333d46179 (diff)
downloadmariadb-git-10.3-MDEV-15855.tar.gz
MDEV-15855 Use MDL in FULLTEXT INDEX sync10.3-MDEV-15855
- fts sync thread allows takes MDL lock on the table instead of dict_operation_lock.
-rw-r--r--mysql-test/suite/innodb/r/purge_thread_shutdown.result4
-rw-r--r--storage/innobase/fts/fts0fts.cc19
-rw-r--r--storage/innobase/fts/fts0opt.cc12
-rw-r--r--storage/innobase/handler/ha_innodb.cc2
4 files changed, 19 insertions, 18 deletions
diff --git a/mysql-test/suite/innodb/r/purge_thread_shutdown.result b/mysql-test/suite/innodb/r/purge_thread_shutdown.result
index 876e2f3107f..2864f5a7385 100644
--- a/mysql-test/suite/innodb/r/purge_thread_shutdown.result
+++ b/mysql-test/suite/innodb/r/purge_thread_shutdown.result
@@ -6,6 +6,7 @@ select user,state from information_schema.processlist order by 2;
user state
root
root Filling schema table
+system user InnoDB fts optimize thread
system user InnoDB purge coordinator
system user InnoDB purge worker
system user InnoDB purge worker
@@ -20,6 +21,7 @@ disconnect con1;
select user,state from information_schema.processlist order by 2;
user state
root Filling schema table
+system user InnoDB fts optimize thread
system user InnoDB purge coordinator
system user InnoDB purge worker
system user InnoDB purge worker
@@ -34,5 +36,5 @@ delete from t1 where a=3;
set global innodb_fast_shutdown=0;
ERROR 42000: Variable 'innodb_fast_shutdown' can't be set to the value of '0'
kill ID;
-ERROR 70ID0: Connection was killed
+ERROR 70100: Connection was killed
drop table t1;
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc
index d874725c374..5388b53569c 100644
--- a/storage/innobase/fts/fts0fts.cc
+++ b/storage/innobase/fts/fts0fts.cc
@@ -202,15 +202,13 @@ FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] sync sync state
@param[in] unlock_cache whether unlock cache lock when write node
@param[in] wait whether wait when a sync is in progress
-@param[in] has_dict whether has dict operation lock
@return DB_SUCCESS if all OK */
static
dberr_t
fts_sync(
fts_sync_t* sync,
bool unlock_cache,
- bool wait,
- bool has_dict);
+ bool wait);
/****************************************************************//**
Release all resources help by the words rb tree e.g., the node ilist. */
@@ -3447,7 +3445,7 @@ fts_add_doc_from_tuple(
if (cache->total_size > fts_max_cache_size / 5
|| fts_need_sync) {
- fts_sync(cache->sync, true, false, false);
+ fts_sync(cache->sync, true, false);
}
mtr_start(&mtr);
@@ -3625,7 +3623,7 @@ fts_add_doc_by_id(
DBUG_EXECUTE_IF(
"fts_instrument_sync_debug",
- fts_sync(cache->sync, true, true, false);
+ fts_sync(cache->sync, true, true);
);
DEBUG_SYNC_C("fts_instrument_sync_request");
@@ -4339,8 +4337,7 @@ dberr_t
fts_sync(
fts_sync_t* sync,
bool unlock_cache,
- bool wait,
- bool has_dict)
+ bool wait)
{
if (srv_read_only_mode) {
return DB_READ_ONLY;
@@ -4373,12 +4370,6 @@ fts_sync(
DEBUG_SYNC_C("fts_sync_begin");
fts_sync_begin(sync);
- /* When sync in background, we hold dict operation lock
- to prevent DDL like DROP INDEX, etc. */
- if (has_dict) {
- sync->trx->dict_operation_lock_mode = RW_S_LATCH;
- }
-
begin_sync:
if (cache->total_size > fts_max_cache_size) {
/* Avoid the case: sync never finish when
@@ -4489,7 +4480,7 @@ fts_sync_table(
if (table->space && table->fts->cache
&& !dict_table_is_corrupted(table)) {
err = fts_sync(table->fts->cache->sync,
- unlock_cache, wait, has_dict);
+ unlock_cache, wait);
}
return(err);
diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc
index 4d93451a40d..c07f18f732d 100644
--- a/storage/innobase/fts/fts0opt.cc
+++ b/storage/innobase/fts/fts0opt.cc
@@ -2958,15 +2958,18 @@ fts_optimize_sync_table(
table_id_t table_id)
{
dict_table_t* table = NULL;
+ MDL_ticket* mdl = NULL;
+ THD* fts_optimize_thd = current_thd;
- table = dict_table_open_on_id(table_id, FALSE, DICT_TABLE_OP_NORMAL);
+ table = dict_table_open_on_id(table_id, FALSE, DICT_TABLE_OP_NORMAL,
+ fts_optimize_thd, &mdl);
if (table) {
if (dict_table_has_fts_index(table) && table->fts->cache) {
fts_sync_table(table, true, false, true);
}
- dict_table_close(table, FALSE, FALSE);
+ dict_table_close(table, false, false, fts_optimize_thd, mdl);
}
}
@@ -2987,6 +2990,8 @@ DECLARE_THREAD(fts_optimize_thread)(
ut_ad(!srv_read_only_mode);
my_thread_init();
+ THD* thd = innobase_create_background_thd(
+ "InnoDB fts optimize thread");
ut_ad(fts_slots);
@@ -3127,6 +3132,9 @@ DECLARE_THREAD(fts_optimize_thread)(
ib::info() << "FTS optimize thread exiting.";
os_event_set(fts_opt_shutdown_event);
+
+ innobase_destroy_background_thd(thd);
+
my_thread_end();
/* We count the number of threads in os_thread_exit(). A created
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 7c9be6b6f96..647fb18b9e2 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -317,7 +317,7 @@ thd_destructor_proxy(void *)
while (srv_fast_shutdown == 0 &&
(trx_sys.any_active_transactions() ||
- (uint)thread_count > srv_n_purge_threads + 2)) {
+ (uint)thread_count > srv_n_purge_threads + 3)) {
thd_proc_info(thd, "InnoDB slow shutdown wait");
os_thread_sleep(1000);
}