Debian Codegraph @

mysql-test/suite/rpl/t/rpl_corruption.test

raw
1 ############################################################
2 # Purpose: WL#5064 Testing with corrupted events.
3 # The test emulates the corruption at the vary stages
4 # of replication:
5 # - in binlog file
6 # - in network
7 # - in relay log
8 ############################################################
9
10 #
11 # The tests intensively utilize @@global.debug. Note,
12 # Bug#11765758 - 58754,
13 # @@global.debug is read by the slave threads through dbug-interface.
14 # Hence, before a client thread set @@global.debug we have to ensure that:
15 # (a) the slave threads are stopped, or (b) the slave threads are in
16 # sync and waiting.
17
18 --source include/not_group_replication_plugin.inc
19 --source include/have_debug.inc
20 --source include/master-slave.inc
21
22 # Block legal errors for MTR
23 call mtr.add_suppression('Found invalid event in binary log');
24 call mtr.add_suppression("Replica I/O for channel '': Relay log write failure: could not queue event from source");
25 call mtr.add_suppression('event read from binlog did not pass crc check');
26 call mtr.add_suppression('Replication event checksum verification failed');
27 call mtr.add_suppression('Event crc check failed! Most likely there is event corruption');
28 call mtr.add_suppression("Replica SQL for channel '': Error initializing relay log position: I/O error reading event at position .*, Error_code: MY-013117");
29
30 SET @old_source_verify_checksum = @@source_verify_checksum;
31
32 # Creating test table/data and set corruption position for testing
33 --echo # 1. Creating test table/data and set corruption position for testing
34 --connection master
35 --echo * insert/update/delete rows in table t1 *
36 # Corruption algorithm modifies only the first event and
37 # then will be reset. To avoid checking always the first event
38 # from binlog (usually it is FD) we randomly execute different
39 # statements and set position for corruption inside events.
40
41 CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b VARCHAR(10), c VARCHAR(100));
42 --disable_query_log
43 let $i=`SELECT 3+CEILING(10*RAND())`;
44 let $j=1;
45 let $pos=0;
46 while ($i) {
47 eval INSERT INTO t1 VALUES ($j, 'a', NULL);
48 if (`SELECT RAND() > 0.7`)
49 {
50 eval UPDATE t1 SET c = REPEAT('a', 20) WHERE a = $j;
51 }
52 if (`SELECT RAND() > 0.8`)
53 {
54 eval DELETE FROM t1 WHERE a = $j;
55 }
56 if (!$pos) {
57 let $pos= query_get_value(SHOW MASTER STATUS, Position, 1);
58 --source include/sync_slave_sql_with_master.inc
59 --source include/stop_slave.inc
60 --disable_query_log
61 --connection master
62 }
63 dec $i;
64 inc $j;
65 }
66 --enable_query_log
67
68
69 # Emulate corruption in binlog file when SHOW BINLOG EVENTS is executing
70 --echo # 2. Corruption in master binlog and SHOW BINLOG EVENTS
71
72 --let $debug_point= corrupt_read_log_event
73 --source include/add_debug_point.inc
74
75 --echo SHOW BINLOG EVENTS;
76 --disable_query_log
77 send_eval SHOW BINLOG EVENTS FROM $pos;
78 --enable_query_log
79 --replace_regex /position \d+/position #/
80 --error ER_ERROR_WHEN_EXECUTING_COMMAND
81 reap;
82
83 # Emulate corruption on master with crc checking on master
84 --echo # 3. Master read a corrupted event from binlog and send the error to slave
85 --connection slave
86 START SLAVE IO_THREAD;
87 let $slave_io_errno= 13114; # ER_SERVER_SOURCE_FATAL_ERROR_READING_BINLOG
88 --source include/wait_for_slave_io_error.inc
89 --connection master
90
91 # Emulate corruption on master without crc checking on master
92 --echo # 4. Master read a corrupted event from binlog and send it to slave
93 --connection master
94 SET GLOBAL source_verify_checksum=0;
95 --connection slave
96 START SLAVE IO_THREAD;
97 let $slave_io_errno= 13122,13115; # ER_REPLICA_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
98 --source include/wait_for_slave_io_error.inc
99 --connection master
100
101 --let $debug_point= corrupt_read_log_event
102 --source include/remove_debug_point.inc
103
104 SET GLOBAL source_verify_checksum=1;
105
106 # Emulate corruption in network
107 --echo # 5. Slave. Corruption in network
108 --connection slave
109
110 --let $debug_point= corrupt_queue_event
111 --source include/add_debug_point.inc
112
113 START SLAVE IO_THREAD;
114 let $slave_io_errno= 13122,13115; # ER_REPLICA_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
115 --source include/wait_for_slave_io_error.inc
116
117 # Emulate corruption in relay log
118 --echo # 6. Slave. Corruption in relay log
119
120 --let $debug_point= corrupt_read_log_event
121 --source include/add_debug_point.inc
122
123 START SLAVE SQL_THREAD;
124 let $slave_sql_errno= 13117; # ER_REPLICA_FATAL_ERROR
125 --source include/wait_for_slave_sql_error.inc
126
127 # Start normal replication and compare same table on master
128 # and slave
129 --echo # 7. Seek diff for tables on master and slave
130 --connection slave
131
132 --let $debug_point= corrupt_read_log_event
133 --source include/remove_debug_point.inc
134 --let $debug_point= corrupt_queue_event
135 --source include/remove_debug_point.inc
136
137 --source include/start_slave.inc
138
139 --connection master
140 --source include/sync_slave_sql_with_master.inc
141 --let $diff_tables= master:t1, slave:t1
142 --source include/diff_tables.inc
143
144 # Clean up
145 --echo # 8. Clean up
146 --connection master
147 SET GLOBAL source_verify_checksum = @old_source_verify_checksum;
148 DROP TABLE t1;
149 --source include/sync_slave_sql_with_master.inc
150
151 --source include/rpl_end.inc