Skip to content

Commit 25323de

Browse files
author
Marko Mäkelä
committed
Bug#20816223 InnoDB crash on shutdown
if XA PREPARE transactions hold explicit locks. innobase_shutdown_for_mysql(): Call trx_sys_close() before lock_sys_close() (and dict_close()) so that trx_free_prepared() will see all locks intact. RB: 8561 Reviewed-by: Vasil Dimov <vasil.dimov@oracle.com>
1 parent 7285b4c commit 25323de

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
2+
INSERT INTO t1 VALUES (1);
3+
XA START 'x';
4+
UPDATE t1 set a=2;
5+
XA END 'x';
6+
XA PREPARE 'x';
7+
call mtr.add_suppression("Found 1 prepared XA transactions");
8+
SELECT * FROM t1 LOCK IN SHARE MODE;
9+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
10+
SELECT * FROM t1;
11+
a
12+
2
13+
XA ROLLBACK 'x';
14+
SELECT * FROM t1;
15+
a
16+
1
17+
DROP TABLE t1;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--source include/have_innodb.inc
2+
3+
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
4+
INSERT INTO t1 VALUES (1);
5+
connect (con1,localhost,root);
6+
XA START 'x'; UPDATE t1 set a=2; XA END 'x'; XA PREPARE 'x';
7+
connection default;
8+
9+
call mtr.add_suppression("Found 1 prepared XA transactions");
10+
11+
# Kill and restart the server.
12+
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
13+
-- shutdown_server 0
14+
-- source include/wait_until_disconnected.inc
15+
16+
-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
17+
-- enable_reconnect
18+
-- source include/wait_until_connected_again.inc
19+
-- disable_reconnect
20+
21+
disconnect con1;
22+
connect (con1,localhost,root);
23+
--send SELECT * FROM t1 LOCK IN SHARE MODE
24+
25+
connection default;
26+
let $wait_condition=
27+
select count(*) = 1 from information_schema.processlist
28+
where state = 'Sending data' and
29+
info = 'SELECT * FROM t1 LOCK IN SHARE MODE';
30+
--source include/wait_condition.inc
31+
32+
--source include/restart_mysqld.inc
33+
34+
disconnect con1;
35+
36+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
37+
SELECT * FROM t1;
38+
XA ROLLBACK 'x';
39+
SELECT * FROM t1;
40+
41+
DROP TABLE t1;

storage/innobase/srv/srv0start.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
3+
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
44
Copyright (c) 2008, Google Inc.
55
Copyright (c) 2009, Percona Inc.
66
@@ -2230,9 +2230,9 @@ innobase_shutdown_for_mysql(void)
22302230

22312231
ibuf_close();
22322232
log_shutdown();
2233-
lock_sys_close();
22342233
trx_sys_file_format_close();
22352234
trx_sys_close();
2235+
lock_sys_close();
22362236

22372237
mutex_free(&srv_monitor_file_mutex);
22382238
mutex_free(&srv_dict_tmpfile_mutex);

0 commit comments

Comments
 (0)