Commit d795bc9f authored by unknown's avatar unknown

Fix race condition in binlog dump thread during server shutdown.

There was missing a check for THD::killed after THD::enter_cond(). This could
cause the binlog dump thread to miss the kill signal during server shutdown
and hang until it was force-closed.

Also fix a race in a test case that occasionally fails in Buildbot.
parent 9fae9930
...@@ -177,8 +177,8 @@ while ($_rpl_server) ...@@ -177,8 +177,8 @@ while ($_rpl_server)
if (!$rpl_skip_reset_master_and_slave) if (!$rpl_skip_reset_master_and_slave)
{ {
RESET MASTER; RESET MASTER;
RESET SLAVE;
SET GLOBAL gtid_pos= ""; SET GLOBAL gtid_pos= "";
RESET SLAVE;
} }
eval SET auto_increment_increment= $rpl_server_count; eval SET auto_increment_increment= $rpl_server_count;
eval SET auto_increment_offset= $_rpl_server; eval SET auto_increment_offset= $_rpl_server;
......
...@@ -107,6 +107,7 @@ a b ...@@ -107,6 +107,7 @@ a b
include/stop_slave.inc include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_MYPORT; CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_MYPORT;
include/start_slave.inc include/start_slave.inc
include/wait_for_slave_to_start.inc
include/stop_slave.inc include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SLAVE_MYPORT; CHANGE MASTER TO master_host = '127.0.0.1', master_port = SLAVE_MYPORT;
include/start_slave.inc include/start_slave.inc
......
...@@ -95,12 +95,16 @@ SELECT * FROM t2 ORDER BY a; ...@@ -95,12 +95,16 @@ SELECT * FROM t2 ORDER BY a;
--echo *** Now change everything back to what it was, to make rpl_end.inc happy --echo *** Now change everything back to what it was, to make rpl_end.inc happy
# Also check that MASTER_USE_GTID=1 is still enabled. # Also check that MASTER_USE_GTID=1 is still enabled.
connection server_2; connection server_2;
# We need to sync up server_2 before switching. If it happened to have reached
# the point 'UPDATE t2 SET b="j1a" WHERE a=5' it will fail to connect to
# server_1, which is (deliberately) missing that transaction.
--let $wait_condition= SELECT COUNT(*) = 7 FROM t2
--source include/wait_condition.inc
--source include/stop_slave.inc --source include/stop_slave.inc
--replace_result $MASTER_MYPORT MASTER_MYPORT --replace_result $MASTER_MYPORT MASTER_MYPORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT; eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT;
--source include/start_slave.inc --source include/start_slave.inc
--let $wait_condition= SELECT COUNT(*) = 7 FROM t2 --source include/wait_for_slave_to_start.inc
--source include/wait_condition.inc
connection server_3; connection server_3;
--source include/stop_slave.inc --source include/stop_slave.inc
......
...@@ -2263,6 +2263,8 @@ impossible position"; ...@@ -2263,6 +2263,8 @@ impossible position";
thd->enter_cond(log_cond, log_lock, thd->enter_cond(log_cond, log_lock,
"Master has sent all binlog to slave; " "Master has sent all binlog to slave; "
"waiting for binlog to be updated"); "waiting for binlog to be updated");
if (thd->killed)
break;
ret= mysql_bin_log.wait_for_update_bin_log(thd, heartbeat_ts); ret= mysql_bin_log.wait_for_update_bin_log(thd, heartbeat_ts);
DBUG_ASSERT(ret == 0 || (heartbeat_period != 0)); DBUG_ASSERT(ret == 0 || (heartbeat_period != 0));
if (ret == ETIMEDOUT || ret == ETIME) if (ret == ETIMEDOUT || ret == ETIME)
...@@ -2294,7 +2296,7 @@ impossible position"; ...@@ -2294,7 +2296,7 @@ impossible position";
{ {
DBUG_PRINT("wait",("binary log received update or a broadcast signal caught")); DBUG_PRINT("wait",("binary log received update or a broadcast signal caught"));
} }
} while (signal_cnt == mysql_bin_log.signal_cnt && !thd->killed); } while (signal_cnt == mysql_bin_log.signal_cnt);
thd->exit_cond(old_msg); thd->exit_cond(old_msg);
} }
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment