File: log_corruption_1.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (120 lines) | stat: -rw-r--r-- 4,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# This test case tests if we handle the corrupted redo logs for dynamic metadata
# of tables(corrupted index bit in this case) correctly.

# Support for --debug=...
--source include/have_debug.inc

--source ../include/redo_log_error_patterns.inc

let $tmp_dir = $MYSQLTEST_VARDIR/tmp;
let MYSQLD_DATADIR = $tmp_dir/log_corruption_1;
let MYSQLD_ERROR_LOG = $tmp_dir/my_restart.err;
let SEARCH_FILE = $MYSQLD_ERROR_LOG;
let $INNODB_PAGE_SIZE = `select @@innodb_page_size`;

--echo # Initialize new data directory...
--source include/initialize_datadir.inc
let restart_parameters = restart: --datadir=$MYSQLD_DATADIR --log-error=$MYSQLD_ERROR_LOG;

--echo # Restart on the new data directory...
--replace_result $MYSQLD_ERROR_LOG my_restart.err $MYSQLD_DATADIR tmp/log_corruption_1
--source include/restart_mysqld.inc

--echo # Create table and row...
CREATE TABLE t (a INT AUTO_INCREMENT PRIMARY KEY, b INT, INDEX b_idx(b))
ENGINE = InnoDB STATS_PERSISTENT = 0;
INSERT INTO t VALUES(1,1);

CHECK TABLE t;

--echo ############################################################################################
--echo # Case 1: Crash after redo logging information about corrupted clustered index.
--echo ############################################################################################

--remove_file $SEARCH_FILE

--echo # Ensure there is a lot of free space in the redo log.
SET GLOBAL innodb_log_checkpoint_now = ON;

--echo # Disable checkpointing.
SET GLOBAL innodb_checkpoint_disabled = ON;

--echo # Enable crash code...
--source include/expect_crash.inc
SET SESSION DEBUG = "+d,log_corruption_crash_1";
SET SESSION DEBUG = "+d,dict_set_index_corrupted";

--echo # Run CHECK TABLE (expecting a crash)...
--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
CHECK TABLE t;

--echo # Verify that InnoDB can recover.
--replace_result $MYSQLD_ERROR_LOG my_restart.err $MYSQLD_DATADIR tmp/log_corruption_1
--source include/start_mysqld.inc

let SEARCH_PATTERN = $PATTERN_CORRUPT_LOG_RECORD;
# Expected: not found
--source include/search_pattern.inc

CHECK TABLE t;
ALTER TABLE t DROP INDEX b_idx;

CHECK TABLE t;
ALTER TABLE t ADD INDEX b_idx (b);

--echo ############################################################################################
--echo # Case 2: Crash after redo logging *corrupted* information about corrupted clustered index
--echo #         (logging number of indexes corrupted = 100 > MAX_INDEXES).
--echo ############################################################################################

--remove_file $SEARCH_FILE

--echo # Ensure there is a lot of free space in the redo log.
SET GLOBAL innodb_log_checkpoint_now = ON;

--echo # Disable checkpointing.
SET GLOBAL innodb_checkpoint_disabled = ON;

--echo # Enable crash code...
--source include/expect_crash.inc
SET SESSION DEBUG = "+d,log_corruption_crash_1";
SET SESSION DEBUG = "+d,log_corruption_1"; # corrupt the redo records being logged
SET SESSION DEBUG = "+d,dict_set_clust_index_corrupted";

--echo # Run CHECK TABLE (expecting a crash)...
--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
CHECK TABLE t;

--echo # Verify that InnoDB cannot recover, because it encounters the corrupted redo record.
--error 1,42
--exec $MYSQLD_CMD $MYSQLD_ARGS --innodb_page_size=$INNODB_PAGE_SIZE --$UNKNOWN_PARAM

--echo # Matching the server logs for corrupted redo logs...
let SEARCH_PATTERN = $PATTERN_CORRUPT_LOG_RECORD;
# Expected: found
--source include/search_pattern.inc

let SEARCH_PATTERN = Hex dump starting .* bytes before and ending .* bytes after the corrupted record;
# Expected: found
--source include/search_pattern.inc

let SEARCH_PATTERN = $PATTERN_UNKNOWN_PARAM;
# Expected: not found
--source include/search_pattern.inc

--echo ############################################################################################

--echo # Cleanup...

--remove_file $SEARCH_FILE
--force-rmdir $MYSQLD_DATADIR

let MYSQLD_ARGS=;
let MYSQLD_DATADIR=;
let MYSQLD_ERROR_LOG=;
let SEARCH_FILE=;
let SEARCH_PATTERN=;

let restart_parameters = restart:;

--source include/start_mysqld.inc