1ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
2CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
3SET @old_count= @@GLOBAL.binlog_commit_wait_count;
4SET GLOBAL binlog_commit_wait_count= 3;
5SET @old_usec= @@GLOBAL.binlog_commit_wait_usec;
6SET GLOBAL binlog_commit_wait_usec= 20000000;
7connect con1,localhost,root,,test;
8connect con2,localhost,root,,test;
9connect con3,localhost,root,,test;
10connection default;
11SELECT variable_value INTO @group_commits FROM information_schema.global_status
12WHERE variable_name = 'binlog_group_commits';
13SELECT variable_value INTO @group_commit_trigger_count FROM information_schema.global_status
14WHERE variable_name = 'binlog_group_commit_trigger_count';
15SELECT variable_value INTO @group_commit_trigger_timeout FROM information_schema.global_status
16WHERE variable_name = 'binlog_group_commit_trigger_timeout';
17SELECT variable_value INTO @group_commit_trigger_lock_wait FROM information_schema.global_status
18WHERE variable_name = 'binlog_group_commit_trigger_lock_wait';
19connection default;
20SET @a= current_timestamp();
21connection con1;
22BEGIN;
23INSERT INTO t1 VALUES (1,0);
24COMMIT;
25connection con2;
26INSERT INTO t1 VALUES (1,1);
27connection con1;
28connection default;
29SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
30SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
31IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
32Ok
33SELECT variable_value - @group_commits FROM information_schema.global_status
34WHERE variable_name = 'binlog_group_commits';
35variable_value - @group_commits
361
37SELECT variable_value - @group_commit_trigger_count FROM information_schema.global_status
38WHERE variable_name = 'binlog_group_commit_trigger_count';
39variable_value - @group_commit_trigger_count
400
41SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status
42WHERE variable_name = 'binlog_group_commit_trigger_timeout';
43variable_value - @group_commit_trigger_timeout
440
45SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status
46WHERE variable_name = 'binlog_group_commit_trigger_lock_wait';
47variable_value - @group_commit_trigger_lock_wait
481
49connection con2;
50ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
51connection default;
52SET @a= current_timestamp();
53connection con1;
54INSERT INTO t1 VALUES (2,0);
55connection con2;
56INSERT INTO t1 VALUES (3,0);
57connection con3;
58INSERT INTO t1 VALUES (4,0);
59connection con1;
60connection con2;
61connection default;
62SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
63SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
64IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
65Ok
66SELECT variable_value - @group_commits FROM information_schema.global_status
67WHERE variable_name = 'binlog_group_commits';
68variable_value - @group_commits
692
70SELECT variable_value - @group_commit_trigger_count FROM information_schema.global_status
71WHERE variable_name = 'binlog_group_commit_trigger_count';
72variable_value - @group_commit_trigger_count
731
74SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status
75WHERE variable_name = 'binlog_group_commit_trigger_timeout';
76variable_value - @group_commit_trigger_timeout
770
78SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status
79WHERE variable_name = 'binlog_group_commit_trigger_lock_wait';
80variable_value - @group_commit_trigger_lock_wait
811
82connection default;
83SET @a= current_timestamp();
84connection con1;
85INSERT INTO t1 VALUES (6,0);
86connection con2;
87BEGIN;
88UPDATE t1 SET b=b+1 WHERE a=1;
89connection con3;
90UPDATE t1 SET b=b+10 WHERE a=1;
91connection con2;
92SELECT SLEEP(0.25);
93SLEEP(0.25)
940
95UPDATE t1 SET b=b+1 WHERE a=3;
96COMMIT;
97connection con1;
98connection default;
99SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
100SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
101IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
102Ok
103SELECT variable_value - @group_commits FROM information_schema.global_status
104WHERE variable_name = 'binlog_group_commits';
105variable_value - @group_commits
1063
107SELECT variable_value - @group_commit_trigger_count FROM information_schema.global_status
108WHERE variable_name = 'binlog_group_commit_trigger_count';
109variable_value - @group_commit_trigger_count
1101
111SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status
112WHERE variable_name = 'binlog_group_commit_trigger_timeout';
113variable_value - @group_commit_trigger_timeout
1140
115SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status
116WHERE variable_name = 'binlog_group_commit_trigger_lock_wait';
117variable_value - @group_commit_trigger_lock_wait
1182
119connection default;
120SET @a= current_timestamp();
121connection con1;
122INSERT INTO t1 VALUES (7,0);
123connection con2;
124INSERT INTO t1 VALUES (8,0);
125connection con3;
126connection default;
127SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
128SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
129IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
130Ok
131SELECT variable_value - @group_commits FROM information_schema.global_status
132WHERE variable_name = 'binlog_group_commits';
133variable_value - @group_commits
1344
135SELECT variable_value - @group_commit_trigger_count FROM information_schema.global_status
136WHERE variable_name = 'binlog_group_commit_trigger_count';
137variable_value - @group_commit_trigger_count
1382
139SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status
140WHERE variable_name = 'binlog_group_commit_trigger_timeout';
141variable_value - @group_commit_trigger_timeout
1420
143SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status
144WHERE variable_name = 'binlog_group_commit_trigger_lock_wait';
145variable_value - @group_commit_trigger_lock_wait
1462
147connection default;
148SET @a= current_timestamp();
149SET GLOBAL binlog_commit_wait_usec= 5*1000*1000;
150connection con1;
151INSERT INTO t1 VALUES (9,0);
152connection default;
153SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
154SELECT IF(@b < 4, CONCAT("Error: too little time elapsed: ", @b, " seconds < 4"),
155IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")));
156IF(@b < 4, CONCAT("Error: too little time elapsed: ", @b, " seconds < 4"),
157IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")))
158Ok
159SELECT variable_value - @group_commits FROM information_schema.global_status
160WHERE variable_name = 'binlog_group_commits';
161variable_value - @group_commits
1625
163SELECT variable_value - @group_commit_trigger_count FROM information_schema.global_status
164WHERE variable_name = 'binlog_group_commit_trigger_count';
165variable_value - @group_commit_trigger_count
1662
167SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status
168WHERE variable_name = 'binlog_group_commit_trigger_timeout';
169variable_value - @group_commit_trigger_timeout
1701
171SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status
172WHERE variable_name = 'binlog_group_commit_trigger_lock_wait';
173variable_value - @group_commit_trigger_lock_wait
1742
175connection default;
176SELECT * FROM t1 ORDER BY a;
177a	b
1781	11
1792	0
1803	1
1814	0
1826	0
1837	0
1848	0
1859	0
186connection default;
187DROP TABLE t1;
188SET GLOBAL binlog_commit_wait_count= @old_count;
189SET GLOBAL binlog_commit_wait_usec= @old_usec;
190