| 1 |
ALTER DATABASE test CHARACTER SET latin1 COLLATE latin1_swedish_ci; |
| 2 |
# REPAIR USE_FRM is not implemented for partitioned tables. |
| 3 |
# Test what happens if we exchange a crashed partition with a table |
| 4 |
SHOW VARIABLES LIKE 'myisam_recover_options'; |
| 5 |
Variable_name Value |
| 6 |
myisam_recover_options OFF |
| 7 |
CREATE TABLE t (a INT, KEY (a)) ENGINE=MyISAM; |
| 8 |
CREATE TABLE tp (a INT, KEY (a)) ENGINE=MyISAM |
| 9 |
PARTITION BY RANGE (a) |
| 10 |
(PARTITION pCrashed VALUES LESS THAN (15), |
| 11 |
PARTITION pMAX VALUES LESS THAN MAXVALUE); |
| 12 |
INSERT INTO t VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11); |
| 13 |
INSERT INTO tp VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11); |
| 14 |
FLUSH TABLES; |
| 15 |
# replacing tp#P#pCrashed.MYI with a corrupt + unclosed one created by doing: |
| 16 |
# 'create table t1 (a int key(a))' head -c1024 t1.MYI > corrupt_t1.MYI |
| 17 |
CHECK TABLE tp; |
| 18 |
Table Op Msg_type Msg_text |
| 19 |
test.tp check warning 1 client is using or hasn't closed the table properly |
| 20 |
test.tp check error Size of indexfile is: 1024 Should be: 2048 |
| 21 |
test.tp check warning Size of datafile is: 77 Should be: 7 |
| 22 |
test.tp check error Partition pCrashed returned error |
| 23 |
test.tp check error Corrupt |
| 24 |
ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t; |
| 25 |
ERROR HY000: Table './test/tp#P#pCrashed' is marked as crashed and should be repaired |
| 26 |
REPAIR TABLE tp; |
| 27 |
Table Op Msg_type Msg_text |
| 28 |
test.tp repair warning Number of rows changed from 1 to 11 |
| 29 |
test.tp repair status OK |
| 30 |
CHECK TABLE tp; |
| 31 |
Table Op Msg_type Msg_text |
| 32 |
test.tp check status OK |
| 33 |
ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t; |
| 34 |
CHECK TABLE t; |
| 35 |
Table Op Msg_type Msg_text |
| 36 |
test.t check status OK |
| 37 |
CHECK TABLE tp; |
| 38 |
Table Op Msg_type Msg_text |
| 39 |
test.tp check status OK |
| 40 |
FLUSH TABLES; |
| 41 |
CHECK TABLE t; |
| 42 |
Table Op Msg_type Msg_text |
| 43 |
test.t check warning 1 client is using or hasn't closed the table properly |
| 44 |
test.t check error Size of indexfile is: 1024 Should be: 2048 |
| 45 |
test.t check warning Size of datafile is: 77 Should be: 7 |
| 46 |
test.t check error Corrupt |
| 47 |
ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t; |
| 48 |
ERROR HY000: Table './test/t' is marked as crashed and should be repaired |
| 49 |
REPAIR TABLE t; |
| 50 |
Table Op Msg_type Msg_text |
| 51 |
test.t repair warning Number of rows changed from 1 to 11 |
| 52 |
test.t repair status OK |
| 53 |
CHECK TABLE t; |
| 54 |
Table Op Msg_type Msg_text |
| 55 |
test.t check status OK |
| 56 |
ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t; |
| 57 |
CHECK TABLE tp; |
| 58 |
Table Op Msg_type Msg_text |
| 59 |
test.tp check status OK |
| 60 |
CHECK TABLE t; |
| 61 |
Table Op Msg_type Msg_text |
| 62 |
test.t check status OK |
| 63 |
DROP TABLE t, tp; |
| 64 |
# test of non partitioned myisam for reference |
| 65 |
CREATE TABLE t1_will_crash (a INT, KEY (a)) ENGINE=MyISAM; |
| 66 |
INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11); |
| 67 |
FLUSH TABLES; |
| 68 |
# replacing t1.MYI with a corrupt + unclosed one created by doing: |
| 69 |
# 'create table t1 (a int key(a))' head -c1024 t1.MYI > corrupt_t1.MYI |
| 70 |
CHECK TABLE t1_will_crash; |
| 71 |
Table Op Msg_type Msg_text |
| 72 |
test.t1_will_crash check warning 1 client is using or hasn't closed the table properly |
| 73 |
test.t1_will_crash check error Size of indexfile is: 1024 Should be: 2048 |
| 74 |
test.t1_will_crash check warning Size of datafile is: 77 Should be: 7 |
| 75 |
test.t1_will_crash check error Corrupt |
| 76 |
REPAIR TABLE t1_will_crash; |
| 77 |
Table Op Msg_type Msg_text |
| 78 |
test.t1_will_crash repair warning Number of rows changed from 1 to 11 |
| 79 |
test.t1_will_crash repair status OK |
| 80 |
SELECT * FROM t1_will_crash; |
| 81 |
a |
| 82 |
1 |
| 83 |
2 |
| 84 |
3 |
| 85 |
4 |
| 86 |
5 |
| 87 |
6 |
| 88 |
7 |
| 89 |
8 |
| 90 |
9 |
| 91 |
10 |
| 92 |
11 |
| 93 |
DROP TABLE t1_will_crash; |
| 94 |
# test of check/repair of a damaged partition's MYI-file |
| 95 |
CREATE TABLE t1_will_crash (a INT, KEY (a)) |
| 96 |
ENGINE=MyISAM |
| 97 |
PARTITION BY HASH (a) |
| 98 |
PARTITIONS 3; |
| 99 |
INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11); |
| 100 |
FLUSH TABLES; |
| 101 |
# test with CHECK/REPAIR TABLE |
| 102 |
# replacing t1#P#p1.MYI with a corrupt + unclosed one created by doing: |
| 103 |
# 'create table t1 (a int key(a)) partition by hash (a) partitions 3' |
| 104 |
# head -c1024 t1#P#p1.MYI > corrupt_t1#P#p1.MYI |
| 105 |
CHECK TABLE t1_will_crash; |
| 106 |
Table Op Msg_type Msg_text |
| 107 |
test.t1_will_crash check warning 1 client is using or hasn't closed the table properly |
| 108 |
test.t1_will_crash check error Size of indexfile is: 1024 Should be: 2048 |
| 109 |
test.t1_will_crash check warning Size of datafile is: 28 Should be: 7 |
| 110 |
test.t1_will_crash check error Partition p1 returned error |
| 111 |
test.t1_will_crash check error Corrupt |
| 112 |
REPAIR TABLE t1_will_crash; |
| 113 |
Table Op Msg_type Msg_text |
| 114 |
test.t1_will_crash repair warning Number of rows changed from 1 to 4 |
| 115 |
test.t1_will_crash repair status OK |
| 116 |
SELECT * FROM t1_will_crash; |
| 117 |
a |
| 118 |
1 |
| 119 |
2 |
| 120 |
3 |
| 121 |
4 |
| 122 |
5 |
| 123 |
6 |
| 124 |
7 |
| 125 |
8 |
| 126 |
9 |
| 127 |
10 |
| 128 |
11 |
| 129 |
FLUSH TABLES; |
| 130 |
# test with ALTER TABLE ... CHECK/REPAIR PARTITION |
| 131 |
# replacing t1_will_crash#P#p1.MYI with a corrupt + unclosed one |
| 132 |
ALTER TABLE t1_will_crash CHECK PARTITION p0, p2; |
| 133 |
Table Op Msg_type Msg_text |
| 134 |
test.t1_will_crash check status OK |
| 135 |
ALTER TABLE t1_will_crash CHECK PARTITION p0, p1; |
| 136 |
Table Op Msg_type Msg_text |
| 137 |
test.t1_will_crash check warning 1 client is using or hasn't closed the table properly |
| 138 |
test.t1_will_crash check error Size of indexfile is: 1024 Should be: 2048 |
| 139 |
test.t1_will_crash check warning Size of datafile is: 28 Should be: 7 |
| 140 |
test.t1_will_crash check error Partition p1 returned error |
| 141 |
test.t1_will_crash check error Corrupt |
| 142 |
ALTER TABLE t1_will_crash CHECK PARTITION p1, p2; |
| 143 |
Table Op Msg_type Msg_text |
| 144 |
test.t1_will_crash check warning Table is marked as crashed |
| 145 |
test.t1_will_crash check warning 1 client is using or hasn't closed the table properly |
| 146 |
test.t1_will_crash check error Size of indexfile is: 1024 Should be: 2048 |
| 147 |
test.t1_will_crash check warning Size of datafile is: 28 Should be: 7 |
| 148 |
test.t1_will_crash check error Partition p1 returned error |
| 149 |
test.t1_will_crash check error Corrupt |
| 150 |
ALTER TABLE t1_will_crash REPAIR PARTITION p0, p2; |
| 151 |
Table Op Msg_type Msg_text |
| 152 |
test.t1_will_crash repair status OK |
| 153 |
ALTER TABLE t1_will_crash REPAIR PARTITION p0, p1; |
| 154 |
Table Op Msg_type Msg_text |
| 155 |
test.t1_will_crash repair warning Number of rows changed from 1 to 4 |
| 156 |
test.t1_will_crash repair status OK |
| 157 |
SELECT * FROM t1_will_crash; |
| 158 |
a |
| 159 |
1 |
| 160 |
2 |
| 161 |
3 |
| 162 |
4 |
| 163 |
5 |
| 164 |
6 |
| 165 |
7 |
| 166 |
8 |
| 167 |
9 |
| 168 |
10 |
| 169 |
11 |
| 170 |
DROP TABLE t1_will_crash; |
| 171 |
# test of check/repair of a damaged subpartition's MYI-file |
| 172 |
CREATE TABLE t1_will_crash (a INT, KEY (a)) |
| 173 |
ENGINE=MyISAM |
| 174 |
PARTITION BY RANGE (a) |
| 175 |
SUBPARTITION BY HASH (a) |
| 176 |
SUBPARTITIONS 2 |
| 177 |
(PARTITION p0 VALUES LESS THAN (7), |
| 178 |
PARTITION p1 VALUES LESS THAN MAXVALUE); |
| 179 |
INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11); |
| 180 |
SELECT * FROM t1_will_crash; |
| 181 |
a |
| 182 |
1 |
| 183 |
2 |
| 184 |
3 |
| 185 |
4 |
| 186 |
5 |
| 187 |
6 |
| 188 |
7 |
| 189 |
8 |
| 190 |
9 |
| 191 |
10 |
| 192 |
11 |
| 193 |
FLUSH TABLES; |
| 194 |
# test with CHECK/REPAIR TABLE |
| 195 |
# replacing t1_will_crash#P#p1#SP#p1sp0.MYI with a corrupt + unclosed one |
| 196 |
CHECK TABLE t1_will_crash; |
| 197 |
Table Op Msg_type Msg_text |
| 198 |
test.t1_will_crash check warning 1 client is using or hasn't closed the table properly |
| 199 |
test.t1_will_crash check error Size of indexfile is: 1024 Should be: 2048 |
| 200 |
test.t1_will_crash check warning Size of datafile is: 14 Should be: 7 |
| 201 |
test.t1_will_crash check error Subpartition p1sp0 returned error |
| 202 |
test.t1_will_crash check error Corrupt |
| 203 |
REPAIR TABLE t1_will_crash; |
| 204 |
Table Op Msg_type Msg_text |
| 205 |
test.t1_will_crash repair warning Number of rows changed from 1 to 2 |
| 206 |
test.t1_will_crash repair status OK |
| 207 |
SELECT * FROM t1_will_crash; |
| 208 |
a |
| 209 |
1 |
| 210 |
2 |
| 211 |
3 |
| 212 |
4 |
| 213 |
5 |
| 214 |
6 |
| 215 |
7 |
| 216 |
8 |
| 217 |
9 |
| 218 |
10 |
| 219 |
11 |
| 220 |
FLUSH TABLES; |
| 221 |
# test with ALTER TABLE ... CHECK/REPAIR PARTITION |
| 222 |
# replacing t1_will_crash#P#p1#SP#p1sp0.MYI with a corrupt + unclosed one |
| 223 |
ALTER TABLE t1_will_crash CHECK PARTITION p0; |
| 224 |
Table Op Msg_type Msg_text |
| 225 |
test.t1_will_crash check status OK |
| 226 |
ALTER TABLE t1_will_crash CHECK PARTITION all; |
| 227 |
Table Op Msg_type Msg_text |
| 228 |
test.t1_will_crash check warning 1 client is using or hasn't closed the table properly |
| 229 |
test.t1_will_crash check error Size of indexfile is: 1024 Should be: 2048 |
| 230 |
test.t1_will_crash check warning Size of datafile is: 14 Should be: 7 |
| 231 |
test.t1_will_crash check error Subpartition p1sp0 returned error |
| 232 |
test.t1_will_crash check error Corrupt |
| 233 |
ALTER TABLE t1_will_crash CHECK PARTITION p1; |
| 234 |
Table Op Msg_type Msg_text |
| 235 |
test.t1_will_crash check warning Table is marked as crashed |
| 236 |
test.t1_will_crash check warning 1 client is using or hasn't closed the table properly |
| 237 |
test.t1_will_crash check error Size of indexfile is: 1024 Should be: 2048 |
| 238 |
test.t1_will_crash check warning Size of datafile is: 14 Should be: 7 |
| 239 |
test.t1_will_crash check error Subpartition p1sp0 returned error |
| 240 |
test.t1_will_crash check error Corrupt |
| 241 |
ALTER TABLE t1_will_crash REPAIR PARTITION p0; |
| 242 |
Table Op Msg_type Msg_text |
| 243 |
test.t1_will_crash repair status OK |
| 244 |
ALTER TABLE t1_will_crash REPAIR PARTITION p0, p1; |
| 245 |
Table Op Msg_type Msg_text |
| 246 |
test.t1_will_crash repair warning Number of rows changed from 1 to 2 |
| 247 |
test.t1_will_crash repair status OK |
| 248 |
SELECT * FROM t1_will_crash; |
| 249 |
a |
| 250 |
1 |
| 251 |
2 |
| 252 |
3 |
| 253 |
4 |
| 254 |
5 |
| 255 |
6 |
| 256 |
7 |
| 257 |
8 |
| 258 |
9 |
| 259 |
10 |
| 260 |
11 |
| 261 |
DROP TABLE t1_will_crash; |
| 262 |
# test of check/repair of crashed partitions in variuos states |
| 263 |
CREATE TABLE t1_will_crash ( |
| 264 |
a VARCHAR(255), |
| 265 |
b INT, |
| 266 |
c LONGTEXT, |
| 267 |
PRIMARY KEY (a, b)) |
| 268 |
ENGINE=MyISAM |
| 269 |
PARTITION BY HASH (b) |
| 270 |
PARTITIONS 7; |
| 271 |
SELECT COUNT(*) FROM t1_will_crash; |
| 272 |
COUNT(*) |
| 273 |
33 |
| 274 |
SELECT (b % 7) AS `partition`, COUNT(*) AS rows_cnt FROM t1_will_crash GROUP BY (b % 7); |
| 275 |
partition rows_cnt |
| 276 |
0 2 |
| 277 |
1 5 |
| 278 |
2 5 |
| 279 |
3 5 |
| 280 |
4 4 |
| 281 |
5 4 |
| 282 |
6 8 |
| 283 |
SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash ORDER BY `partition`, b, a; |
| 284 |
partition b a length(c) |
| 285 |
0 0 lost 64 |
| 286 |
0 7 z lost 64 |
| 287 |
1 1 abc 64 |
| 288 |
1 8 tuw 64 |
| 289 |
1 29 kkkkkkkkKkk 64 |
| 290 |
1 71 1 broken when head -c1024 on datafile 1024 |
| 291 |
1 71 eee 64 |
| 292 |
2 2 def 64 |
| 293 |
2 9 vxy 64 |
| 294 |
2 23 lll 64 |
| 295 |
2 30 2 crashed after _mi_mark_changed 64 |
| 296 |
2 79 ccc 64 |
| 297 |
3 3 ghi 64 |
| 298 |
3 10 aaa 64 |
| 299 |
3 17 nnn 64 |
| 300 |
3 24 3 crashed after write_record 64 |
| 301 |
3 73 ddd 64 |
| 302 |
4 4 pqr 64 |
| 303 |
4 11 bbb 64 |
| 304 |
4 18 4 crashed after flush_cached_blocks 64 |
| 305 |
4 67 fff 64 |
| 306 |
5 5 mno 64 |
| 307 |
5 19 mmm 64 |
| 308 |
5 40 5 still here since crash in next row in multirow insert? 64 |
| 309 |
5 89 a 64 |
| 310 |
6 6 jkl 64 |
| 311 |
6 13 ooo 64 |
| 312 |
6 27 6 row 7 (crash before completely written to datafile) 128 |
| 313 |
6 34 6 row 2 64 |
| 314 |
6 48 6 row 4 64 |
| 315 |
6 62 6 row 6 64 |
| 316 |
6 83 64 |
| 317 |
6 97 zzzzzZzzzzz 64 |
| 318 |
FLUSH TABLES; |
| 319 |
# truncating p0 to simulate an empty datafile (not recovered!) |
| 320 |
# replacing p1 with only the first 1024 bytes (not recovered!) |
| 321 |
# replacing p3 with a crashed one at the last row in first insert |
| 322 |
# (crashed right after *share->write_record()) |
| 323 |
# replacing p6 with a crashed MYD file (1) (splitted dynamic record) |
| 324 |
ANALYZE TABLE t1_will_crash; |
| 325 |
Table Op Msg_type Msg_text |
| 326 |
test.t1_will_crash analyze Warning Engine-independent statistics are not collected for column 'c' |
| 327 |
test.t1_will_crash analyze status Operation failed |
| 328 |
OPTIMIZE TABLE t1_will_crash; |
| 329 |
Table Op Msg_type Msg_text |
| 330 |
test.t1_will_crash optimize info Found row block followed by deleted block |
| 331 |
test.t1_will_crash optimize warning Number of rows changed from 8 to 7 |
| 332 |
test.t1_will_crash optimize status OK |
| 333 |
CHECK TABLE t1_will_crash; |
| 334 |
Table Op Msg_type Msg_text |
| 335 |
test.t1_will_crash check error Size of datafile is: 0 Should be: 164 |
| 336 |
test.t1_will_crash check error Partition p0 returned error |
| 337 |
test.t1_will_crash check error Corrupt |
| 338 |
REPAIR TABLE t1_will_crash; |
| 339 |
Table Op Msg_type Msg_text |
| 340 |
test.t1_will_crash repair warning Number of rows changed from 2 to 0 |
| 341 |
test.t1_will_crash repair info Found block that points outside data file at 344 |
| 342 |
test.t1_will_crash repair warning Number of rows changed from 5 to 4 |
| 343 |
test.t1_will_crash repair warning Number of rows changed from 0 to 5 |
| 344 |
test.t1_will_crash repair status OK |
| 345 |
SELECT COUNT(*) FROM t1_will_crash; |
| 346 |
COUNT(*) |
| 347 |
29 |
| 348 |
SELECT (b % 7) AS `partition`, COUNT(*) AS rows_cnt FROM t1_will_crash GROUP BY (b % 7); |
| 349 |
partition rows_cnt |
| 350 |
1 4 |
| 351 |
2 5 |
| 352 |
3 5 |
| 353 |
4 4 |
| 354 |
5 4 |
| 355 |
6 7 |
| 356 |
SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash ORDER BY `partition`, b, a; |
| 357 |
partition b a length(c) |
| 358 |
1 1 abc 64 |
| 359 |
1 8 tuw 64 |
| 360 |
1 29 kkkkkkkkKkk 64 |
| 361 |
1 71 eee 64 |
| 362 |
2 2 def 64 |
| 363 |
2 9 vxy 64 |
| 364 |
2 23 lll 64 |
| 365 |
2 30 2 crashed after _mi_mark_changed 64 |
| 366 |
2 79 ccc 64 |
| 367 |
3 3 ghi 64 |
| 368 |
3 10 aaa 64 |
| 369 |
3 17 nnn 64 |
| 370 |
3 24 3 crashed after write_record 64 |
| 371 |
3 73 ddd 64 |
| 372 |
4 4 pqr 64 |
| 373 |
4 11 bbb 64 |
| 374 |
4 18 4 crashed after flush_cached_blocks 64 |
| 375 |
4 67 fff 64 |
| 376 |
5 5 mno 64 |
| 377 |
5 19 mmm 64 |
| 378 |
5 40 5 still here since crash in next row in multirow insert? 64 |
| 379 |
5 89 a 64 |
| 380 |
6 6 jkl 64 |
| 381 |
6 13 ooo 64 |
| 382 |
6 34 6 row 2 64 |
| 383 |
6 48 6 row 4 64 |
| 384 |
6 62 6 row 6 64 |
| 385 |
6 83 64 |
| 386 |
6 97 zzzzzZzzzzz 64 |
| 387 |
FLUSH TABLES; |
| 388 |
# |
| 389 |
# replacing p2 with crashed files (after _mi_mark_changed) |
| 390 |
ALTER TABLE t1_will_crash CHECK PARTITION p2; |
| 391 |
Table Op Msg_type Msg_text |
| 392 |
test.t1_will_crash check warning 1 client is using or hasn't closed the table properly |
| 393 |
test.t1_will_crash check status OK |
| 394 |
# crash was when index only marked as opened, no real corruption |
| 395 |
ALTER TABLE t1_will_crash CHECK PARTITION p2; |
| 396 |
Table Op Msg_type Msg_text |
| 397 |
test.t1_will_crash check status OK |
| 398 |
FLUSH TABLES; |
| 399 |
# |
| 400 |
# replacing p4 with updated but not closed index file |
| 401 |
ALTER TABLE t1_will_crash OPTIMIZE PARTITION p4; |
| 402 |
Table Op Msg_type Msg_text |
| 403 |
test.t1_will_crash optimize error Found key at page 2048 that points to record outside datafile |
| 404 |
test.t1_will_crash optimize error Partition p4 returned error |
| 405 |
test.t1_will_crash optimize status Operation failed |
| 406 |
ALTER TABLE t1_will_crash CHECK PARTITION p4; |
| 407 |
Table Op Msg_type Msg_text |
| 408 |
test.t1_will_crash check warning Table is marked as crashed and last repair failed |
| 409 |
test.t1_will_crash check warning 1 client is using or hasn't closed the table properly |
| 410 |
test.t1_will_crash check warning Size of datafile is: 368 Should be: 252 |
| 411 |
test.t1_will_crash check error Found 4 keys of 3 |
| 412 |
test.t1_will_crash check error Partition p4 returned error |
| 413 |
test.t1_will_crash check error Corrupt |
| 414 |
ALTER TABLE t1_will_crash REPAIR PARTITION p4; |
| 415 |
Table Op Msg_type Msg_text |
| 416 |
test.t1_will_crash repair warning Number of rows changed from 3 to 4 |
| 417 |
test.t1_will_crash repair status OK |
| 418 |
FLUSH TABLES; |
| 419 |
# |
| 420 |
# replacing p6 with a crashed MYD file (2) (splitted dynamic record) |
| 421 |
ALTER TABLE t1_will_crash CHECK PARTITION p6; |
| 422 |
Table Op Msg_type Msg_text |
| 423 |
test.t1_will_crash check warning Size of datafile is: 868 Should be: 604 |
| 424 |
test.t1_will_crash check error Unexpected byte: 0 at link: 340 |
| 425 |
test.t1_will_crash check error Partition p6 returned error |
| 426 |
test.t1_will_crash check error Corrupt |
| 427 |
ALTER TABLE t1_will_crash REPAIR PARTITION p6; |
| 428 |
Table Op Msg_type Msg_text |
| 429 |
test.t1_will_crash repair info Delete link points outside datafile at 340 |
| 430 |
test.t1_will_crash repair info Delete link points outside datafile at 340 |
| 431 |
test.t1_will_crash repair status OK |
| 432 |
SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash |
| 433 |
WHERE (b % 7) = 6 |
| 434 |
ORDER BY `partition`, b, a; |
| 435 |
partition b a length(c) |
| 436 |
6 6 jkl 64 |
| 437 |
6 13 ooo 64 |
| 438 |
6 34 6 row 2 64 |
| 439 |
6 48 6 row 4 64 |
| 440 |
6 62 6 row 6 64 |
| 441 |
6 83 64 |
| 442 |
6 97 zzzzzZzzzzz 64 |
| 443 |
FLUSH TABLES; |
| 444 |
# |
| 445 |
# replacing p6 with a crashed MYD file (3) (splitted dynamic record) |
| 446 |
# Different results from the corrupt table, which can lead to dropping |
| 447 |
# of the not completely written rows when using REBUILD on a corrupt |
| 448 |
# table, depending if one reads via index or direct on datafile. |
| 449 |
# Since crash when reuse of deleted row space, CHECK MEDIUM or EXTENDED |
| 450 |
# is required (MEDIUM is default) to verify correct behavior! |
| 451 |
SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash |
| 452 |
WHERE (b % 7) = 6 |
| 453 |
ORDER BY `partition`, b, a; |
| 454 |
partition b a length(c) |
| 455 |
6 6 jkl 64 |
| 456 |
6 13 ooo 64 |
| 457 |
6 34 6 row 2 64 |
| 458 |
6 83 64 |
| 459 |
6 97 zzzzzZzzzzz 64 |
| 460 |
SET @save_optimizer_switch= @@optimizer_switch; |
| 461 |
SET @@optimizer_switch='derived_merge=off'; |
| 462 |
SELECT (b % 7) AS `partition`, b, a FROM (SELECT b,a FROM t1_will_crash) q |
| 463 |
WHERE (b % 7) = 6 |
| 464 |
ORDER BY `partition`, b, a; |
| 465 |
partition b a |
| 466 |
6 6 jkl |
| 467 |
6 13 ooo |
| 468 |
6 34 6 row 2 |
| 469 |
6 48 6 row 4 |
| 470 |
6 62 6 row 6 |
| 471 |
6 83 |
| 472 |
6 97 zzzzzZzzzzz |
| 473 |
SET @@optimizer_switch=@save_optimizer_switch; |
| 474 |
ALTER TABLE t1_will_crash CHECK PARTITION p6; |
| 475 |
Table Op Msg_type Msg_text |
| 476 |
test.t1_will_crash check warning Size of datafile is: 868 Should be: 604 |
| 477 |
test.t1_will_crash check error Record-count is not ok; is 8 Should be: 7 |
| 478 |
test.t1_will_crash check warning Found 10 key parts. Should be: 7 |
| 479 |
test.t1_will_crash check error Partition p6 returned error |
| 480 |
test.t1_will_crash check error Corrupt |
| 481 |
ALTER TABLE t1_will_crash REPAIR PARTITION p6; |
| 482 |
Table Op Msg_type Msg_text |
| 483 |
test.t1_will_crash repair warning Number of rows changed from 7 to 8 |
| 484 |
test.t1_will_crash repair status OK |
| 485 |
SELECT COUNT(*) FROM t1_will_crash; |
| 486 |
COUNT(*) |
| 487 |
29 |
| 488 |
SELECT (b % 7) AS `partition`, COUNT(*) AS rows_cnt FROM t1_will_crash GROUP BY (b % 7); |
| 489 |
partition rows_cnt |
| 490 |
1 4 |
| 491 |
2 4 |
| 492 |
3 5 |
| 493 |
4 4 |
| 494 |
5 4 |
| 495 |
6 8 |
| 496 |
SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash ORDER BY `partition`, b, a; |
| 497 |
partition b a length(c) |
| 498 |
1 1 abc 64 |
| 499 |
1 8 tuw 64 |
| 500 |
1 29 kkkkkkkkKkk 64 |
| 501 |
1 71 eee 64 |
| 502 |
2 2 def 64 |
| 503 |
2 9 vxy 64 |
| 504 |
2 23 lll 64 |
| 505 |
2 79 ccc 64 |
| 506 |
3 3 ghi 64 |
| 507 |
3 10 aaa 64 |
| 508 |
3 17 nnn 64 |
| 509 |
3 24 3 crashed after write_record 64 |
| 510 |
3 73 ddd 64 |
| 511 |
4 4 pqr 64 |
| 512 |
4 11 bbb 64 |
| 513 |
4 18 4 crashed after flush_cached_blocks 64 |
| 514 |
4 67 fff 64 |
| 515 |
5 5 mno 64 |
| 516 |
5 19 mmm 64 |
| 517 |
5 40 5 still here since crash in next row in multirow insert? 64 |
| 518 |
5 89 a 64 |
| 519 |
6 6 jkl 64 |
| 520 |
6 13 ooo 64 |
| 521 |
6 27 6 row 7 (crash before completely written to datafile) 128 |
| 522 |
6 34 6 row 2 64 |
| 523 |
6 48 6 row 4 64 |
| 524 |
6 62 6 row 6 64 |
| 525 |
6 83 64 |
| 526 |
6 97 zzzzzZzzzzz 64 |
| 527 |
ALTER TABLE t1_will_crash CHECK PARTITION all EXTENDED; |
| 528 |
Table Op Msg_type Msg_text |
| 529 |
test.t1_will_crash check status OK |
| 530 |
DROP TABLE t1_will_crash; |
| 531 |
ALTER DATABASE test CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci; |