1
# This is the test case for bug #53756. Alter table operation could
2
# leave a deleted record for the temp table (later renamed to the altered
3
# table) in the SYS_TABLES secondary index, we should ignore this row and
4
# find the first non-deleted row for the specified table_id when load table
5
# metadata in the function dict_load_table_on_id() during crash recovery.
8
# innobackup needs to connect to the server. Not supported in embedded.
9
--source include/not_embedded.inc
11
# This test case needs to crash the server. Needs a debug server.
12
--source include/have_debug.inc
14
# Don't test this under valgrind, memory leaks will occur.
15
--source include/not_valgrind.inc
17
# This test case needs InnoDB.
18
--source include/have_innodb.inc
21
# Precautionary clean up.
24
DROP TABLE IF EXISTS bug_53756 ;
30
CREATE TABLE bug_53756 (pk INT, c1 INT) ENGINE=InnoDB;
31
ALTER TABLE bug_53756 ADD PRIMARY KEY (pk);
32
INSERT INTO bug_53756 VALUES(1, 11), (2, 22), (3, 33), (4, 44);
35
--echo # Select a less restrictive isolation level.
36
# Don't use user variables. They won't survive server crash.
37
--let $global_isolation= `SELECT @@global.tx_isolation`
38
--let $session_isolation= `SELECT @@session.tx_isolation`
39
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
40
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
44
--echo # Start a transaction in the default connection for isolation.
46
SELECT @@tx_isolation;
47
SELECT * FROM bug_53756;
50
--echo # connection con1 deletes row 1
51
--connect (con1,localhost,root,,)
53
SELECT @@tx_isolation;
54
DELETE FROM bug_53756 WHERE pk=1;
57
--echo # connection con2 deletes row 2
58
--connect (con2,localhost,root,,)
60
SELECT @@tx_isolation;
61
DELETE FROM bug_53756 WHERE pk=2;
64
--echo # connection con3 updates row 3
65
--connect (con3,localhost,root,,)
67
SELECT @@tx_isolation;
68
UPDATE bug_53756 SET c1=77 WHERE pk=3;
71
--echo # connection con4 updates row 4
72
--connect (con4,localhost,root,,)
74
SELECT @@tx_isolation;
75
UPDATE bug_53756 SET c1=88 WHERE pk=4;
78
--echo # connection con5 inserts row 5
79
--connect (con5,localhost,root,,)
81
SELECT @@tx_isolation;
82
INSERT INTO bug_53756 VALUES(5, 55);
85
--echo # connection con6 inserts row 6
86
--connect (con6,localhost,root,,)
88
SELECT @@tx_isolation;
89
INSERT INTO bug_53756 VALUES(6, 66);
92
--echo # connection con1 commits.
97
--echo # connection con3 commits.
102
--echo # connection con4 rolls back.
107
--echo # connection con6 rolls back.
112
--echo # The connections 2 and 5 stay open.
115
--echo # connection default selects resulting data.
116
--echo # Delete of row 1 was committed.
117
--echo # Update of row 3 was committed.
118
--echo # Due to isolation level read committed, these should be included.
119
--echo # All other changes should not be included.
121
SELECT * FROM bug_53756;
124
--echo # connection default
127
--echo # Crash server.
129
# Write file to make mysql-test-run.pl expect the "crash", but don't start
130
# it until it's told to
131
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
134
INSERT INTO bug_53756 VALUES (666,666);
136
# Request a crash on next execution of commit.
137
SET SESSION debug="+d,crash_commit_before";
139
# Execute the statement that causes the crash.
140
--error ER_LOCK_DEADLOCK
144
--echo # disconnect con1, con2, con3, con4, con5, con6.
152
--echo # Restart server.
154
# Write file to make mysql-test-run.pl start up the server again
155
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
160
# Call script that will poll the server waiting for it to be back online again
161
--source include/wait_until_connected_again.inc
163
# Turn off reconnect again
168
--echo # Select recovered data.
169
--echo # Delete of row 1 was committed.
170
--echo # Update of row 3 was committed.
171
--echo # These should be included.
172
--echo # All other changes should not be included.
173
--echo # Delete of row 2 and insert of row 5 should be rolled back
174
SELECT * FROM bug_53756;
178
DROP TABLE bug_53756;
181
eval SET GLOBAL tx_isolation= '$global_isolation';
182
eval SET SESSION tx_isolation= '$session_isolation';