summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2012-12-17 12:49:11 +0100
committerunknown <knielsen@knielsen-hq.org>2012-12-17 12:49:11 +0100
commitcd0970c4808b80f33516e9e47e0bb62dae1e6bd5 (patch)
tree31b55b1341491021dbdcfc8e9060af59fb28435b
parent7760efad74140680b1eefaf2172b0fa26f7b1146 (diff)
downloadmariadb-git-cd0970c4808b80f33516e9e47e0bb62dae1e6bd5.tar.gz
MDEV-532: Fix some race conditions in test cases.
With MDEV-532, the binlog_checkpoint event is logged asynchronously from a binlog background thread. This causes some sporadic failures in some test cases whose output depends on order of events in binlog. Fix using an include file that waits until the binlog checkpoint event has been logged before proceeding with the test case.
-rw-r--r--mysql-test/extra/rpl_tests/rpl_insert_delayed.test2
-rw-r--r--mysql-test/extra/rpl_tests/rpl_log.test1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc2
-rw-r--r--mysql-test/include/wait_for_binlog_checkpoint.inc53
-rw-r--r--mysql-test/suite/innodb/t/binlog_consistent.test1
-rw-r--r--mysql-test/suite/multi_source/multisource.test1
6 files changed, 60 insertions, 0 deletions
diff --git a/mysql-test/extra/rpl_tests/rpl_insert_delayed.test b/mysql-test/extra/rpl_tests/rpl_insert_delayed.test
index 2dbba38166b..3d7d3600199 100644
--- a/mysql-test/extra/rpl_tests/rpl_insert_delayed.test
+++ b/mysql-test/extra/rpl_tests/rpl_insert_delayed.test
@@ -94,8 +94,10 @@ if (`SELECT @@global.binlog_format = 'STATEMENT'`)
#flush the logs before the test
connection slave;
FLUSH LOGS;
+ source include/wait_for_binlog_checkpoint.inc;
connection master;
FLUSH LOGS;
+ source include/wait_for_binlog_checkpoint.inc;
}
CREATE TABLE t1(a int, UNIQUE(a));
diff --git a/mysql-test/extra/rpl_tests/rpl_log.test b/mysql-test/extra/rpl_tests/rpl_log.test
index 892d926a156..961996bb265 100644
--- a/mysql-test/extra/rpl_tests/rpl_log.test
+++ b/mysql-test/extra/rpl_tests/rpl_log.test
@@ -43,6 +43,7 @@ let $binlog_limit= 1,4;
source include/show_binlog_events.inc;
let $binlog_limit=;
flush logs;
+--source include/wait_for_binlog_checkpoint.inc
# We need an extra update before doing save_master_pos.
# Otherwise, an unlikely scenario may occur:
diff --git a/mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc b/mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc
index a56e08ece42..d0a905d3b7d 100644
--- a/mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc
+++ b/mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc
@@ -41,8 +41,10 @@ INSERT INTO t1 VALUES (3);
#
FLUSH LOGS;
+--source include/wait_for_binlog_checkpoint.inc
-- connection master
FLUSH LOGS;
+--source include/wait_for_binlog_checkpoint.inc
DROP TABLE t1;
--let $is_relay_log= 0
diff --git a/mysql-test/include/wait_for_binlog_checkpoint.inc b/mysql-test/include/wait_for_binlog_checkpoint.inc
new file mode 100644
index 00000000000..960cf4e41b1
--- /dev/null
+++ b/mysql-test/include/wait_for_binlog_checkpoint.inc
@@ -0,0 +1,53 @@
+# include/wait_for_binlog_checkpoint.inc
+#
+# SUMMARY
+#
+# Wait until binlog checkpoint has been logged for current binlog file.
+# This is useful to avoid races with output difference for binlog
+# checkpoints, as these are logged asynchronously from the binlog
+# background thread.
+#
+# USAGE:
+#
+# --source include/wait_for_binlog_checkpoint.inc
+
+let $_wait_count= 300;
+
+let $_found= 0;
+
+while ($_wait_count)
+{
+ dec $_wait_count;
+ let $_cur_binlog= query_get_value(SHOW MASTER STATUS, File, 1);
+ let $_more= 1;
+ let $_row= 1;
+ while ($_more)
+ {
+ let $_event= query_get_value(SHOW BINLOG EVENTS IN "$_cur_binlog", Event_type, $_row);
+ if ($_event == "No such row")
+ {
+ let $_more= 0;
+ }
+ if ($_event == "Binlog_checkpoint")
+ {
+ let $_info= query_get_value(SHOW BINLOG EVENTS IN "$_cur_binlog", Info, $_row);
+ if (`SELECT INSTR("$_info", "$_cur_binlog") != 0`)
+ {
+ let $_more= 0;
+ let $_wait_count= 0;
+ let $_found= 1;
+ }
+ }
+ inc $_row;
+ }
+ if ($_wait_count)
+ {
+ real_sleep 0.1;
+ }
+}
+
+if (!$_found)
+{
+ eval SHOW BINLOG EVENTS IN "$_cur_binlog";
+ --die ERROR: failed while waiting for binlog checkpoint $_cur_binlog
+}
diff --git a/mysql-test/suite/innodb/t/binlog_consistent.test b/mysql-test/suite/innodb/t/binlog_consistent.test
index f4babb8bad7..20023871093 100644
--- a/mysql-test/suite/innodb/t/binlog_consistent.test
+++ b/mysql-test/suite/innodb/t/binlog_consistent.test
@@ -72,6 +72,7 @@ connection con3;
--echo # Connection con3
COMMIT;
FLUSH LOGS;
+--source include/wait_for_binlog_checkpoint.inc
connection default;
--echo # Connection default
diff --git a/mysql-test/suite/multi_source/multisource.test b/mysql-test/suite/multi_source/multisource.test
index e9d672a9ae3..7a9ee166ec2 100644
--- a/mysql-test/suite/multi_source/multisource.test
+++ b/mysql-test/suite/multi_source/multisource.test
@@ -169,6 +169,7 @@ select * from db2.t1;
--connection master1
flush logs;
+--source include/wait_for_binlog_checkpoint.inc
--save_master_pos
--connection slave
--sync_with_master 0, 'master1'