Debian Codegraph @

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

raw
1 # Bug#13721257 RACE CONDITION IN UPDATES OR INSERTS OF WIDE RECORDS
2 # Test what happens when a record is inserted or updated so that some
3 # columns are stored off-page.
4
5 # The 7000 in this test is a bit less than half the innodb_page_size.
6
7 # DEBUG_SYNC must be compiled in.
8 --source include/have_debug_sync.inc
9
10 # Valgrind would complain about memory leaks when we crash on purpose.
11 --source include/not_valgrind.inc
12 # Avoid CrashReporter popup on Mac
13 --source include/not_crashrep.inc
14
15 CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
16 CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
17 CREATE TABLE t3 (a INT PRIMARY KEY, b TEXT, c TEXT) ENGINE=InnoDB;
18
19 INSERT INTO t1 VALUES (1,REPEAT('a',30000)),(2,REPEAT('b',40000));
20 SET DEBUG_SYNC='before_row_upd_extern SIGNAL have_latch WAIT_FOR go1';
21 BEGIN;
22 # This will not block, because it will not store new BLOBs.
23 UPDATE t1 SET a=a+2;
24 ROLLBACK;
25 BEGIN;
26 --send
27 UPDATE t1 SET b=CONCAT(b,'foo');
28
29 connect (con1,localhost,root,,);
30 SET DEBUG_SYNC='now WAIT_FOR have_latch';
31
32 # this one should block due to the clustered index tree and leaf page latches
33 --send
34 SELECT a, RIGHT(b,20) FROM t1;
35
36 connect (con2,localhost,root,,);
37
38 # Check that the above SELECT is blocked
39 let $wait_condition=
40 select count(*) = 1 from information_schema.processlist
41 where state in ('executing', 'Opening tables') and
42 info = 'SELECT a, RIGHT(b,20) FROM t1';
43 --source include/wait_condition.inc
44
45 SET DEBUG_SYNC='now SIGNAL go1';
46
47 connection con1;
48 reap;
49 connection default;
50 reap;
51 SET DEBUG='+d,row_ins_extern_checkpoint';
52 SET DEBUG_SYNC='before_row_ins_extern_latch SIGNAL rec_not_blob WAIT_FOR crash';
53 ROLLBACK;
54 BEGIN;
55 --send
56 INSERT INTO t1 VALUES (3,REPEAT('c',50000));
57
58 connection con1;
59 SET DEBUG_SYNC='now WAIT_FOR rec_not_blob';
60 SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
61 SELECT @@transaction_isolation;
62
63 # this one should see (3,NULL_BLOB)
64 SELECT a, RIGHT(b,20) FROM t1;
65 SELECT a FROM t1;
66
67 # Request a crash, and restart the server.
68 SET DEBUG='+d,crash_commit_before';
69 # Write file to make mysql-test-run.pl restart the server
70 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
71 --error 2013
72 INSERT INTO t2 VALUES (42);
73
74 disconnect con1;
75 disconnect con2;
76 connection default;
77 # This connection should notice the crash as well.
78 --error 2013
79 reap;
80
81 --enable_reconnect
82 --source include/wait_until_connected_again.inc
83 --disable_reconnect
84
85 CHECK TABLE t1;
86
87 INSERT INTO t3 VALUES
88 (1,REPEAT('d',7000),REPEAT('e',100)),
89 (2,REPEAT('g',7000),REPEAT('h',100));
90 SET DEBUG_SYNC='blob_write_middle SIGNAL go_sel WAIT_FOR go_upd';
91 # This should move column b off-page.
92 --send
93 UPDATE t3 SET c=REPEAT('f',3000) WHERE a=1;
94
95 --echo # Connection con1:
96 connect (con1,localhost,root,,);
97 SET DEBUG_SYNC='now WAIT_FOR go_sel';
98 SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
99 SELECT @@transaction_isolation;
100 SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3;
101 set debug_sync='now SIGNAL go_upd';
102
103 --echo # Connection default:
104 connection default;
105 --echo # reap UPDATE t3 SET c=REPEAT('f',3000) WHERE a=1;
106 reap;
107
108 --echo # Connection con1:
109 connection con1;
110 SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3;
111
112 disconnect con1;
113
114 connection default;
115 CHECK TABLE t1,t2,t3;
116
117 connect (con2,localhost,root,,);
118 BEGIN;
119 INSERT INTO t2 VALUES (347);
120 connection default;
121
122 # The row_upd_extern_checkpoint was removed in Bug#13721257,
123 # because the mini-transaction of the B-tree modification would
124 # remain open while we are writing the off-page columns and are
125 # stuck in the DEBUG_SYNC. A checkpoint involves a flush, which
126 # would wait for the buffer-fix to cease.
127 SET DEBUG='+d,row_upd_extern_checkpoint';
128 SET DEBUG_SYNC='before_row_upd_extern SIGNAL have_latch WAIT_FOR crash';
129 # This should move column b off-page.
130 --send
131 UPDATE t3 SET c=REPEAT('i',3000) WHERE a=2;
132
133 connection con2;
134 SET DEBUG_SYNC='now WAIT_FOR have_latch';
135
136 # Check that the above UPDATE is blocked
137 SELECT info FROM information_schema.processlist
138 WHERE state = 'debug sync point: before_row_upd_extern';
139
140 # Request a crash, and restart the server.
141 SET DEBUG='+d,crash_commit_before';
142 # Write file to make mysql-test-run.pl restart the server
143 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
144 --error 2013
145 COMMIT;
146
147 disconnect con2;
148 connection default;
149 # This connection should notice the crash as well.
150 --error 2013
151 reap;
152
153 --enable_reconnect
154 --source include/wait_until_connected_again.inc
155 --disable_reconnect
156
157 CHECK TABLE t1,t2,t3;
158 SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3;
159 SELECT a FROM t3;
160
161 connect (con2,localhost,root,,);
162 BEGIN;
163 INSERT INTO t2 VALUES (33101);
164 connection default;
165
166 # The row_upd_extern_checkpoint was removed in Bug#13721257,
167 # because the mini-transaction of the B-tree modification would
168 # remain open while we are writing the off-page columns and are
169 # stuck in the DEBUG_SYNC. A checkpoint involves a flush, which
170 # would wait for the buffer-fix to cease.
171 SET DEBUG='+d,row_upd_extern_checkpoint';
172 SET DEBUG_SYNC='after_row_upd_extern SIGNAL have_latch WAIT_FOR crash';
173 # This should move column b off-page.
174 --send
175 UPDATE t3 SET c=REPEAT('j',3000) WHERE a=2;
176
177 connection con2;
178 SET DEBUG_SYNC='now WAIT_FOR have_latch';
179
180 # Check that the above UPDATE is blocked
181 SELECT info FROM information_schema.processlist
182 WHERE state = 'debug sync point: after_row_upd_extern';
183
184 # Request a crash, and restart the server.
185 SET DEBUG='+d,crash_commit_before';
186 # Write file to make mysql-test-run.pl restart the server
187 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
188 --error 2013
189 COMMIT;
190
191 disconnect con2;
192 connection default;
193 # This connection should notice the crash as well.
194 --error 2013
195 reap;
196
197 --enable_reconnect
198 --source include/wait_until_connected_again.inc
199 --disable_reconnect
200
201 CHECK TABLE t1,t2,t3;
202 SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3;
203 SELECT a FROM t3;
204
205 SELECT * FROM t2;
206
207 DROP TABLE t1,t2,t3;
208
209
210 --echo #
211 --echo # Bug #29866408 SERVER CRASHES WHEN ADDING LONGTEXT COLUMN
212 --echo #
213
214 CREATE TABLE t1 (
215 id int(11) COLLATE utf8mb4_unicode_ci NOT NULL,
216 data longtext COLLATE utf8mb4_unicode_ci NOT NULL,
217 PRIMARY KEY (id),
218 UNIQUE KEY unq_id (id)
219 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
220
221 INSERT INTO t1 VALUES (1,'');
222 SET @old_mode=@@sql_mode;
223 SET GLOBAL SQL_MODE="";
224
225 let $num = 3;
226 while($num)
227 {
228 connect (con1,localhost,root,,);
229 connection con1;
230 eval ALTER TABLE t1 ADD COLUMN d$num DATETIME NOT NULL;
231 disconnect con1;
232 dec $num;
233 }
234 connection default;
235 SET GLOBAL SQL_MODE=@old_mode;
236 DROP TABLE t1;