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
20
# Avoid CrashReporter popup on Mac
21
--source include/not_crashrep.inc
24
# Precautionary clean up.
27
DROP TABLE IF EXISTS bug_53756 ;
33
CREATE TABLE bug_53756 (pk INT, c1 INT) ENGINE=InnoDB;
34
ALTER TABLE bug_53756 ADD PRIMARY KEY (pk);
35
INSERT INTO bug_53756 VALUES(1, 11), (2, 22), (3, 33), (4, 44);
38
--echo # Select a less restrictive isolation level.
39
# Don't use user variables. They won't survive server crash.
40
--let $global_isolation= `SELECT @@global.tx_isolation`
41
--let $session_isolation= `SELECT @@session.tx_isolation`
42
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
43
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
47
--echo # Start a transaction in the default connection for isolation.
49
SELECT @@tx_isolation;
50
SELECT * FROM bug_53756;
53
--echo # connection con1 deletes row 1
54
--connect (con1,localhost,root,,)
56
SELECT @@tx_isolation;
57
DELETE FROM bug_53756 WHERE pk=1;
60
--echo # connection con2 deletes row 2
61
--connect (con2,localhost,root,,)
63
SELECT @@tx_isolation;
64
DELETE FROM bug_53756 WHERE pk=2;
67
--echo # connection con3 updates row 3
68
--connect (con3,localhost,root,,)
70
SELECT @@tx_isolation;
71
UPDATE bug_53756 SET c1=77 WHERE pk=3;
74
--echo # connection con4 updates row 4
75
--connect (con4,localhost,root,,)
77
SELECT @@tx_isolation;
78
UPDATE bug_53756 SET c1=88 WHERE pk=4;
81
--echo # connection con5 inserts row 5
82
--connect (con5,localhost,root,,)
84
SELECT @@tx_isolation;
85
INSERT INTO bug_53756 VALUES(5, 55);
88
--echo # connection con6 inserts row 6
89
--connect (con6,localhost,root,,)
91
SELECT @@tx_isolation;
92
INSERT INTO bug_53756 VALUES(6, 66);
95
--echo # connection con1 commits.
100
--echo # connection con3 commits.
105
--echo # connection con4 rolls back.
110
--echo # connection con6 rolls back.
115
--echo # The connections 2 and 5 stay open.
118
--echo # connection default selects resulting data.
119
--echo # Delete of row 1 was committed.
120
--echo # Update of row 3 was committed.
121
--echo # Due to isolation level read committed, these should be included.
122
--echo # All other changes should not be included.
124
SELECT * FROM bug_53756;
127
--echo # connection default
130
--echo # Crash server.
132
# Write file to make mysql-test-run.pl expect the "crash", but don't start
133
# it until it's told to
134
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
137
INSERT INTO bug_53756 VALUES (666,666);
139
# Request a crash on next execution of commit.
140
SET SESSION debug="+d,crash_commit_before";
142
# Execute the statement that causes the crash.
147
--echo # disconnect con1, con2, con3, con4, con5, con6.
155
--echo # Restart server.
157
# Write file to make mysql-test-run.pl start up the server again
158
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
163
# Call script that will poll the server waiting for it to be back online again
164
--source include/wait_until_connected_again.inc
166
# Turn off reconnect again
171
--echo # Select recovered data.
172
--echo # Delete of row 1 was committed.
173
--echo # Update of row 3 was committed.
174
--echo # These should be included.
175
--echo # All other changes should not be included.
176
--echo # Delete of row 2 and insert of row 5 should be rolled back
177
SELECT * FROM bug_53756;
181
DROP TABLE bug_53756;
184
eval SET GLOBAL tx_isolation= '$global_isolation';
185
eval SET SESSION tx_isolation= '$session_isolation';