From 154bd0950f6691dff22a5e01d4aa68e281ea6092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 3 Sep 2019 11:23:57 +0300 Subject: [PATCH] MDEV-15326 preparation: Test slow shutdown after XA PREPARE We were missing a test that would exercise trx_free_prepared() with innodb_fast_shutdown=0. Add a test. Note: if shutdown hangs due to the XA PREPARE transactions, in MariaDB 10.2 the test would unfortunately pass, but take 2*60 seconds longer, because of two shutdown_server statements timing out after 60 seconds. Starting with MariaDB 10.3, the hung server would be killed with SIGABRT, and the test could fail thanks to a backtrace message. --- .../suite/innodb/r/recovery_shutdown.result | 9 ++++++++- .../suite/innodb/t/recovery_shutdown.test | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/recovery_shutdown.result b/mysql-test/suite/innodb/r/recovery_shutdown.result index 694fd4d9194..d2fd130add8 100644 --- a/mysql-test/suite/innodb/r/recovery_shutdown.result +++ b/mysql-test/suite/innodb/r/recovery_shutdown.result @@ -1,3 +1,5 @@ +FLUSH TABLES; +call mtr.add_suppression("Found 1 prepared XA transactions"); # # MDEV-13797 InnoDB may hang if shutdown is initiated soon after startup # while rolling back recovered incomplete transactions @@ -7,10 +9,12 @@ BEGIN; COMMIT; connect con$c,localhost,root,,; CREATE TABLE t8 (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB; -BEGIN; +XA START 'x'; INSERT INTO t8 (a) SELECT NULL FROM t; UPDATE t8 SET a=a+100, b=a; DELETE FROM t8; +XA END 'x'; +XA PREPARE 'x'; connect con$c,localhost,root,,; CREATE TABLE t7 (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB; BEGIN; @@ -62,4 +66,7 @@ connection default; SET GLOBAL innodb_flush_log_at_trx_commit=1; CREATE TABLE u(a SERIAL) ENGINE=INNODB; FLUSH TABLES; +XA RECOVER; +formatID gtrid_length bqual_length data +1 1 0 x DROP TABLE t,u; diff --git a/mysql-test/suite/innodb/t/recovery_shutdown.test b/mysql-test/suite/innodb/t/recovery_shutdown.test index 50fe4e87c9d..d72e785f21d 100644 --- a/mysql-test/suite/innodb/t/recovery_shutdown.test +++ b/mysql-test/suite/innodb/t/recovery_shutdown.test @@ -1,6 +1,10 @@ --source include/have_innodb.inc --source include/not_embedded.inc +# Flush any open myisam tables from previous tests +FLUSH TABLES; +call mtr.add_suppression("Found 1 prepared XA transactions"); + --echo # --echo # MDEV-13797 InnoDB may hang if shutdown is initiated soon after startup --echo # while rolling back recovered incomplete transactions @@ -20,6 +24,15 @@ dec $c; COMMIT; let $c = $trx; +connect (con$c,localhost,root,,); +eval CREATE TABLE t$c (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB; +XA START 'x'; +eval INSERT INTO t$c (a) SELECT NULL FROM t; +eval UPDATE t$c SET a=a+$size, b=a; +eval DELETE FROM t$c; +XA END 'x'; +XA PREPARE 'x'; +dec $c; while ($c) { connect (con$c,localhost,root,,); @@ -50,12 +63,17 @@ FLUSH TABLES; # Perform a slow shutdown in order to roll back all recovered transactions # and to avoid locking conflicts with the DROP TABLE below. +XA RECOVER; --disable_query_log SET GLOBAL innodb_fast_shutdown=0; --source include/restart_mysqld.inc --disable_query_log let $c = $trx; +disconnect con$c; +XA ROLLBACK 'x'; +eval DROP TABLE t$c; +dec $c; while ($c) { disconnect con$c;