Skip to content

Commit 3e15934

Browse files
author
Venkatesh Duggirala
committed
Merge branch 'mysql-5.7' into mysql-trunk
2 parents 267ec5f + 0bfb6a9 commit 3e15934

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

mysql-test/suite/binlog/r/binlog_group_commit_sync_delay.result

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ SET GLOBAL sync_binlog=1000;
88
SET @clock_in = SYSDATE();
99
SET @elapsed = TIMESTAMPDIFF(MICROSECOND, @clock_in, SYSDATE());
1010
include/assert.inc ["Assert that the above statements should not take more than 1000 seconds"]
11+
SET GLOBAL sync_binlog=0;
12+
SET @clock_in = SYSDATE();
13+
SET @elapsed = TIMESTAMPDIFF(MICROSECOND, @clock_in, SYSDATE());
14+
include/assert.inc ["Assert that the above statements should not take more than 1000 seconds"]
1115
SET GLOBAL binlog_group_commit_sync_delay=0;
1216
SET GLOBAL sync_binlog=1;
1317
DROP TABLE t1;

mysql-test/suite/binlog/t/binlog_group_commit_sync_delay.test

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,37 @@ SET @elapsed = TIMESTAMPDIFF(MICROSECOND, @clock_in, SYSDATE());
2929
# But with fix, it should not take more than few seconds (that depends
3030
# on Pb2 machine speed and also depends on various build options too.
3131
#
32+
# Do above experiment with two iterations
33+
# 1) When sync_binlog > 1 (i.e., with 1000)
34+
# 2) When sync_binlog = 0
35+
#
3236
--let $group_count=1000
33-
--eval SET GLOBAL sync_binlog=$group_count
34-
--let $i=0
35-
36-
SET @clock_in = SYSDATE();
37-
--disable_query_log
38-
while ($i <= $group_count)
37+
--let $iter=1
38+
while ($iter <= 2)
3939
{
40-
--eval INSERT INTO t1 VALUES ($i)
41-
--inc $i
40+
if ($iter == 1)
41+
{
42+
--eval SET GLOBAL sync_binlog=$group_count
43+
}
44+
if ($iter == 2)
45+
{
46+
--eval SET GLOBAL sync_binlog=0
47+
}
48+
--let $i=0
49+
SET @clock_in = SYSDATE();
50+
--disable_query_log
51+
while ($i <= $group_count)
52+
{
53+
--eval INSERT INTO t1 VALUES ($i)
54+
--inc $i
55+
}
56+
--enable_query_log
57+
SET @elapsed = TIMESTAMPDIFF(MICROSECOND, @clock_in, SYSDATE());
58+
--let $assert_text="Assert that the above statements should not take more than 1000 seconds"
59+
--let $assert_cond= [SELECT @elapsed < 1000 * @@GLOBAL.binlog_group_commit_sync_delay]
60+
--source include/assert.inc
61+
--inc $iter
4262
}
43-
--enable_query_log
44-
SET @elapsed = TIMESTAMPDIFF(MICROSECOND, @clock_in, SYSDATE());
45-
--let $assert_text="Assert that the above statements should not take more than 1000 seconds"
46-
--let $assert_cond= [SELECT @elapsed < 1000 * @@GLOBAL.binlog_group_commit_sync_delay]
47-
--source include/assert.inc
48-
4963
# End of Bug#21420180 test
5064

5165
# Cleanup

sql/binlog.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9547,6 +9547,7 @@ int MYSQL_BIN_LOG::ordered_commit(THD *thd, bool all, bool skip_commit)
95479547
int flush_error= 0, sync_error= 0;
95489548
my_off_t total_bytes= 0;
95499549
bool do_rotate= false;
9550+
unsigned int current_sync_period;
95509551

95519552
DBUG_EXECUTE_IF("crash_commit_before_log", DBUG_SUICIDE(););
95529553
/*
@@ -9693,7 +9694,8 @@ int MYSQL_BIN_LOG::ordered_commit(THD *thd, bool all, bool skip_commit)
96939694
in this ongoing SYNC stage. The "+1" used below in the
96949695
if condition is to count the ongoing sync stage.
96959696
*/
9696-
if (!flush_error && (sync_counter + 1 >= get_sync_period()))
9697+
current_sync_period= get_sync_period();
9698+
if (!flush_error && current_sync_period && (sync_counter + 1 >= current_sync_period))
96979699
stage_manager.wait_count_or_timeout(opt_binlog_group_commit_sync_no_delay_count,
96989700
opt_binlog_group_commit_sync_delay,
96999701
Stage_manager::SYNC_STAGE);

0 commit comments

Comments
 (0)