Skip to content

Commit 0bfb6a9

Browse files
author
Venkatesh Duggirala
committed
Bug#26589008 SYNC_BINLOG=0 SHOULD IGNORE BINLOG_GROUP_COMMIT_SYNC_DELAY
Problem: When sync_binlog=0, sync stage in binlog group commit is never reached. But still each binlog group is waiting for BINLOG_GROUP_COMMIT_SYNC_DELAY seconds before entering into sync stage. Fix: Now the code is changed in such a way that the waiting logic considers sync_binlog=0 case and skips delay logic in such case.
1 parent 7404416 commit 0bfb6a9

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
@@ -9157,6 +9157,7 @@ int MYSQL_BIN_LOG::ordered_commit(THD *thd, bool all, bool skip_commit)
91579157
int flush_error= 0, sync_error= 0;
91589158
my_off_t total_bytes= 0;
91599159
bool do_rotate= false;
9160+
unsigned int current_sync_period;
91609161

91619162
/*
91629163
These values are used while flushing a transaction, so clear
@@ -9304,7 +9305,8 @@ int MYSQL_BIN_LOG::ordered_commit(THD *thd, bool all, bool skip_commit)
93049305
in this ongoing SYNC stage. The "+1" used below in the
93059306
if condition is to count the ongoing sync stage.
93069307
*/
9307-
if (!flush_error && (sync_counter + 1 >= get_sync_period()))
9308+
current_sync_period= get_sync_period();
9309+
if (!flush_error && current_sync_period && (sync_counter + 1 >= current_sync_period))
93089310
stage_manager.wait_count_or_timeout(opt_binlog_group_commit_sync_no_delay_count,
93099311
opt_binlog_group_commit_sync_delay,
93109312
Stage_manager::SYNC_STAGE);

0 commit comments

Comments
 (0)