Commit cd0970c4 authored by unknown's avatar unknown

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.
parent 7760efad
...@@ -94,8 +94,10 @@ if (`SELECT @@global.binlog_format = 'STATEMENT'`) ...@@ -94,8 +94,10 @@ if (`SELECT @@global.binlog_format = 'STATEMENT'`)
#flush the logs before the test #flush the logs before the test
connection slave; connection slave;
FLUSH LOGS; FLUSH LOGS;
source include/wait_for_binlog_checkpoint.inc;
connection master; connection master;
FLUSH LOGS; FLUSH LOGS;
source include/wait_for_binlog_checkpoint.inc;
} }
CREATE TABLE t1(a int, UNIQUE(a)); CREATE TABLE t1(a int, UNIQUE(a));
......
...@@ -43,6 +43,7 @@ let $binlog_limit= 1,4; ...@@ -43,6 +43,7 @@ let $binlog_limit= 1,4;
source include/show_binlog_events.inc; source include/show_binlog_events.inc;
let $binlog_limit=; let $binlog_limit=;
flush logs; flush logs;
--source include/wait_for_binlog_checkpoint.inc
# We need an extra update before doing save_master_pos. # We need an extra update before doing save_master_pos.
# Otherwise, an unlikely scenario may occur: # Otherwise, an unlikely scenario may occur:
......
...@@ -41,8 +41,10 @@ INSERT INTO t1 VALUES (3); ...@@ -41,8 +41,10 @@ INSERT INTO t1 VALUES (3);
# #
FLUSH LOGS; FLUSH LOGS;
--source include/wait_for_binlog_checkpoint.inc
-- connection master -- connection master
FLUSH LOGS; FLUSH LOGS;
--source include/wait_for_binlog_checkpoint.inc
DROP TABLE t1; DROP TABLE t1;
--let $is_relay_log= 0 --let $is_relay_log= 0
......
# 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
}
...@@ -72,6 +72,7 @@ connection con3; ...@@ -72,6 +72,7 @@ connection con3;
--echo # Connection con3 --echo # Connection con3
COMMIT; COMMIT;
FLUSH LOGS; FLUSH LOGS;
--source include/wait_for_binlog_checkpoint.inc
connection default; connection default;
--echo # Connection default --echo # Connection default
......
...@@ -169,6 +169,7 @@ select * from db2.t1; ...@@ -169,6 +169,7 @@ select * from db2.t1;
--connection master1 --connection master1
flush logs; flush logs;
--source include/wait_for_binlog_checkpoint.inc
--save_master_pos --save_master_pos
--connection slave --connection slave
--sync_with_master 0, 'master1' --sync_with_master 0, 'master1'
......
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