summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2013-05-16 12:41:11 +0200
committerunknown <knielsen@knielsen-hq.org>2013-05-16 12:41:11 +0200
commitd795bc9ff8d4a4e17f249a0eb9ac01f25d53a259 (patch)
tree34cb2909f877f529da8d539b32af9797189d62de
parent9fae9930244d505585d83590051a17df9bab7d8a (diff)
downloadmariadb-git-d795bc9ff8d4a4e17f249a0eb9ac01f25d53a259.tar.gz
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.
-rw-r--r--mysql-test/include/rpl_init.inc2
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_basic.result1
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_basic.test8
-rw-r--r--sql/sql_repl.cc4
4 files changed, 11 insertions, 4 deletions
diff --git a/mysql-test/include/rpl_init.inc b/mysql-test/include/rpl_init.inc
index 939a05d8011..98e3c468253 100644
--- a/mysql-test/include/rpl_init.inc
+++ b/mysql-test/include/rpl_init.inc
@@ -177,8 +177,8 @@ while ($_rpl_server)
if (!$rpl_skip_reset_master_and_slave)
{
RESET MASTER;
- RESET SLAVE;
SET GLOBAL gtid_pos= "";
+ RESET SLAVE;
}
eval SET auto_increment_increment= $rpl_server_count;
eval SET auto_increment_offset= $_rpl_server;
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_basic.result b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
index bbe59ee69ae..b1e53a4a0b5 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_basic.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
@@ -107,6 +107,7 @@ a b
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_MYPORT;
include/start_slave.inc
+include/wait_for_slave_to_start.inc
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SLAVE_MYPORT;
include/start_slave.inc
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_basic.test b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
index becb284c0c2..9513acb17b6 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_basic.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
@@ -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
# Also check that MASTER_USE_GTID=1 is still enabled.
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
--replace_result $MASTER_MYPORT MASTER_MYPORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT;
--source include/start_slave.inc
---let $wait_condition= SELECT COUNT(*) = 7 FROM t2
---source include/wait_condition.inc
+--source include/wait_for_slave_to_start.inc
connection server_3;
--source include/stop_slave.inc
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index aa21d191166..2e10af0aa8c 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -2263,6 +2263,8 @@ impossible position";
thd->enter_cond(log_cond, log_lock,
"Master has sent all binlog to slave; "
"waiting for binlog to be updated");
+ if (thd->killed)
+ break;
ret= mysql_bin_log.wait_for_update_bin_log(thd, heartbeat_ts);
DBUG_ASSERT(ret == 0 || (heartbeat_period != 0));
if (ret == ETIMEDOUT || ret == ETIME)
@@ -2294,7 +2296,7 @@ impossible position";
{
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);
}
break;