Debian Codegraph @

mysql-test/suite/innodb/t/innodb_bug53756.test

raw
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.
6
7 #
8 #
9 # This test case needs to crash the server. Needs a debug server.
10 --source include/have_debug.inc
11 #
12 # Don't test this under valgrind, memory leaks will occur.
13 --source include/not_valgrind.inc
14 #
15 # This test case needs InnoDB.
16
17 # Avoid CrashReporter popup on Mac
18 --source include/not_crashrep.inc
19
20 #
21 # Precautionary clean up.
22 #
23 --disable_warnings
24 DROP TABLE IF EXISTS bug_53756 ;
25 --enable_warnings
26
27 #
28 # Create test data.
29 #
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);
33
34 --echo
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.transaction_isolation`
38 --let $session_isolation= `SELECT @@session.transaction_isolation`
39 SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
40 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
41 COMMIT;
42
43 --echo
44 --echo # Start a transaction in the default connection for isolation.
45 START TRANSACTION;
46 SELECT @@transaction_isolation;
47 SELECT * FROM bug_53756;
48
49 --echo
50 --echo # connection con1 deletes row 1
51 --connect (con1,localhost,root,,)
52 START TRANSACTION;
53 SELECT @@transaction_isolation;
54 DELETE FROM bug_53756 WHERE pk=1;
55
56 --echo
57 --echo # connection con2 deletes row 2
58 --connect (con2,localhost,root,,)
59 START TRANSACTION;
60 SELECT @@transaction_isolation;
61 DELETE FROM bug_53756 WHERE pk=2;
62
63 --echo
64 --echo # connection con3 updates row 3
65 --connect (con3,localhost,root,,)
66 START TRANSACTION;
67 SELECT @@transaction_isolation;
68 UPDATE bug_53756 SET c1=77 WHERE pk=3;
69
70 --echo
71 --echo # connection con4 updates row 4
72 --connect (con4,localhost,root,,)
73 START TRANSACTION;
74 SELECT @@transaction_isolation;
75 UPDATE bug_53756 SET c1=88 WHERE pk=4;
76
77 --echo
78 --echo # connection con5 inserts row 5
79 --connect (con5,localhost,root,,)
80 START TRANSACTION;
81 SELECT @@transaction_isolation;
82 INSERT INTO bug_53756 VALUES(5, 55);
83
84 --echo
85 --echo # connection con6 inserts row 6
86 --connect (con6,localhost,root,,)
87 START TRANSACTION;
88 SELECT @@transaction_isolation;
89 INSERT INTO bug_53756 VALUES(6, 66);
90
91 --echo
92 --echo # connection con1 commits.
93 --connection con1
94 COMMIT;
95
96 --echo
97 --echo # connection con3 commits.
98 --connection con3
99 COMMIT;
100
101 --echo
102 --echo # connection con4 rolls back.
103 --connection con4
104 ROLLBACK;
105
106 --echo
107 --echo # connection con6 rolls back.
108 --connection con6
109 ROLLBACK;
110
111 --echo
112 --echo # The connections 2 and 5 stay open.
113
114 --echo
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.
120 --connection default
121 SELECT * FROM bug_53756;
122
123 --echo
124 --echo # connection default
125 --connection default
126 --echo #
127 --echo # Crash server.
128 #
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
132 #
133 START TRANSACTION;
134 INSERT INTO bug_53756 VALUES (666,666);
135 #
136 # Request a crash on next execution of commit.
137 SET SESSION debug="+d,crash_commit_before";
138 #
139 # Write file to make mysql-test-run.pl start up the server again
140 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
141 #
142 # Execute the statement that causes the crash.
143 --error 2013
144 COMMIT;
145 --echo
146 --echo #
147 --echo # disconnect con1, con2, con3, con4, con5, con6.
148 --disconnect con1
149 --disconnect con2
150 --disconnect con3
151 --disconnect con4
152 --disconnect con5
153 --disconnect con6
154 --echo #
155 --echo # Restart server.
156 #
157 # Turn on reconnect
158 --enable_reconnect
159 #
160 # Call script that will poll the server waiting for it to be back online again
161 --source include/wait_until_connected_again.inc
162 #
163 # Turn off reconnect again
164 --disable_reconnect
165 --echo
166
167 --echo #
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;
175
176 --echo
177 --echo # Clean up.
178 DROP TABLE bug_53756;
179
180 --disable_query_log
181 eval SET GLOBAL transaction_isolation= '$global_isolation';
182 eval SET SESSION transaction_isolation= '$session_isolation';
183 --enable_query_log
184