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.
9
# This test case needs to crash the server. Needs a debug server.
10
--source include/have_debug.inc
12
# Don't test this under valgrind, memory leaks will occur.
13
--source include/not_valgrind.inc
15
# This test case needs InnoDB.
16
--source include/have_innodb.inc
19
# Precautionary clean up.
22
DROP TABLE IF EXISTS bug_53756 ;
28
CREATE TABLE bug_53756 (pk INT, c1 INT) ENGINE=InnoDB;
29
ALTER TABLE bug_53756 ADD PRIMARY KEY (pk);
30
INSERT INTO bug_53756 VALUES(1, 11), (2, 22), (3, 33), (4, 44);
33
--echo # Select a less restrictive isolation level.
34
# Don't use user variables. They won't survive server crash.
35
--let $global_isolation= `SELECT @@global.tx_isolation`
36
--let $session_isolation= `SELECT @@session.tx_isolation`
37
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
38
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
42
--echo # Start a transaction in the default connection for isolation.
44
SELECT @@tx_isolation;
45
SELECT * FROM bug_53756;
48
--echo # connection con1 deletes row 1
49
--connect (con1,localhost,root,,)
51
SELECT @@tx_isolation;
52
DELETE FROM bug_53756 WHERE pk=1;
55
--echo # connection con2 deletes row 2
56
--connect (con2,localhost,root,,)
58
SELECT @@tx_isolation;
59
DELETE FROM bug_53756 WHERE pk=2;
62
--echo # connection con3 updates row 3
63
--connect (con3,localhost,root,,)
65
SELECT @@tx_isolation;
66
UPDATE bug_53756 SET c1=77 WHERE pk=3;
69
--echo # connection con4 updates row 4
70
--connect (con4,localhost,root,,)
72
SELECT @@tx_isolation;
73
UPDATE bug_53756 SET c1=88 WHERE pk=4;
76
--echo # connection con5 inserts row 5
77
--connect (con5,localhost,root,,)
79
SELECT @@tx_isolation;
80
INSERT INTO bug_53756 VALUES(5, 55);
83
--echo # connection con6 inserts row 6
84
--connect (con6,localhost,root,,)
86
SELECT @@tx_isolation;
87
INSERT INTO bug_53756 VALUES(6, 66);
90
--echo # connection con1 commits.
95
--echo # connection con3 commits.
100
--echo # connection con4 rolls back.
105
--echo # connection con6 rolls back.
110
--echo # The connections 2 and 5 stay open.
113
--echo # connection default selects resulting data.
114
--echo # Delete of row 1 was committed.
115
--echo # Update of row 3 was committed.
116
--echo # Due to isolation level read committed, these should be included.
117
--echo # All other changes should not be included.
119
SELECT * FROM bug_53756;
122
--echo # connection default
125
--echo # Crash server.
127
# Write file to make mysql-test-run.pl expect the "crash", but don't start
128
# it until it's told to
129
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
132
INSERT INTO bug_53756 VALUES (666,666);
134
# Request a crash on next execution of commit.
135
SET SESSION debug="+d,crash_commit_before";
137
# Execute the statement that causes the crash.
142
--echo # disconnect con1, con2, con3, con4, con5, con6.
150
--echo # Restart server.
152
# Write file to make mysql-test-run.pl start up the server again
153
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
158
# Call script that will poll the server waiting for it to be back online again
159
--source include/wait_until_connected_again.inc
161
# Turn off reconnect again
166
--echo # Select recovered data.
167
--echo # Delete of row 1 was committed.
168
--echo # Update of row 3 was committed.
169
--echo # These should be included.
170
--echo # All other changes should not be included.
171
--echo # Delete of row 2 and insert of row 5 should be rolled back
172
SELECT * FROM bug_53756;
176
DROP TABLE bug_53756;
179
eval SET GLOBAL tx_isolation= '$global_isolation';
180
eval SET SESSION tx_isolation= '$session_isolation';