Debian Codegraph @

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

raw
1 # This test case tests if we handle the corrupted redo logs for dynamic metadata
2 # of tables(corrupted index bit in this case) correctly.
3
4 # Support for --debug=...
5 --source include/have_debug.inc
6
7 --source ../include/redo_log_error_patterns.inc
8
9 let $tmp_dir = $MYSQLTEST_VARDIR/tmp;
10 let MYSQLD_DATADIR = $tmp_dir/log_corruption_1;
11 let MYSQLD_ERROR_LOG = $tmp_dir/my_restart.err;
12 let SEARCH_FILE = $MYSQLD_ERROR_LOG;
13 let $INNODB_PAGE_SIZE = `select @@innodb_page_size`;
14
15 --echo # Initialize new data directory...
16 --source include/initialize_datadir.inc
17 let restart_parameters = restart: --datadir=$MYSQLD_DATADIR --log-error=$MYSQLD_ERROR_LOG;
18
19 --echo # Restart on the new data directory...
20 --replace_result $MYSQLD_ERROR_LOG my_restart.err $MYSQLD_DATADIR tmp/log_corruption_1
21 --source include/restart_mysqld.inc
22
23 --echo # Create table and row...
24 CREATE TABLE t (a INT AUTO_INCREMENT PRIMARY KEY, b INT, INDEX b_idx(b))
25 ENGINE = InnoDB STATS_PERSISTENT = 0;
26 INSERT INTO t VALUES(1,1);
27
28 CHECK TABLE t;
29
30 --echo ############################################################################################
31 --echo # Case 1: Crash after redo logging information about corrupted clustered index.
32 --echo ############################################################################################
33
34 --remove_file $SEARCH_FILE
35
36 --echo # Ensure there is a lot of free space in the redo log.
37 SET GLOBAL innodb_log_checkpoint_now = ON;
38
39 --echo # Disable checkpointing.
40 SET GLOBAL innodb_checkpoint_disabled = ON;
41
42 --echo # Enable crash code...
43 --source include/expect_crash.inc
44 SET SESSION DEBUG = "+d,log_corruption_crash_1";
45 SET SESSION DEBUG = "+d,dict_set_index_corrupted";
46
47 --echo # Run CHECK TABLE (expecting a crash)...
48 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
49 CHECK TABLE t;
50
51 --echo # Verify that InnoDB can recover.
52 --replace_result $MYSQLD_ERROR_LOG my_restart.err $MYSQLD_DATADIR tmp/log_corruption_1
53 --source include/start_mysqld.inc
54
55 let SEARCH_PATTERN = $PATTERN_CORRUPT_LOG_RECORD;
56 # Expected: not found
57 --source include/search_pattern.inc
58
59 CHECK TABLE t;
60 ALTER TABLE t DROP INDEX b_idx;
61
62 CHECK TABLE t;
63 ALTER TABLE t ADD INDEX b_idx (b);
64
65 --echo ############################################################################################
66 --echo # Case 2: Crash after redo logging *corrupted* information about corrupted clustered index
67 --echo # (logging number of indexes corrupted = 100 > MAX_INDEXES).
68 --echo ############################################################################################
69
70 --remove_file $SEARCH_FILE
71
72 --echo # Ensure there is a lot of free space in the redo log.
73 SET GLOBAL innodb_log_checkpoint_now = ON;
74
75 --echo # Disable checkpointing.
76 SET GLOBAL innodb_checkpoint_disabled = ON;
77
78 --echo # Enable crash code...
79 --source include/expect_crash.inc
80 SET SESSION DEBUG = "+d,log_corruption_crash_1";
81 SET SESSION DEBUG = "+d,log_corruption_1"; # corrupt the redo records being logged
82 SET SESSION DEBUG = "+d,dict_set_clust_index_corrupted";
83
84 --echo # Run CHECK TABLE (expecting a crash)...
85 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
86 CHECK TABLE t;
87
88 --echo # Verify that InnoDB cannot recover, because it encounters the corrupted redo record.
89 --error 1,42
90 --exec $MYSQLD_CMD $MYSQLD_ARGS --innodb_page_size=$INNODB_PAGE_SIZE --$UNKNOWN_PARAM
91
92 --echo # Matching the server logs for corrupted redo logs...
93 let SEARCH_PATTERN = $PATTERN_CORRUPT_LOG_RECORD;
94 # Expected: found
95 --source include/search_pattern.inc
96
97 let SEARCH_PATTERN = Hex dump starting .* bytes before and ending .* bytes after the corrupted record;
98 # Expected: found
99 --source include/search_pattern.inc
100
101 let SEARCH_PATTERN = $PATTERN_UNKNOWN_PARAM;
102 # Expected: not found
103 --source include/search_pattern.inc
104
105 --echo ############################################################################################
106
107 --echo # Cleanup...
108
109 --remove_file $SEARCH_FILE
110 --force-rmdir $MYSQLD_DATADIR
111
112 let MYSQLD_ARGS=;
113 let MYSQLD_DATADIR=;
114 let MYSQLD_ERROR_LOG=;
115 let SEARCH_FILE=;
116 let SEARCH_PATTERN=;
117
118 let restart_parameters = restart:;
119
120 --source include/start_mysqld.inc