| 1 |
# |
| 2 |
# WL#6501: make truncate table atomic |
| 3 |
# |
| 4 |
|
| 5 |
--source include/have_debug.inc |
| 6 |
--source include/big_test.inc |
| 7 |
|
| 8 |
# Valgrind would complain about memory leaks when we crash on purpose. |
| 9 |
--source include/not_valgrind.inc |
| 10 |
# Avoid CrashReporter popup on Mac |
| 11 |
--source include/not_crashrep.inc |
| 12 |
|
| 13 |
# suppress expected warnings. |
| 14 |
call mtr.add_suppression("The file '.*' already exists though the corresponding table did not exist in the InnoDB data dictionary"); |
| 15 |
call mtr.add_suppression("Cannot create file '.*'"); |
| 16 |
call mtr.add_suppression("InnoDB: Error number 17 means 'File exists'"); |
| 17 |
|
| 18 |
################################################################################ |
| 19 |
# |
| 20 |
# Will test following scenarios: |
| 21 |
# 1. Hit crash point while writing redo log. |
| 22 |
# 2. Hit crash point on completion of redo log write. |
| 23 |
# 3. Hit crash point while dropping indexes. |
| 24 |
# 4. Hit crash point on completing drop of all indexes before creation of index |
| 25 |
# is commenced. |
| 26 |
# 5. Hit crash point while creating indexes. |
| 27 |
# 6. Hit crash point after data is updated to system-table and in-memory dict. |
| 28 |
# 7. Hit crash point before/after log checkpoint is done. |
| 29 |
# |
| 30 |
################################################################################ |
| 31 |
|
| 32 |
#----------------------------------------------------------------------------- |
| 33 |
# |
| 34 |
# create test-bed |
| 35 |
# |
| 36 |
let $per_table = `select @@innodb_file_per_table`; |
| 37 |
|
| 38 |
eval set global innodb_file_per_table = on; |
| 39 |
let $WL6501_TMP_DIR = `select @@tmpdir`; |
| 40 |
let $WL6501_DATA_DIR = `select @@datadir`; |
| 41 |
let SEARCH_FILE = $MYSQLTEST_VARDIR/log/my_restart.err; |
| 42 |
|
| 43 |
#----------------------------------------------------------------------------- |
| 44 |
# |
| 45 |
# 1. Hit crash point while writing redo log. |
| 46 |
# |
| 47 |
--echo "1. Hit crash point while writing redo log." |
| 48 |
use test; |
| 49 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 50 |
SET innodb_strict_mode=OFF; |
| 51 |
--disable_warnings |
| 52 |
eval create $wl6501_temp table t ( |
| 53 |
i int, f float, c char, |
| 54 |
primary key pk(i), unique findex(f), index ck(c)) |
| 55 |
engine=innodb row_format=$wl6501_row_fmt |
| 56 |
key_block_size=$wl6501_kbs; |
| 57 |
--enable_warnings |
| 58 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 59 |
select * from t; |
| 60 |
check table t; |
| 61 |
# |
| 62 |
set session debug = "+d,ib_trunc_crash_while_writing_redo_log"; |
| 63 |
--source include/expect_crash.inc |
| 64 |
--error 2013 |
| 65 |
truncate table t; |
| 66 |
# |
| 67 |
--source include/start_mysqld.inc |
| 68 |
check table t; |
| 69 |
select * from t; |
| 70 |
select * from t where f < 2.5; |
| 71 |
drop table t; |
| 72 |
|
| 73 |
#----------------------------------------------------------------------------- |
| 74 |
# |
| 75 |
# 2. Hit crash point on completion of redo log write. |
| 76 |
# |
| 77 |
--echo "2. Hit crash point on completion of redo log write." |
| 78 |
use test; |
| 79 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 80 |
SET innodb_strict_mode=OFF; |
| 81 |
--disable_warnings |
| 82 |
eval create $wl6501_temp table t ( |
| 83 |
i int, f float, c char, |
| 84 |
primary key pk(i), unique findex(f), index ck(c)) |
| 85 |
engine = innodb row_format = $wl6501_row_fmt |
| 86 |
key_block_size = $wl6501_kbs; |
| 87 |
--enable_warnings |
| 88 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 89 |
select * from t; |
| 90 |
check table t; |
| 91 |
# |
| 92 |
set session debug = "+d,ib_trunc_crash_after_redo_log_write_complete"; |
| 93 |
--source include/expect_crash.inc |
| 94 |
--error 2013 |
| 95 |
truncate table t; |
| 96 |
# |
| 97 |
--source include/start_mysqld.inc |
| 98 |
check table t; |
| 99 |
select * from t; |
| 100 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 101 |
select * from t; |
| 102 |
select * from t where f < 2.5; |
| 103 |
drop table t; |
| 104 |
|
| 105 |
#----------------------------------------------------------------------------- |
| 106 |
# |
| 107 |
# 3. Hit crash point while dropping indexes. |
| 108 |
# |
| 109 |
--echo "3. Hit crash point while dropping indexes." |
| 110 |
use test; |
| 111 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 112 |
SET innodb_strict_mode=OFF; |
| 113 |
--disable_warnings |
| 114 |
eval create $wl6501_temp table t ( |
| 115 |
i int, f float, c char, |
| 116 |
primary key pk(i), unique findex(f), index ck(c)) |
| 117 |
engine = innodb row_format = $wl6501_row_fmt |
| 118 |
key_block_size = $wl6501_kbs; |
| 119 |
--enable_warnings |
| 120 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 121 |
select * from t; |
| 122 |
check table t; |
| 123 |
# |
| 124 |
set session debug = "+d,ib_trunc_crash_on_drop_of_clust_index"; |
| 125 |
--source include/expect_crash.inc |
| 126 |
--error 2013 |
| 127 |
truncate table t; |
| 128 |
# |
| 129 |
--source include/start_mysqld.inc |
| 130 |
check table t; |
| 131 |
select * from t; |
| 132 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 133 |
select * from t; |
| 134 |
select * from t where f < 2.5; |
| 135 |
drop table t; |
| 136 |
# |
| 137 |
# |
| 138 |
use test; |
| 139 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 140 |
SET innodb_strict_mode=OFF; |
| 141 |
--disable_warnings |
| 142 |
eval create $wl6501_temp table t ( |
| 143 |
i int, f float, c char, |
| 144 |
primary key pk(i), unique findex(f)) |
| 145 |
engine = innodb row_format = $wl6501_row_fmt |
| 146 |
key_block_size = $wl6501_kbs; |
| 147 |
--enable_warnings |
| 148 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 149 |
select * from t; |
| 150 |
check table t; |
| 151 |
# |
| 152 |
set session debug = "+d,ib_trunc_crash_on_drop_of_uniq_index"; |
| 153 |
--source include/expect_crash.inc |
| 154 |
--error 2013 |
| 155 |
truncate table t; |
| 156 |
# |
| 157 |
--source include/start_mysqld.inc |
| 158 |
# |
| 159 |
check table t; |
| 160 |
select * from t; |
| 161 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 162 |
select * from t; |
| 163 |
select * from t where f < 2.5; |
| 164 |
drop table t; |
| 165 |
# |
| 166 |
# |
| 167 |
use test; |
| 168 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 169 |
SET innodb_strict_mode=OFF; |
| 170 |
--disable_warnings |
| 171 |
eval create $wl6501_temp table t ( |
| 172 |
i int, f float, c char, |
| 173 |
primary key pk(i), index ck(c)) |
| 174 |
engine = innodb row_format = $wl6501_row_fmt |
| 175 |
key_block_size = $wl6501_kbs; |
| 176 |
--enable_warnings |
| 177 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 178 |
select * from t; |
| 179 |
check table t; |
| 180 |
# |
| 181 |
set session debug = "+d,ib_trunc_crash_on_drop_of_sec_index"; |
| 182 |
--source include/expect_crash.inc |
| 183 |
--error 2013 |
| 184 |
truncate table t; |
| 185 |
# |
| 186 |
--source include/start_mysqld.inc |
| 187 |
check table t; |
| 188 |
select * from t; |
| 189 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 190 |
select * from t; |
| 191 |
select * from t where f < 2.5; |
| 192 |
drop table t; |
| 193 |
|
| 194 |
#----------------------------------------------------------------------------- |
| 195 |
# |
| 196 |
# 4. Hit crash point on completing drop of all indexes before creation of index |
| 197 |
# is commenced. |
| 198 |
# |
| 199 |
--echo "4. Hit crash point on completing drop of all indexes before creation" |
| 200 |
--echo " of index is commenced." |
| 201 |
use test; |
| 202 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 203 |
SET innodb_strict_mode=OFF; |
| 204 |
--disable_warnings |
| 205 |
eval create $wl6501_temp table t ( |
| 206 |
i int, f float, c char, |
| 207 |
primary key pk(i), unique findex(f), index ck(c)) |
| 208 |
engine = innodb row_format = $wl6501_row_fmt |
| 209 |
key_block_size = $wl6501_kbs; |
| 210 |
--enable_warnings |
| 211 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 212 |
select * from t; |
| 213 |
check table t; |
| 214 |
# |
| 215 |
set session debug = "+d,ib_trunc_crash_drop_reinit_done_create_to_start"; |
| 216 |
--source include/expect_crash.inc |
| 217 |
--error 2013 |
| 218 |
truncate table t; |
| 219 |
# |
| 220 |
--source include/start_mysqld.inc |
| 221 |
check table t; |
| 222 |
select * from t; |
| 223 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 224 |
select * from t; |
| 225 |
select * from t where f < 2.5; |
| 226 |
drop table t; |
| 227 |
|
| 228 |
#----------------------------------------------------------------------------- |
| 229 |
# |
| 230 |
# 5. Hit crash point while creating indexes. |
| 231 |
# |
| 232 |
--echo "5. Hit crash point while creating indexes." |
| 233 |
use test; |
| 234 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 235 |
SET innodb_strict_mode=OFF; |
| 236 |
--disable_warnings |
| 237 |
eval create $wl6501_temp table t ( |
| 238 |
i int, f float, c char, |
| 239 |
primary key pk(i), unique findex(f), index ck(c)) |
| 240 |
engine = innodb row_format = $wl6501_row_fmt |
| 241 |
key_block_size = $wl6501_kbs; |
| 242 |
--enable_warnings |
| 243 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 244 |
select * from t; |
| 245 |
check table t; |
| 246 |
# |
| 247 |
set session debug = "+d,ib_trunc_crash_on_create_of_clust_index"; |
| 248 |
--source include/expect_crash.inc |
| 249 |
--error 2013 |
| 250 |
truncate table t; |
| 251 |
# |
| 252 |
--source include/start_mysqld.inc |
| 253 |
check table t; |
| 254 |
select * from t; |
| 255 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 256 |
select * from t; |
| 257 |
select * from t where f < 2.5; |
| 258 |
drop table t; |
| 259 |
# |
| 260 |
# |
| 261 |
use test; |
| 262 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 263 |
SET innodb_strict_mode=OFF; |
| 264 |
--disable_warnings |
| 265 |
eval create $wl6501_temp table t ( |
| 266 |
i int, f float, c char, |
| 267 |
primary key pk(i), unique findex(f)) |
| 268 |
engine = innodb row_format = $wl6501_row_fmt |
| 269 |
key_block_size = $wl6501_kbs; |
| 270 |
--enable_warnings |
| 271 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 272 |
select * from t; |
| 273 |
check table t; |
| 274 |
# |
| 275 |
set session debug = "+d,ib_trunc_crash_on_create_of_uniq_index"; |
| 276 |
--source include/expect_crash.inc |
| 277 |
--error 2013 |
| 278 |
truncate table t; |
| 279 |
# |
| 280 |
--source include/start_mysqld.inc |
| 281 |
check table t; |
| 282 |
select * from t; |
| 283 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 284 |
select * from t; |
| 285 |
select * from t where f < 2.5; |
| 286 |
drop table t; |
| 287 |
# |
| 288 |
# |
| 289 |
use test; |
| 290 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 291 |
SET innodb_strict_mode=OFF; |
| 292 |
--disable_warnings |
| 293 |
eval create $wl6501_temp table t ( |
| 294 |
i int, f float, c char, |
| 295 |
primary key pk(i), index ck(c)) |
| 296 |
engine = innodb row_format = $wl6501_row_fmt |
| 297 |
key_block_size = $wl6501_kbs; |
| 298 |
--enable_warnings |
| 299 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 300 |
select * from t; |
| 301 |
check table t; |
| 302 |
# |
| 303 |
set session debug = "+d,ib_trunc_crash_on_create_of_sec_index"; |
| 304 |
--source include/expect_crash.inc |
| 305 |
--error 2013 |
| 306 |
truncate table t; |
| 307 |
# |
| 308 |
--source include/start_mysqld.inc |
| 309 |
check table t; |
| 310 |
select * from t; |
| 311 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 312 |
select * from t; |
| 313 |
select * from t where f < 2.5; |
| 314 |
drop table t; |
| 315 |
|
| 316 |
#----------------------------------------------------------------------------- |
| 317 |
# |
| 318 |
# 6. Hit crash point after data is updated to system-table and in-memory dict. |
| 319 |
# |
| 320 |
--echo "6. Hit crash point after data is updated to system-table and" |
| 321 |
--echo " in-memory dict." |
| 322 |
use test; |
| 323 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 324 |
SET innodb_strict_mode=OFF; |
| 325 |
--disable_warnings |
| 326 |
eval create $wl6501_temp table t ( |
| 327 |
i int, f float, c char, |
| 328 |
primary key pk(i), unique findex(f), index ck(c)) |
| 329 |
engine = innodb row_format = $wl6501_row_fmt |
| 330 |
key_block_size = $wl6501_kbs; |
| 331 |
--enable_warnings |
| 332 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 333 |
select * from t; |
| 334 |
check table t; |
| 335 |
# |
| 336 |
set session debug = "+d,ib_trunc_crash_on_updating_dict_sys_info"; |
| 337 |
--source include/expect_crash.inc |
| 338 |
--error 2013 |
| 339 |
truncate table t; |
| 340 |
# |
| 341 |
--source include/start_mysqld.inc |
| 342 |
check table t; |
| 343 |
select * from t; |
| 344 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 345 |
select * from t; |
| 346 |
select * from t where f < 2.5; |
| 347 |
drop table t; |
| 348 |
|
| 349 |
#----------------------------------------------------------------------------- |
| 350 |
# |
| 351 |
# 7. Hit crash point before/after log checkpoint is done. |
| 352 |
# |
| 353 |
--echo "7. Hit crash point before/after log checkpoint is done." |
| 354 |
use test; |
| 355 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 356 |
SET innodb_strict_mode=OFF; |
| 357 |
--disable_warnings |
| 358 |
eval create $wl6501_temp table t ( |
| 359 |
i int, f float, c char, |
| 360 |
primary key pk(i), unique findex(f), index ck(c)) |
| 361 |
engine = innodb row_format = $wl6501_row_fmt |
| 362 |
key_block_size = $wl6501_kbs; |
| 363 |
--enable_warnings |
| 364 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 365 |
select * from t; |
| 366 |
check table t; |
| 367 |
# |
| 368 |
set session debug = "+d,ib_trunc_crash_before_log_removal"; |
| 369 |
--source include/expect_crash.inc |
| 370 |
--error 2013 |
| 371 |
truncate table t; |
| 372 |
# |
| 373 |
--source include/start_mysqld.inc |
| 374 |
check table t; |
| 375 |
select * from t; |
| 376 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 377 |
select * from t where f < 2.5; |
| 378 |
drop table t; |
| 379 |
# |
| 380 |
# |
| 381 |
use test; |
| 382 |
eval set global innodb_file_per_table = $wl6501_file_per_table; |
| 383 |
SET innodb_strict_mode=OFF; |
| 384 |
--disable_warnings |
| 385 |
eval create $wl6501_temp table t ( |
| 386 |
i int, f float, c char, |
| 387 |
primary key pk(i), unique findex(f), index ck(c)) |
| 388 |
engine = innodb row_format = $wl6501_row_fmt |
| 389 |
key_block_size = $wl6501_kbs; |
| 390 |
--enable_warnings |
| 391 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 392 |
select * from t; |
| 393 |
check table t; |
| 394 |
# |
| 395 |
set session debug = "+d,ib_trunc_crash_after_truncate_done"; |
| 396 |
--source include/expect_crash.inc |
| 397 |
--error 2013 |
| 398 |
truncate table t; |
| 399 |
# |
| 400 |
--source include/start_mysqld.inc |
| 401 |
check table t; |
| 402 |
select * from t; |
| 403 |
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); |
| 404 |
select * from t; |
| 405 |
select * from t where f < 2.5; |
| 406 |
drop table t; |
| 407 |
|
| 408 |
|
| 409 |
#----------------------------------------------------------------------------- |
| 410 |
# |
| 411 |
# remove test-bed |
| 412 |
# |
| 413 |
eval set global innodb_file_per_table = $per_table; |