From 70113ee170cbace52d01afdb3ddd4ea5bfa92ebd Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 22 Dec 2015 14:58:02 -0500 Subject: [PATCH 1/3] MDEV-9290 : InnoDB: Assertion failure in file trx0sys.cc line 353 Addendum: Save thd's server_status & option_bits before setting the thread specific pointer. --- sql/mysqld.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index fe74a82a4c6..3e2cc40e181 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4611,19 +4611,19 @@ a file name for --log-bin-index option", opt_binlog_index_name); if (tmp->wsrep_applier == true) { /* - Set THR_THD to temporally point to this THD to register all the + Save/restore server_status and variables.option_bits and they get + altered during init_for_queries(). + */ + unsigned int server_status_saved= tmp->server_status; + ulonglong option_bits_saved= tmp->variables.option_bits; + + /* + Set THR_THD to temporarily point to this THD to register all the variables that allocates memory for this THD. */ THD *current_thd_saved= current_thd; my_pthread_setspecific_ptr(THR_THD, tmp); - /* - Also save/restore server_status and variables.option_bits and they - get altered during init_for_queries(). - */ - unsigned int server_status_saved= tmp->server_status; - ulonglong option_bits_saved= tmp->variables.option_bits; - tmp->init_for_queries(); /* Restore current_thd. */ From fe4047dc39090f626408d91999dd4a8f0869ab13 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 22 Dec 2015 15:02:18 -0500 Subject: [PATCH 2/3] MDEV-9224 : Database lockup on flush in galera A deadlock can occur when the wsrep applier thread while executing FLUSH TABLES waits for MDL lock owned by other local transactions, which in turn are waiting for commit order if their seqno comes after one assigned to FLUSH TABLES. Fixed by making sure that the wsrep applier thread while executing FLUSH TABLES does not wait for table share(s) to be removed from table definition cache. --- sql/sql_reload.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 63809fae7ee..ef699962777 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -313,6 +313,16 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, } } +#ifdef WITH_WSREP + if (thd->wsrep_applier) + { + /* + In case of applier thread, do not wait for table share(s) to be + removed from table definition cache. + */ + options|= REFRESH_FAST; + } +#endif if (close_cached_tables(thd, tables, ((options & REFRESH_FAST) ? FALSE : TRUE), (thd ? thd->variables.lock_wait_timeout : From 89a264809d660fb5a4e7d43e9324b1f529a3a1d7 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 23 Dec 2015 09:51:32 -0500 Subject: [PATCH 3/3] MDEV-9224: postfix - thd can be null in reload_acl_and_cache() --- sql/sql_reload.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index ef699962777..f3909913c5b 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -314,7 +314,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, } #ifdef WITH_WSREP - if (thd->wsrep_applier) + if (thd && thd->wsrep_applier) { /* In case of applier thread, do not wait for table share(s) to be