#At file:///home/ksm/oracle/repo/WL5064/mysql-next-mr-wl2540-commit/ based on revid:aelkin@stripped
3176 Serge Kozlov 2010-10-04
WL#5064 Emulate the corruption of events for replication at vary stages: reading from binlog/relay log, receiving by slave from network
modified:
sql/log_event.cc
sql/mysqld.cc
sql/rpl_slave.cc
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc 2010-09-28 15:42:48 +0000
+++ b/sql/log_event.cc 2010-10-04 10:00:58 +0000
@@ -1358,7 +1358,6 @@ Log_event* Log_event::read_log_event(con
DBUG_ASSERT(description_event != 0);
DBUG_PRINT("info", ("binlog_version: %d", description_event->binlog_version));
DBUG_DUMP("data", (unsigned char*) buf, event_len);
-
/* Check the integrity */
if (event_len < EVENT_LEN_OFFSET ||
buf[EVENT_TYPE_OFFSET] >= ENUM_END_EVENT ||
@@ -1393,7 +1392,16 @@ Log_event* Log_event::read_log_event(con
*/
alg= (event_type != FORMAT_DESCRIPTION_EVENT) ?
description_event->checksum_alg : get_checksum_alg(buf, event_len);
-
+ // Emulate the corruption during reading an event
+ DBUG_EXECUTE_IF("corrupt_read_log_event",
+ char *debug_buf_c = (char *)buf;
+ int debug_cor_pos = rand() % event_len;
+ int debug_cor_mask = 1 << rand() % 8;
+ char debug_cor_data = debug_buf_c[debug_cor_pos] ^ debug_cor_mask;
+ DBUG_PRINT("info", ("Corrupt the event at Log_event::read_log_event(char*,...): position %d, converted %d -> %d", debug_cor_pos, debug_buf_c[debug_cor_pos], debug_cor_data));
+ memset(debug_buf_c + debug_cor_pos, debug_cor_data, 1);
+ DBUG_SET("-d,corrupt_read_log_event");
+ );
if (crc_check &&
event_checksum_test((uchar *) buf, event_len, alg))
{
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2010-09-28 15:06:04 +0000
+++ b/sql/mysqld.cc 2010-10-04 10:00:58 +0000
@@ -4560,6 +4560,7 @@ int mysqld_main(int argc, char **argv)
#ifndef DBUG_OFF
test_lc_time_sz();
+ srand(time(NULL));
#endif
/*
=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc 2010-09-28 15:06:04 +0000
+++ b/sql/rpl_slave.cc 2010-10-04 10:00:58 +0000
@@ -3379,6 +3379,16 @@ Stopping slave I/O thread due to out-of-
retry_count=0; // ok event, reset retry counter
thd_proc_info(thd, "Queueing master event to the relay log");
event_buf= (const char*)mysql->net.read_pos + 1;
+ // Emulate the network corruption
+ DBUG_EXECUTE_IF("corrupt_log_event",
+ char *debug_event_buf_c = (char*)mysql->net.read_pos + 1;
+ int debug_cor_pos = rand() % event_len;
+ int debug_cor_mask = 1 << rand() % 8;
+ char debug_cor_data = debug_event_buf_c[debug_cor_pos] ^ debug_cor_mask;
+ DBUG_PRINT("info", ("Corrupt the event at handle_slave_io: position %d, converted %d -> %d", debug_cor_pos, debug_event_buf_c[debug_cor_pos], debug_cor_data));
+ memset(debug_event_buf_c + debug_cor_pos, debug_cor_data, 1);
+ DBUG_SET("-d,corrupt_log_event");
+ );
if (RUN_HOOK(binlog_relay_io, after_read_event,
(thd, mi,(const char*)mysql->net.read_pos + 1,
event_len, &event_buf, &event_len)))
Attachment: [text/bzr-bundle] bzr/serge.kozlov@sun.com-20101004100058-wf2r8zjpztx49xa1.bundle