From 6ef139780d7a6ae6ea001523b4505de6b5c3a7bc Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 29 Jul 2014 09:09:52 +0200 Subject: [PATCH] MDEV-6497 InnoDB deadlocks on UNINSTALL PLUGIN Free the trx of the current thd (if any) in innobase_end() --- mysql-test/r/innodb_load_xa.result | 13 +++++++++++++ mysql-test/t/innodb_load_xa.test | 7 +++++++ storage/innobase/handler/ha_innodb.cc | 8 ++++++++ storage/xtradb/handler/ha_innodb.cc | 8 ++++++++ 4 files changed, 36 insertions(+) diff --git a/mysql-test/r/innodb_load_xa.result b/mysql-test/r/innodb_load_xa.result index 7ce2fb6c48f..e738ca6e3af 100644 --- a/mysql-test/r/innodb_load_xa.result +++ b/mysql-test/r/innodb_load_xa.result @@ -4,4 +4,17 @@ Warning 1105 Cannot enable tc-log at run-time. XA features of InnoDB are disable select engine,support,transactions,xa from information_schema.engines where engine='innodb'; engine support transactions xa InnoDB YES YES NO +create table t1 (a int) engine=innodb; +start transaction; +insert t1 values (1); +insert t1 values (2); +commit; +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-bin.000001 # Query # # use `test`; create table t1 (a int) engine=innodb +mysqld-bin.000001 # Query # # BEGIN +mysqld-bin.000001 # Query # # use `test`; insert t1 values (1) +mysqld-bin.000001 # Query # # use `test`; insert t1 values (2) +mysqld-bin.000001 # Query # # COMMIT +drop table t1; uninstall plugin innodb; diff --git a/mysql-test/t/innodb_load_xa.test b/mysql-test/t/innodb_load_xa.test index ab2204133a2..52862151b22 100644 --- a/mysql-test/t/innodb_load_xa.test +++ b/mysql-test/t/innodb_load_xa.test @@ -8,4 +8,11 @@ if (!$HA_INNODB_SO) { } install plugin innodb soname 'ha_innodb'; select engine,support,transactions,xa from information_schema.engines where engine='innodb'; +create table t1 (a int) engine=innodb; +start transaction; +insert t1 values (1); +insert t1 values (2); +commit; +--source include/show_binlog_events.inc +drop table t1; uninstall plugin innodb; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 2e837e80fcd..2c2e2dcd6d6 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2658,6 +2658,14 @@ innobase_end( if (innodb_inited) { + THD *thd= current_thd; + if (thd) { // may be UNINSTALL PLUGIN statement + trx_t* trx = thd_to_trx(thd); + if (trx) { + trx_free_for_mysql(trx); + } + } + srv_fast_shutdown = (ulint) innobase_fast_shutdown; innodb_inited = 0; hash_table_free(innobase_open_tables); diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 539e0ca8d7e..510292fefc5 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -3276,6 +3276,14 @@ innobase_end( if (innodb_inited) { + THD *thd= current_thd; + if (thd) { // may be UNINSTALL PLUGIN statement + trx_t* trx = thd_to_trx(thd); + if (trx) { + trx_free_for_mysql(trx); + } + } + srv_fast_shutdown = (ulint) innobase_fast_shutdown; innodb_inited = 0; hash_table_free(innobase_open_tables);