From 280bf1782980a59e923196e46c381abecb617d46 Mon Sep 17 00:00:00 2001
From: Thirunarayanan Balathandayuthapani <thiru@mariadb.com>
Date: Thu, 6 Feb 2020 20:42:29 +0530
Subject: MDEV-21563	FTS thread aborts during shutdown

Problem:
=======
After discarding the table, fts_optimize_thread aborts during shutdown.
InnoDB fails to remove the table from fts_optimize_wq and it leads to
the fts_optimize_thread to lookup for the auxiliary table and fails.

Fix:
====
While discarding the fts table, remove the table from fts_optimize_wq.
---
 storage/innobase/row/row0mysql.cc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

(limited to 'storage/innobase')

diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index c6d9909a6fc..47dd94d40c3 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -3205,6 +3205,16 @@ row_discard_tablespace_for_mysql(
 		err = DB_ERROR;
 
 	} else {
+		bool fts_exist = (dict_table_has_fts_index(table)
+				  || DICT_TF2_FLAG_IS_SET(
+					  table, DICT_TF2_FTS_HAS_DOC_ID));
+
+		if (fts_exist) {
+			row_mysql_unlock_data_dictionary(trx);
+			fts_optimize_remove_table(table);
+			row_mysql_lock_data_dictionary(trx);
+		}
+
 		/* Do foreign key constraint checks. */
 
 		err = row_discard_tablespace_foreign_key_checks(trx, table);
@@ -3212,6 +3222,10 @@ row_discard_tablespace_for_mysql(
 		if (err == DB_SUCCESS) {
 			err = row_discard_tablespace(trx, table);
 		}
+
+		if (fts_exist && err != DB_SUCCESS) {
+			fts_optimize_add_table(table);
+		}
 	}
 
 	return(row_discard_tablespace_end(trx, table, err));
-- 
cgit v1.2.1


From 80da23257658ea2c3250f16116eee57c1de63c7f Mon Sep 17 00:00:00 2001
From: Thirunarayanan Balathandayuthapani <thiru@mariadb.com>
Date: Fri, 7 Feb 2020 15:22:16 +0530
Subject: MDEV-21563      FTS thread aborts during shutdown

- Added the test case in innodb_fts suite
- Updated copyright year in row0mysql.cc
---
 storage/innobase/row/row0mysql.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'storage/innobase')

diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index 47dd94d40c3..55befe42b13 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -1,7 +1,7 @@
 /*****************************************************************************
 
 Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2019, MariaDB Corporation.
+Copyright (c) 2015, 2020, 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
-- 
cgit v1.2.1


From e568dc9723e24159330a2848d510fbd2e6974130 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= <marko.makela@mariadb.com>
Date: Sat, 8 Feb 2020 18:58:28 +0200
Subject: Remove unused SRV_MASTER_PURGE_INTERVAL

The symbol SRV_MASTER_PURGE_INTERVAL became unused in
mysql/mysql-server@42f36919584e82c621dbec1e69fd05ab023c54c6
when separate purge threads were introduced in MySQL 5.6.5.
---
 storage/innobase/srv/srv0srv.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

(limited to 'storage/innobase')

diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index af9474dd9b3..f933442f036 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -3,7 +3,7 @@
 Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, 2009 Google Inc.
 Copyright (c) 2009, Percona Inc.
-Copyright (c) 2013, 2019, MariaDB Corporation.
+Copyright (c) 2013, 2020, MariaDB Corporation.
 
 Portions of this file contain modifications contributed and copyrighted by
 Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -527,7 +527,6 @@ current_time % 60 == 0 and no tasks will be performed when
 current_time % 5 != 0. */
 
 # define	SRV_MASTER_CHECKPOINT_INTERVAL		(7)
-# define	SRV_MASTER_PURGE_INTERVAL		(10)
 #ifdef MEM_PERIODIC_CHECK
 # define	SRV_MASTER_MEM_VALIDATE_INTERVAL	(13)
 #endif /* MEM_PERIODIC_CHECK */
-- 
cgit v1.2.1