Skip to content

Commit 1949d8c

Browse files
author
Libing Song
committed
WL#10956 Binlog Access API - Step3 Relaylog Applier Reader
This patch replaced the last Log_event::read_log_event() call to Relaylog_file_reader which was introduced in Step2 patch. So Log_event::read_log_event() was finally removed from the code. It also did some refacotring - It created Rpl_applier_reader class which is responsible for reading events from relaylog files. - The code of next_event was moved into Rpl_applier_reader class and separated into a few functions. - The applier reader is only need when applier is online. It is used as a local variable of handle_slave_sql(). - change_master and purge_relay_logs don't need to reopen or reinitialize the applier read anymore. So rli::init_relay_log_pos is reorganized as group_relay_log_is_valid() to verify group_relay_log_name existing. - rli::event_relay_log_pos and rli::event_relay_log_name are only used when applying events. So they just need to be intilaized in Rpl_applier_reader class. - Moved the code period checking out mts_checkpoint_routine. It was encapsulated into a new function called rli::is_time_for_mts_checkpoint
1 parent 191b1d1 commit 1949d8c

32 files changed

+1027
-1384
lines changed

client/mysqlbinlog.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,8 +1964,7 @@ static Exit_status dump_multiple_logs(int argc, char **argv) {
19641964
When reading a remote binlog, this function is used to grab the
19651965
Format_description_log_event in the beginning of the stream.
19661966
1967-
This is not as smart as check_header() (used for local log); it will
1968-
not work for a binlog which mixes format. TODO: fix this.
1967+
It will not work for a binlog which mixes format. TODO: fix this.
19691968
19701969
@retval ERROR_STOP An error occurred - the program should terminate.
19711970
@retval OK_CONTINUE No error, the program should continue.
@@ -2399,11 +2398,13 @@ class Stdin_binlog_istream : public Basic_seekable_istream,
23992398
return false;
24002399
}
24012400

2401+
/* purecov: begin inspected */
24022402
/** Stdin has no length. It should never be called. */
24032403
my_off_t length() override {
24042404
DBUG_ASSERT(0);
24052405
return 0;
24062406
};
2407+
/* purecov: end */
24072408

24082409
private:
24092410
/**
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
call mtr.add_suppression("Binary logging not possible");
2+
call mtr.add_suppression("Attempting backtrace");
3+
RESET MASTER;
4+
CREATE TABLE t1(c1 INT);
5+
SET debug = "+d,simulate_init_io_cache_failure";
6+
SHOW BINLOG EVENTS;
7+
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not open log file
8+
SET debug = "-d,simulate_init_io_cache_failure";
9+
SET debug = "+d,simulate_allocate_failure";
10+
SHOW BINLOG EVENTS;
11+
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: memory allocation failed reading log event
12+
SET debug = "-d,simulate_allocate_failure";
13+
SET debug = "+d,simulate_seek_failure";
14+
SHOW BINLOG EVENTS FROM 337;
15+
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: I/O error reading log event
16+
SET debug = "-d,simulate_seek_failure";
17+
SET debug = "+d,simulate_ostream_write_failure";
18+
INSERT INTO t1 VALUES(1);
19+
ERROR HY000: Binary logging not possible. Message: An error occurred during flush stage of the commit. 'binlog_error_action' is set to 'ABORT_SERVER'. Hence aborting the server.
20+
DROP TABLE t1;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Coverage Tests for WL#10956
2+
--source include/not_valgrind.inc
3+
--source include/have_debug.inc
4+
--source include/have_binlog_format_row.inc
5+
call mtr.add_suppression("Binary logging not possible");
6+
call mtr.add_suppression("Attempting backtrace");
7+
RESET MASTER;
8+
9+
CREATE TABLE t1(c1 INT);
10+
--let $start_pos = query_get_value(SHOW MASTER STATUS, Position, 1)
11+
12+
SET debug = "+d,simulate_init_io_cache_failure";
13+
--error ER_ERROR_WHEN_EXECUTING_COMMAND
14+
SHOW BINLOG EVENTS;
15+
SET debug = "-d,simulate_init_io_cache_failure";
16+
17+
SET debug = "+d,simulate_allocate_failure";
18+
--error ER_ERROR_WHEN_EXECUTING_COMMAND
19+
SHOW BINLOG EVENTS;
20+
SET debug = "-d,simulate_allocate_failure";
21+
22+
SET debug = "+d,simulate_seek_failure";
23+
--error ER_ERROR_WHEN_EXECUTING_COMMAND
24+
eval SHOW BINLOG EVENTS FROM $start_pos;
25+
SET debug = "-d,simulate_seek_failure";
26+
27+
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
28+
SET debug = "+d,simulate_ostream_write_failure";
29+
--error ER_BINLOG_LOGGING_IMPOSSIBLE
30+
INSERT INTO t1 VALUES(1);
31+
32+
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
33+
--enable_reconnect
34+
--source include/wait_until_connected_again.inc
35+
36+
--error 1
37+
--exec $MYSQL_BINLOG file_not_exist >/dev/null
38+
39+
--error 1,12
40+
--exec $MYSQL_BINLOG -#d,simulate_init_io_cache_failure - > /dev/null 2>&1
41+
42+
--error 1,12
43+
--exec $MYSQL_BINLOG -#d,simulate_init_io_cache_failure binlog.000001 > /dev/null 2>&1
44+
45+
--error 1,12
46+
--exec $MYSQL_BINLOG --start-position=100000000 binlog.000001 > /dev/null 2>&1
47+
DROP TABLE t1;
48+

mysql-test/suite/ndb_rpl/r/ndb_rpl_checksum.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ include/start_slave.inc
7777
set @@global.master_verify_checksum = 1;
7878
set @@session.debug='d,simulate_checksum_test_failure';
7979
show binlog events;
80-
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
80+
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: event read from binlog did not pass crc check
8181
set @@session.debug='';
8282
set @@global.master_verify_checksum = default;
8383
include/stop_slave.inc
@@ -92,7 +92,7 @@ set @@global.slave_sql_verify_checksum = 1;
9292
set @@global.debug='d,simulate_checksum_test_failure';
9393
start slave sql_thread;
9494
include/wait_for_slave_sql_error.inc [errno=13117]
95-
Last_SQL_Error = 'Error initializing relay log position: I/O error reading event at position 4'
95+
Last_SQL_Error = 'Error initializing relay log position: event read from binlog did not pass crc check'
9696
include/stop_slave.inc
9797
set @@global.debug='';
9898
include/start_slave.inc

mysql-test/suite/rpl/r/rpl_multi_source_channel_map_stress.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Note #### Storing MySQL user name or password information in the master info rep
77
CALL mtr.add_suppression('Slave failed to initialize master info structure from the repository');
88
CALL mtr.add_suppression('This operation cannot be performed with a running slave');
99
CALL mtr.add_suppression('Could not find target log file mentioned in relay log info in the index file');
10+
CALL mtr.add_suppression('Could not find relay log file');
1011
CALL mtr.add_suppression('A slave with the same server_uuid/server_id as this slave has connected to the master');
1112
SET @saved_event_scheduler= @@GLOBAL.event_scheduler;
1213
SET @saved_relay_log_purge= @@GLOBAL.relay_log_purge;

mysql-test/suite/rpl/r/rpl_reset_slave_fail.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ call mtr.add_suppression("Could not find target log file mentioned in relay log
2222
call mtr.add_suppression("Failed to initialize the relay-log-info structure");
2323
call mtr.add_suppression("Failed to initialize the master info structure");
2424
call mtr.add_suppression("Failed to create or recover replication info repositories");
25+
call mtr.add_suppression("listed in the index, but failed to stat");
26+
call mtr.add_suppression("Error counting relay log space");
2527
include/rpl_stop_server.inc [server_number=2]
2628
# Removing file(s)
2729
include/rpl_start_server.inc [server_number=2]

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
CALL mtr.add_suppression('Slave failed to initialize master info structure from the repository');
2727
CALL mtr.add_suppression('This operation cannot be performed with a running slave');
2828
CALL mtr.add_suppression('Could not find target log file mentioned in relay log info in the index file');
29+
# For case:
30+
# STOP SLAVE SQL_THREAD; // IO_THREAD is running
31+
# CHANGE MASTER TO relay_log_name = 'non-existing relay log name',...;
32+
# While CHANGE MASTER throwns an error, group_relay_log_name is changed to the
33+
# non-existing file name.
34+
# START SLAVE SQL_THREAD; // It will log below error.
35+
CALL mtr.add_suppression('Could not find relay log file');
2936
CALL mtr.add_suppression('A slave with the same server_uuid/server_id as this slave has connected to the master');
3037

3138
# Save current event scheduler status

mysql-test/suite/rpl/t/rpl_multi_source_slave_files.cnf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ relay-log-purge=0
1212
relay-log-recovery=1
1313
sync_relay_log=10
1414
max-relay-log-size=1073741824
15-
relay-log-space-limit=1073741824
1615
relay-log=relaylog-msr
1716
relay-log-index=relaylog-msr.index
1817
sync-master-info=10

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ call mtr.add_suppression("Could not find target log file mentioned in relay log
4141
call mtr.add_suppression("Failed to initialize the relay-log-info structure");
4242
call mtr.add_suppression("Failed to initialize the master info structure");
4343
call mtr.add_suppression("Failed to create or recover replication info repositories");
44+
call mtr.add_suppression("listed in the index, but failed to stat");
45+
call mtr.add_suppression("Error counting relay log space");
4446

4547
# Stop slave
4648
--let $rpl_server_number= 2

mysql-test/suite/rpl_nogtid/r/rpl_checksum.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ set @@global.slave_sql_verify_checksum = 1;
9292
set @@global.debug='d,simulate_checksum_test_failure';
9393
start slave sql_thread;
9494
include/wait_for_slave_sql_error.inc [errno=13117]
95-
Last_SQL_Error = 'Error initializing relay log position: I/O error reading event at position 4'
95+
Last_SQL_Error = 'Event crc check failed! Most likely there is event corruption.'
9696
include/stop_slave.inc
9797
set @@global.debug='';
9898
include/start_slave.inc

0 commit comments

Comments
 (0)