Permalink
Browse files

Bug#21816399 5.6.24: LOST DATA DURING MASTER RESTART IF PARTIAL TRANS…

…ACT HAS BEEN DOWNLOADED

Problem: If dump thread is killed (during shutdown/explicit kill) during
dumping a non-active binary log, events in that binary log are getting
skipped completely and not getting replicated to slave.

Analysis: During bug#19975697 fix, we have identified a case where a dump
thread is unnecessarily looping through a binary log file even if it is
in killed state. Problem is big enough if the binary log file is huge
Hence we fixed it by adding thd->killed flag check in while condition.
But after the while loop is exited, it was not checked whether while loop
was broken due to thd->killed condition or not. Earlier the code after
the while loop assumes that the loop processes full binary log file and
dump thread can be safely moved to next binary log.
But with this new condition, it is not the case.

Fix: A condition "if (thd->killed)" after the while loop and should exit
the dump thread without doing any work.

(cherry picked from commit 97d9f26d153e1aa688a5328c5e691953a2761e4d)
  • Loading branch information...
Venkatesh Duggirala authored and bjornmu committed Sep 11, 2015
1 parent 02211fb commit 0911fe2e28da2778d5385a8c7f93307f64bd807b
@@ -0,0 +1,17 @@
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]
CREATE TABLE t1(i INT) engine=innodb;
INSERT INTO t1 VALUES (1);
FLUSH LOGS;
SET GLOBAL DEBUG='+d,simulate_dump_thread_kill';
include/start_slave.inc
SET GLOBAL DEBUG='-d,simulate_dump_thread_kill';
include/stop_slave.inc
include/start_slave.inc
include/sync_slave_sql_with_master.inc
include/diff_tables.inc [master:t1,slave:t1]
DROP TABLE t1;
include/rpl_end.inc
@@ -0,0 +1,55 @@
###############################################################################
# Bug #21816399 5.6.24: LOST DATA DURING MASTER RESTART IF PARTIAL TRANSACT HAS
# BEEN DOWNLOADED
#
# Problem: If dump thread is killed (during shutdown/explicit kill) during
# dumping a non-active binary log, events in the binary log are not getting
# replicated.
# Steps to reproduce:
# 1) Create a binary log with some events
# 2) Rotate it to make it non-active log
# 3) While dump thread is sending data to slave, kill it.
# 4) Make sure that dump thread is killed
# 5) Start dump thread
# 6) See that there is no issue in replication
###############################################################################
--source include/have_binlog_format_statement.inc
--source include/have_debug.inc
--let $rpl_skip_start_slave=1
--source include/master-slave.inc
# 1) Create a binary log with some events
CREATE TABLE t1(i INT) engine=innodb;
INSERT INTO t1 VALUES (1);
# 2) Rotate it to make it non-active log
FLUSH LOGS;
# 3) While dump thread is sending data to slave, kill it.
SET GLOBAL DEBUG='+d,simulate_dump_thread_kill';
--connection slave
--source include/start_slave.inc
# 4) Make sure that dump thread is killed
--connection master
--let $wait_condition= SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND = 'Binlog dump' OR COMMAND = 'Binlog Dump GTID'
--source include/wait_condition.inc
SET GLOBAL DEBUG='-d,simulate_dump_thread_kill';
# 5) Start dump thread
--connection slave
--source include/stop_slave.inc
--source include/start_slave.inc
# 6) See that there is no issue in replication
--connection master
--source include/sync_slave_sql_with_master.inc
--let diff_tables=master:t1,slave:t1
--source include/diff_tables.inc
# Cleanup
--connection master
DROP TABLE t1;
--source include/rpl_end.inc
View
@@ -1249,6 +1249,10 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
log_file_name,
&is_active_binlog)))
{
DBUG_EXECUTE_IF("simulate_dump_thread_kill",
{
thd->killed= THD::KILL_CONNECTION;
});
DBUG_EXECUTE_IF("hold_dump_thread_inside_inner_loop",
{
const char act[]= "now "
@@ -1532,6 +1536,10 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
GOTO_ERR;
}
/* If the above while is killed due to thd->killed flag and not
due to read_log_event error, then do nothing.*/
if (thd->killed)
goto end;
DBUG_EXECUTE_IF("wait_after_binlog_EOF",
{
const char act[]= "now wait_for signal.rotate_finished no_clear_event";

0 comments on commit 0911fe2

Please sign in to comment.