Skip to content

Commit 54287ad

Browse files
committed
MDEV-7802 Add status binlog_group_commit_reason_*
The following global status variables where added: * binlog_group_commit_reason_count * binlog_group_commit_reason_usec * binlog_group_commit_reason_transaction * binlog_group_commit_reason_immediate binlog_group_commit_reason_count corresponds to group commits made by virtue of the binlog_commit_wait_count variable. binlog_group_commit_reason_usec corresponds to the binlog_commit_wait_usec variable. binlog_group_commit_reason_transaction is a result of ordered transaction that need to occur in the same order on the slave and can't be parallelised. binlog_group_commit_reason_immediate is caused to prevent stalls with row locks as described in log.cc:binlog_report_wait_for. This immediate count is also counted a second time in binlog_group_commit_reason_transaction. Overall binlog_group_commits = binlog_group_commit_reason_count + binlog_group_commit_reason_usec + binlog_group_commit_reason_transaction This work was funded thanks to Open Source Developers Club Australia.
1 parent c14d9c2 commit 54287ad

File tree

6 files changed

+291
-1
lines changed

6 files changed

+291
-1
lines changed

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

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ SET @old_count= @@GLOBAL.binlog_commit_wait_count;
44
SET GLOBAL binlog_commit_wait_count= 3;
55
SET @old_usec= @@GLOBAL.binlog_commit_wait_usec;
66
SET GLOBAL binlog_commit_wait_usec= 20000000;
7+
SELECT variable_value INTO @group_commits FROM information_schema.global_status
8+
WHERE variable_name = 'binlog_group_commits';
9+
SELECT variable_value INTO @group_commit_reason_count FROM information_schema.global_status
10+
WHERE variable_name = 'binlog_group_commit_reason_count';
11+
SELECT variable_value INTO @group_commit_reason_usec FROM information_schema.global_status
12+
WHERE variable_name = 'binlog_group_commit_reason_usec';
13+
SELECT variable_value INTO @group_commit_reason_transaction FROM information_schema.global_status
14+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
715
SET @a= current_timestamp();
816
BEGIN;
917
INSERT INTO t1 VALUES (1,0);
@@ -13,6 +21,22 @@ SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
1321
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
1422
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
1523
Ok
24+
SELECT variable_value - @group_commits FROM information_schema.global_status
25+
WHERE variable_name = 'binlog_group_commits';
26+
variable_value - @group_commits
27+
1
28+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
29+
WHERE variable_name = 'binlog_group_commit_reason_count';
30+
variable_value - @group_commit_reason_count
31+
0
32+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
33+
WHERE variable_name = 'binlog_group_commit_reason_usec';
34+
variable_value - @group_commit_reason_usec
35+
0
36+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
37+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
38+
variable_value - @group_commit_reason_transaction
39+
1
1640
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
1741
SET @a= current_timestamp();
1842
INSERT INTO t1 VALUES (2,0);
@@ -22,6 +46,22 @@ SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
2246
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
2347
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
2448
Ok
49+
SELECT variable_value - @group_commits FROM information_schema.global_status
50+
WHERE variable_name = 'binlog_group_commits';
51+
variable_value - @group_commits
52+
2
53+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
54+
WHERE variable_name = 'binlog_group_commit_reason_count';
55+
variable_value - @group_commit_reason_count
56+
1
57+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
58+
WHERE variable_name = 'binlog_group_commit_reason_usec';
59+
variable_value - @group_commit_reason_usec
60+
0
61+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
62+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
63+
variable_value - @group_commit_reason_transaction
64+
1
2565
SET @a= current_timestamp();
2666
INSERT INTO t1 VALUES (6,0);
2767
BEGIN;
@@ -36,13 +76,70 @@ SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
3676
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
3777
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
3878
Ok
79+
SELECT variable_value - @group_commits FROM information_schema.global_status
80+
WHERE variable_name = 'binlog_group_commits';
81+
variable_value - @group_commits
82+
3
83+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
84+
WHERE variable_name = 'binlog_group_commit_reason_count';
85+
variable_value - @group_commit_reason_count
86+
1
87+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
88+
WHERE variable_name = 'binlog_group_commit_reason_usec';
89+
variable_value - @group_commit_reason_usec
90+
0
91+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
92+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
93+
variable_value - @group_commit_reason_transaction
94+
2
3995
SET @a= current_timestamp();
4096
INSERT INTO t1 VALUES (7,0);
4197
INSERT INTO t1 VALUES (8,0);
4298
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
4399
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
44100
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
45101
Ok
102+
SELECT variable_value - @group_commits FROM information_schema.global_status
103+
WHERE variable_name = 'binlog_group_commits';
104+
variable_value - @group_commits
105+
4
106+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
107+
WHERE variable_name = 'binlog_group_commit_reason_count';
108+
variable_value - @group_commit_reason_count
109+
2
110+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
111+
WHERE variable_name = 'binlog_group_commit_reason_usec';
112+
variable_value - @group_commit_reason_usec
113+
0
114+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
115+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
116+
variable_value - @group_commit_reason_transaction
117+
2
118+
SET @a= current_timestamp();
119+
SET GLOBAL binlog_commit_wait_usec= 5*1000*1000;
120+
INSERT INTO t1 VALUES (9,0);
121+
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
122+
SELECT IF(@b < 4, CONCAT("Error: too little time elapsed: ", @b, " seconds < 4"),
123+
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")));
124+
IF(@b < 4, CONCAT("Error: too little time elapsed: ", @b, " seconds < 4"),
125+
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")))
126+
Ok
127+
SELECT variable_value - @group_commits FROM information_schema.global_status
128+
WHERE variable_name = 'binlog_group_commits';
129+
variable_value - @group_commits
130+
5
131+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
132+
WHERE variable_name = 'binlog_group_commit_reason_count';
133+
variable_value - @group_commit_reason_count
134+
2
135+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
136+
WHERE variable_name = 'binlog_group_commit_reason_usec';
137+
variable_value - @group_commit_reason_usec
138+
1
139+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
140+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
141+
variable_value - @group_commit_reason_transaction
142+
2
46143
SELECT * FROM t1 ORDER BY a;
47144
a b
48145
1 11
@@ -52,6 +149,7 @@ a b
52149
6 0
53150
7 0
54151
8 0
152+
9 0
55153
DROP TABLE t1;
56154
SET GLOBAL binlog_commit_wait_count= @old_count;
57155
SET GLOBAL binlog_commit_wait_usec= @old_usec;

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

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ connect(con1,localhost,root,,test);
1313
connect(con2,localhost,root,,test);
1414
connect(con3,localhost,root,,test);
1515

16+
# Get Initial status measurements
17+
--connection default
18+
SELECT variable_value INTO @group_commits FROM information_schema.global_status
19+
WHERE variable_name = 'binlog_group_commits';
20+
SELECT variable_value INTO @group_commit_reason_count FROM information_schema.global_status
21+
WHERE variable_name = 'binlog_group_commit_reason_count';
22+
SELECT variable_value INTO @group_commit_reason_usec FROM information_schema.global_status
23+
WHERE variable_name = 'binlog_group_commit_reason_usec';
24+
SELECT variable_value INTO @group_commit_reason_transaction FROM information_schema.global_status
25+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
26+
27+
# Note: binlog_group_commits is counted at the start of the group and group_commit_reason_* is
28+
# counted near when the groups its finalised.
29+
1630
# Check that if T2 goes to wait for a row lock of T1 while T1 is waiting for
1731
# more transactions to arrive for group commit, the commit of T1 will complete
1832
# immediately.
@@ -37,6 +51,18 @@ reap;
3751
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
3852
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
3953

54+
# before: binlog_group_commit=0, binlog_group_commit_reason_count=0
55+
# before: binlog_group_commit_reason_usec=0, binlog_group_commit_reason_transaction=0
56+
# after: binlog_group_commit+1 by reason of binlog_group_commit_reason_transaction+1
57+
SELECT variable_value - @group_commits FROM information_schema.global_status
58+
WHERE variable_name = 'binlog_group_commits';
59+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
60+
WHERE variable_name = 'binlog_group_commit_reason_count';
61+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
62+
WHERE variable_name = 'binlog_group_commit_reason_usec';
63+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
64+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
65+
4066
--connection con2
4167
--error ER_DUP_ENTRY
4268
reap;
@@ -64,6 +90,17 @@ reap;
6490
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
6591
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
6692

93+
# before: binlog_group_commit=1, binlog_group_commit_reason_count=0
94+
# before: binlog_group_commit_reason_usec=0, binlog_group_commit_reason_transaction=1
95+
# after: binlog_group_commit+1 by reason of binlog_group_commit_reason_count+1
96+
SELECT variable_value - @group_commits FROM information_schema.global_status
97+
WHERE variable_name = 'binlog_group_commits';
98+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
99+
WHERE variable_name = 'binlog_group_commit_reason_count';
100+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
101+
WHERE variable_name = 'binlog_group_commit_reason_usec';
102+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
103+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
67104

68105
# Test that commit triggers immediately if there is already a transaction
69106
# waiting on another transaction that reaches its commit.
@@ -99,6 +136,18 @@ reap;
99136
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
100137
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
101138

139+
# before: binlog_group_commit=2, binlog_group_commit_reason_count=1
140+
# before: binlog_group_commit_reason_usec=0, binlog_group_commit_reason_transaction=1
141+
# after: binlog_group_commit+1 by reason of binlog_group_commit_reason_transaction+1
142+
SELECT variable_value - @group_commits FROM information_schema.global_status
143+
WHERE variable_name = 'binlog_group_commits';
144+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
145+
WHERE variable_name = 'binlog_group_commit_reason_count';
146+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
147+
WHERE variable_name = 'binlog_group_commit_reason_usec';
148+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
149+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
150+
102151
--connection default
103152
SET @a= current_timestamp();
104153

@@ -114,6 +163,45 @@ reap;
114163
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
115164
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
116165

166+
# before: binlog_group_commit=3, binlog_group_commit_reason_count=1
167+
# before: binlog_group_commit_reason_usec=0, binlog_group_commit_reason_transaction=2
168+
# after: binlog_group_commit+1 by reason of binlog_group_commit_reason_count+1
169+
SELECT variable_value - @group_commits FROM information_schema.global_status
170+
WHERE variable_name = 'binlog_group_commits';
171+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
172+
WHERE variable_name = 'binlog_group_commit_reason_count';
173+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
174+
WHERE variable_name = 'binlog_group_commit_reason_usec';
175+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
176+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
177+
178+
# Test that when the binlog_commit_wait_usec is reached the tranction gets a group commit
179+
180+
--connection default
181+
SET @a= current_timestamp();
182+
SET GLOBAL binlog_commit_wait_usec= 5*1000*1000;
183+
184+
--connection con1
185+
reap;
186+
INSERT INTO t1 VALUES (9,0);
187+
188+
--connection default
189+
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
190+
SELECT IF(@b < 4, CONCAT("Error: too little time elapsed: ", @b, " seconds < 4"),
191+
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")));
192+
193+
# before: binlog_group_commit=4, binlog_group_commit_reason_count=2
194+
# before: binlog_group_commit_reason_usec=0, binlog_group_commit_reason_transaction=2
195+
# after: binlog_group_commit+1 by reason of binlog_group_commit_reason_usec+1
196+
SELECT variable_value - @group_commits FROM information_schema.global_status
197+
WHERE variable_name = 'binlog_group_commits';
198+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
199+
WHERE variable_name = 'binlog_group_commit_reason_count';
200+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
201+
WHERE variable_name = 'binlog_group_commit_reason_usec';
202+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
203+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
204+
117205
--connection default
118206
SELECT * FROM t1 ORDER BY a;
119207

mysql-test/suite/rpl/r/rpl_parallel_multilevel2.result

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ SET @old_updates= @@GLOBAL.binlog_direct_non_transactional_updates;
1616
SET GLOBAL binlog_direct_non_transactional_updates=OFF;
1717
SET SESSION binlog_direct_non_transactional_updates=OFF;
1818
CHANGE MASTER TO master_use_gtid=current_pos;
19+
SELECT variable_value INTO @group_commits FROM information_schema.global_status
20+
WHERE variable_name = 'binlog_group_commits';
21+
SELECT variable_value INTO @group_commit_reason_count FROM information_schema.global_status
22+
WHERE variable_name = 'binlog_group_commit_reason_count';
23+
SELECT variable_value INTO @group_commit_reason_usec FROM information_schema.global_status
24+
WHERE variable_name = 'binlog_group_commit_reason_usec';
25+
SELECT variable_value INTO @group_commit_reason_transaction FROM information_schema.global_status
26+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
27+
SELECT variable_value INTO @group_commit_reason_immediate FROM information_schema.global_status
28+
WHERE variable_name = 'binlog_group_commit_reason_immediate';
1929
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
2030
include/stop_slave.inc
2131
SET GLOBAL slave_parallel_threads=10;
@@ -37,6 +47,26 @@ include/sync_with_master_gtid.inc
3747
SELECT * FROM t1 ORDER BY a;
3848
a b
3949
1 10
50+
SELECT variable_value - @group_commits FROM information_schema.global_status
51+
WHERE variable_name = 'binlog_group_commits';
52+
variable_value - @group_commits
53+
3
54+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
55+
WHERE variable_name = 'binlog_group_commit_reason_count';
56+
variable_value - @group_commit_reason_count
57+
0
58+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
59+
WHERE variable_name = 'binlog_group_commit_reason_usec';
60+
variable_value - @group_commit_reason_usec
61+
3
62+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
63+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
64+
variable_value - @group_commit_reason_transaction
65+
0
66+
SELECT variable_value - @group_commit_reason_immediate FROM information_schema.global_status
67+
WHERE variable_name = 'binlog_group_commit_reason_immediate';
68+
variable_value - @group_commit_reason_immediate
69+
0
4070
include/stop_slave.inc
4171
SET GLOBAL slave_parallel_threads=@old_parallel_threads;
4272
SET GLOBAL binlog_commit_wait_count=@old_commit_count;

mysql-test/suite/rpl/t/rpl_parallel_multilevel2.test

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ SET GLOBAL binlog_direct_non_transactional_updates=OFF;
2727
SET SESSION binlog_direct_non_transactional_updates=OFF;
2828
CHANGE MASTER TO master_use_gtid=current_pos;
2929

30+
# Get Initial status measurements
31+
# we take out measurements from server_2 as that's where
32+
# the its critical that 3 separate binlog_group_commits occur
33+
SELECT variable_value INTO @group_commits FROM information_schema.global_status
34+
WHERE variable_name = 'binlog_group_commits';
35+
SELECT variable_value INTO @group_commit_reason_count FROM information_schema.global_status
36+
WHERE variable_name = 'binlog_group_commit_reason_count';
37+
SELECT variable_value INTO @group_commit_reason_usec FROM information_schema.global_status
38+
WHERE variable_name = 'binlog_group_commit_reason_usec';
39+
SELECT variable_value INTO @group_commit_reason_transaction FROM information_schema.global_status
40+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
41+
SELECT variable_value INTO @group_commit_reason_immediate FROM information_schema.global_status
42+
WHERE variable_name = 'binlog_group_commit_reason_immediate';
43+
44+
# Note: binlog_group_commits is counted at the start of the group and group_commit_reason_* is
45+
# counted near when the groups its finalised.
46+
47+
3048
--connection server_3
3149
--sync_with_master
3250
--save_master_pos
@@ -56,6 +74,18 @@ SELECT * FROM t1 ORDER BY a;
5674
--source include/sync_with_master_gtid.inc
5775
SELECT * FROM t1 ORDER BY a;
5876

77+
# Measure status(es)
78+
--connection server_2
79+
SELECT variable_value - @group_commits FROM information_schema.global_status
80+
WHERE variable_name = 'binlog_group_commits';
81+
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
82+
WHERE variable_name = 'binlog_group_commit_reason_count';
83+
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
84+
WHERE variable_name = 'binlog_group_commit_reason_usec';
85+
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
86+
WHERE variable_name = 'binlog_group_commit_reason_transaction';
87+
SELECT variable_value - @group_commit_reason_immediate FROM information_schema.global_status
88+
WHERE variable_name = 'binlog_group_commit_reason_immediate';
5989

6090
# Clean up
6191

0 commit comments

Comments
 (0)