Permalink
Browse files

Bug #20644100 "Event crc check failed" when master disable binlog_che…

…cksum

Starting slave sql_thread to apply events will cause event crc check
failure when master disables binlog_checksum.

Currently relay logs have the following sequence (starting from
position 4):
Format_desc (of slave)
Previous-GTIDs (of slave)
Rotate (of master)
Format_desc (of master)
The Format_desc which really describes the rest of the relay
log is the 4rd event, which is from master.
Relay_log_info::init_relay_log_pos(...) will look for a
Format_description_log_event from master. We only need this when
slave applier thread starts and opens an existing relay log and
has to execute it (possibly from an offset >4), because we need
to read the description event of the relay log to be able to
parse the events we have to execute.
But the current code supposed that relay logs have the following
sequence (starting from position 4):
Format_desc (of slave)
Rotate (of master)
Format_desc (of master)
So the function failed to find the Format_description_log_event
from master when slave applier thread starts and opens an existing
relay log and has to execute it, which causes some failures.
The event crc check failure is one of them.

Fix code to let slave applier thread also skip the Previous-GTIDs
log event to find the correct Format_description_log_event from
master when it is starting and opening an existing relay log.
  • Loading branch information...
Daogang.qu
Daogang.qu committed Mar 28, 2015
1 parent 8b53b00 commit 8a070d30fa66ac5f7099c9972ff7dc92955f979f
@@ -0,0 +1,18 @@
include/master-slave.inc
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[connection master]
[connection slave]
include/stop_slave_sql.inc
[connection master]
CREATE TABLE t1 (c1 INT);
#
# Start slave applier thread to verify that
# their is no event crc check failure.
#
[connection slave]
include/start_slave_sql.inc
[connection master]
DROP TABLE t1;
include/rpl_end.inc
@@ -0,0 +1 @@
--binlog_checksum=none
@@ -0,0 +1,66 @@
# ==== Purpose ====
#
# Bug #20644100 "Event crc check failed" when master disable binlog_checksum
#
# Starting slave sql_thread to apply events will cause event crc check
# failure when master disables binlog_checksum.
#
# Currently relay logs have the following sequence (starting from
# position 4):
# Format_desc (of slave)
# Previous-GTIDs (of slave)
# Rotate (of master)
# Format_desc (of master)
# The Format_desc which really describes the rest of the relay
# log is the 4rd event, which is from master.
# Relay_log_info::init_relay_log_pos(...) will look for a
# Format_description_log_event from master. We only need this when
# slave applier thread starts and opens an existing relay log and
# has to execute it (possibly from an offset >4), because we need
# to read the description event of the relay log to be able to
# parse the events we have to execute.
# But the current code supposed that relay logs have the following
# sequence (starting from position 4):
# Format_desc (of slave)
# Rotate (of master)
# Format_desc (of master)
# So the function failed to find the Format_description_log_event
# from master when slave applier thread starts and opens an existing
# relay log and has to execute it, which causes some failures.
# The event crc check failure is one of them.
#
# Fix code to let slave applier thread also skip the Previous-GTIDs
# log event to find the correct Format_description_log_event from
# master when it is starting and opening an existing relay log.
#
# Steps to reproduce:
# 1) Start master and slave servers
# 2) Stop slave applier thread.
# 3) Write an event into binary log on master
# when master disables binlog_checksum.
# 4) Start slave applier thread to verify that
# their is no event crc check failure.
#
# Test in this file is binlog format agnostic, thus no need
# to rerun them for every format.
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
--source include/rpl_connection_slave.inc
--source include/stop_slave_sql.inc
--source include/rpl_connection_master.inc
CREATE TABLE t1 (c1 INT);
--echo #
--echo # Start slave applier thread to verify that
--echo # their is no event crc check failure.
--echo #
--source include/rpl_connection_slave.inc
--source include/start_slave_sql.inc
--source include/rpl_connection_master.inc
DROP TABLE t1;
--source include/rpl_end.inc
View
@@ -576,23 +576,27 @@ int Relay_log_info::init_relay_log_pos(const char* log,
describes the whole relay log; indeed, one can have this sequence
(starting from position 4):
Format_desc (of slave)
Previous-GTIDs (of slave IO thread)
Rotate (of master)
Format_desc (of master)
So the Format_desc which really describes the rest of the relay log
is the 3rd event (it can't be further than that, because we rotate
is the 4rd event (it can't be further than that, because we rotate
the relay log when we queue a Rotate event from the master).
But what describes the Rotate is the first Format_desc.
So what we do is:
go on searching for Format_description events, until you exceed the
position (argument 'pos') or until you find another event than Rotate
or Format_desc.
position (argument 'pos') or until you find another event than
Previous-GTIDs, Rotate or Format_desc.
*/
}
else
{
DBUG_PRINT("info",("found event of another type=%d",
ev->get_type_code()));
look_for_description_event= (ev->get_type_code() == binary_log::ROTATE_EVENT);
look_for_description_event=
(ev->get_type_code() == binary_log::ROTATE_EVENT ||
ev->get_type_code() == binary_log::PREVIOUS_GTIDS_LOG_EVENT);
DBUG_ASSERT(look_for_description_event);
delete ev;
}
}

0 comments on commit 8a070d3

Please sign in to comment.