| 1 |
# |
| 2 |
# MDEV-26137 ALTER TABLE IMPORT enhancement |
| 3 |
# |
| 4 |
call mtr.add_suppression('InnoDB: Tablespace for table `test`.`t1` is set as discarded.'); |
| 5 |
call mtr.add_suppression('InnoDB: Tablespace for table `test`.`t2` is set as discarded.'); |
| 6 |
call mtr.add_suppression('InnoDB: Tablespace for table `test`.`t3` is set as discarded.'); |
| 7 |
call mtr.add_suppression('InnoDB: ./test/t3.ibd: Page 0 at offset 0 looks corrupted.'); |
| 8 |
call mtr.add_suppression("mariadbd.*: Index for table 't3' is corrupt; try to repair it"); |
| 9 |
call mtr.add_suppression("InnoDB: Expected tablespace id \\d+ but found \\d+ in the file ./test/t3.ibd"); |
| 10 |
call mtr.add_suppression("InnoDB: Corrupted page \\[page id: space=.*, page number=0\\] of datafile './test/t3.ibd' could not be found in the doublewrite buffer."); |
| 11 |
call mtr.add_suppression('InnoDB: Tablespace for table `test`.`t4` is set as discarded.'); |
| 12 |
call mtr.add_suppression('InnoDB: ./test/t4.ibd: Page 0 at offset 0 looks corrupted.'); |
| 13 |
call mtr.add_suppression("mariadbd.*: Index for table 't4' is corrupt; try to repair it"); |
| 14 |
call mtr.add_suppression("InnoDB: Corrupted page \\[page id: space=.*, page number=0\\] of datafile './test/t4.ibd' could not be found in the doublewrite buffer."); |
| 15 |
# Recovery from crashes |
| 16 |
## t1: Creation of stub succeeds; server crashes; second import attempt succeeds |
| 17 |
## t2: Creation of stub succeeds; server crashes; drop table |
| 18 |
## t3: Creation of stub succeeds; server crashes; ibd corrupted; second import attempt fails; drop table |
| 19 |
## t4: Did not copy .cfg; creation of stub succeeds; server crashes; ibd corrupted; second import attempt fails; drop table |
| 20 |
CREATE TABLE t (a int) ENGINE=InnoDB; |
| 21 |
INSERT INTO t VALUES(42); |
| 22 |
FLUSH TABLES t FOR EXPORT; |
| 23 |
UNLOCK TABLES; |
| 24 |
SET GLOBAL innodb_max_dirty_pages_pct_lwm=0.0; |
| 25 |
SET GLOBAL innodb_max_dirty_pages_pct=0.0; |
| 26 |
connect hang1,localhost,root; |
| 27 |
SET DEBUG_SYNC='ib_after_create_stub_for_import SIGNAL hung WAIT_FOR ever'; |
| 28 |
ALTER TABLE t1 IMPORT TABLESPACE; |
| 29 |
connection default; |
| 30 |
SET DEBUG_SYNC='now WAIT_FOR hung'; |
| 31 |
connect hang2,localhost,root; |
| 32 |
SET DEBUG_SYNC='ib_after_create_stub_for_import SIGNAL hung WAIT_FOR ever'; |
| 33 |
ALTER TABLE t2 IMPORT TABLESPACE; |
| 34 |
connection default; |
| 35 |
SET DEBUG_SYNC='now WAIT_FOR hung'; |
| 36 |
connect hang3,localhost,root; |
| 37 |
SET DEBUG_SYNC='ib_after_create_stub_for_import SIGNAL hung WAIT_FOR ever'; |
| 38 |
ALTER TABLE t3 IMPORT TABLESPACE; |
| 39 |
connection default; |
| 40 |
SET DEBUG_SYNC='now WAIT_FOR hung'; |
| 41 |
connect hang4,localhost,root; |
| 42 |
SET DEBUG_SYNC='ib_after_create_stub_for_import SIGNAL hung WAIT_FOR ever'; |
| 43 |
ALTER TABLE t4 IMPORT TABLESPACE; |
| 44 |
connection default; |
| 45 |
SET DEBUG_SYNC='now WAIT_FOR hung'; |
| 46 |
# corrupting the 0th page |
| 47 |
# Restart mysqld after the crash and reconnect. |
| 48 |
# restart |
| 49 |
ALTER TABLE t1 IMPORT TABLESPACE; |
| 50 |
SHOW CREATE TABLE t1; |
| 51 |
Table Create Table |
| 52 |
t1 CREATE TABLE `t1` ( |
| 53 |
`a` int(11) DEFAULT NULL |
| 54 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 55 |
SELECT * FROM t1; |
| 56 |
a |
| 57 |
42 |
| 58 |
ALTER TABLE t3 IMPORT TABLESPACE; |
| 59 |
ERROR HY000: Internal error: Error importing tablespace for table `test`.`t3` : Data structure corruption |
| 60 |
ALTER TABLE t4 IMPORT TABLESPACE; |
| 61 |
ERROR HY000: Schema mismatch (Expected FSP_SPACE_FLAGS=0x15, .ibd file contains 0x1010115.) |
| 62 |
DROP TABLE t, t1, t2, t3, t4; |
| 63 |
# Recovery from corruption only, no server restart |
| 64 |
## t5: Recovery from corruption, with cfg |
| 65 |
## t6: Recovery from corruption, without cfg |
| 66 |
call mtr.add_suppression('InnoDB: ./test/t5.ibd: Page 0 at offset 0 looks corrupted.'); |
| 67 |
call mtr.add_suppression("mariadbd.*: Index for table 't5' is corrupt; try to repair it"); |
| 68 |
call mtr.add_suppression("InnoDB: Corrupted page \\[page id: space=.*, page number=0\\] of datafile './test/t5.ibd' could not be found in the doublewrite buffer."); |
| 69 |
call mtr.add_suppression("InnoDB: Corrupted page \\[page id: space=.*, page number=0\\] of datafile './test/t6.ibd' could not be found in the doublewrite buffer."); |
| 70 |
call mtr.add_suppression("mariadbd.*: Index for table 't6' is corrupt; try to repair it"); |
| 71 |
CREATE TABLE t (a int) ENGINE=InnoDB; |
| 72 |
INSERT INTO t VALUES(42); |
| 73 |
FLUSH TABLES t FOR EXPORT; |
| 74 |
UNLOCK TABLES; |
| 75 |
# corrupting the 0th page |
| 76 |
ALTER TABLE t5 IMPORT TABLESPACE; |
| 77 |
ERROR HY000: Internal error: Error importing tablespace for table `test`.`t5` : Data structure corruption |
| 78 |
ALTER TABLE t6 IMPORT TABLESPACE; |
| 79 |
ERROR HY000: Schema mismatch (Expected FSP_SPACE_FLAGS=0x15, .ibd file contains 0x1010115.) |
| 80 |
DROP TABLE t, t5, t6; |