mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
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.
This commit is contained in:
@@ -4,6 +4,14 @@ SET @old_count= @@GLOBAL.binlog_commit_wait_count;
|
|||||||
SET GLOBAL binlog_commit_wait_count= 3;
|
SET GLOBAL binlog_commit_wait_count= 3;
|
||||||
SET @old_usec= @@GLOBAL.binlog_commit_wait_usec;
|
SET @old_usec= @@GLOBAL.binlog_commit_wait_usec;
|
||||||
SET GLOBAL binlog_commit_wait_usec= 20000000;
|
SET GLOBAL binlog_commit_wait_usec= 20000000;
|
||||||
|
SELECT variable_value INTO @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
SET @a= current_timestamp();
|
SET @a= current_timestamp();
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO t1 VALUES (1,0);
|
INSERT INTO t1 VALUES (1,0);
|
||||||
@@ -13,6 +21,22 @@ SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
|||||||
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
||||||
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
|
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
|
||||||
Ok
|
Ok
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
variable_value - @group_commits
|
||||||
|
1
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
variable_value - @group_commit_reason_count
|
||||||
|
0
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
variable_value - @group_commit_reason_usec
|
||||||
|
0
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
variable_value - @group_commit_reason_transaction
|
||||||
|
1
|
||||||
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
||||||
SET @a= current_timestamp();
|
SET @a= current_timestamp();
|
||||||
INSERT INTO t1 VALUES (2,0);
|
INSERT INTO t1 VALUES (2,0);
|
||||||
@@ -22,6 +46,22 @@ SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
|||||||
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
||||||
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
|
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
|
||||||
Ok
|
Ok
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
variable_value - @group_commits
|
||||||
|
2
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
variable_value - @group_commit_reason_count
|
||||||
|
1
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
variable_value - @group_commit_reason_usec
|
||||||
|
0
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
variable_value - @group_commit_reason_transaction
|
||||||
|
1
|
||||||
SET @a= current_timestamp();
|
SET @a= current_timestamp();
|
||||||
INSERT INTO t1 VALUES (6,0);
|
INSERT INTO t1 VALUES (6,0);
|
||||||
BEGIN;
|
BEGIN;
|
||||||
@@ -36,6 +76,22 @@ SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
|||||||
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
||||||
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
|
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
|
||||||
Ok
|
Ok
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
variable_value - @group_commits
|
||||||
|
3
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
variable_value - @group_commit_reason_count
|
||||||
|
1
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
variable_value - @group_commit_reason_usec
|
||||||
|
0
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
variable_value - @group_commit_reason_transaction
|
||||||
|
2
|
||||||
SET @a= current_timestamp();
|
SET @a= current_timestamp();
|
||||||
INSERT INTO t1 VALUES (7,0);
|
INSERT INTO t1 VALUES (7,0);
|
||||||
INSERT INTO t1 VALUES (8,0);
|
INSERT INTO t1 VALUES (8,0);
|
||||||
@@ -43,6 +99,47 @@ SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
|||||||
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
||||||
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
|
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
|
||||||
Ok
|
Ok
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
variable_value - @group_commits
|
||||||
|
4
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
variable_value - @group_commit_reason_count
|
||||||
|
2
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
variable_value - @group_commit_reason_usec
|
||||||
|
0
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
variable_value - @group_commit_reason_transaction
|
||||||
|
2
|
||||||
|
SET @a= current_timestamp();
|
||||||
|
SET GLOBAL binlog_commit_wait_usec= 5*1000*1000;
|
||||||
|
INSERT INTO t1 VALUES (9,0);
|
||||||
|
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
||||||
|
SELECT IF(@b < 4, CONCAT("Error: too little time elapsed: ", @b, " seconds < 4"),
|
||||||
|
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")));
|
||||||
|
IF(@b < 4, CONCAT("Error: too little time elapsed: ", @b, " seconds < 4"),
|
||||||
|
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")))
|
||||||
|
Ok
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
variable_value - @group_commits
|
||||||
|
5
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
variable_value - @group_commit_reason_count
|
||||||
|
2
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
variable_value - @group_commit_reason_usec
|
||||||
|
1
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
variable_value - @group_commit_reason_transaction
|
||||||
|
2
|
||||||
SELECT * FROM t1 ORDER BY a;
|
SELECT * FROM t1 ORDER BY a;
|
||||||
a b
|
a b
|
||||||
1 11
|
1 11
|
||||||
@@ -52,6 +149,7 @@ a b
|
|||||||
6 0
|
6 0
|
||||||
7 0
|
7 0
|
||||||
8 0
|
8 0
|
||||||
|
9 0
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
SET GLOBAL binlog_commit_wait_count= @old_count;
|
SET GLOBAL binlog_commit_wait_count= @old_count;
|
||||||
SET GLOBAL binlog_commit_wait_usec= @old_usec;
|
SET GLOBAL binlog_commit_wait_usec= @old_usec;
|
||||||
|
@@ -13,6 +13,20 @@ connect(con1,localhost,root,,test);
|
|||||||
connect(con2,localhost,root,,test);
|
connect(con2,localhost,root,,test);
|
||||||
connect(con3,localhost,root,,test);
|
connect(con3,localhost,root,,test);
|
||||||
|
|
||||||
|
# Get Initial status measurements
|
||||||
|
--connection default
|
||||||
|
SELECT variable_value INTO @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
|
||||||
|
# Note: binlog_group_commits is counted at the start of the group and group_commit_reason_* is
|
||||||
|
# counted near when the groups its finalised.
|
||||||
|
|
||||||
# Check that if T2 goes to wait for a row lock of T1 while T1 is waiting for
|
# Check that if T2 goes to wait for a row lock of T1 while T1 is waiting for
|
||||||
# more transactions to arrive for group commit, the commit of T1 will complete
|
# more transactions to arrive for group commit, the commit of T1 will complete
|
||||||
# immediately.
|
# immediately.
|
||||||
@@ -37,6 +51,18 @@ reap;
|
|||||||
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
||||||
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
||||||
|
|
||||||
|
# before: binlog_group_commit=0, binlog_group_commit_reason_count=0
|
||||||
|
# before: binlog_group_commit_reason_usec=0, binlog_group_commit_reason_transaction=0
|
||||||
|
# after: binlog_group_commit+1 by reason of binlog_group_commit_reason_transaction+1
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
|
||||||
--connection con2
|
--connection con2
|
||||||
--error ER_DUP_ENTRY
|
--error ER_DUP_ENTRY
|
||||||
reap;
|
reap;
|
||||||
@@ -64,6 +90,17 @@ reap;
|
|||||||
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
||||||
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
||||||
|
|
||||||
|
# before: binlog_group_commit=1, binlog_group_commit_reason_count=0
|
||||||
|
# before: binlog_group_commit_reason_usec=0, binlog_group_commit_reason_transaction=1
|
||||||
|
# after: binlog_group_commit+1 by reason of binlog_group_commit_reason_count+1
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
|
||||||
# Test that commit triggers immediately if there is already a transaction
|
# Test that commit triggers immediately if there is already a transaction
|
||||||
# waiting on another transaction that reaches its commit.
|
# waiting on another transaction that reaches its commit.
|
||||||
@@ -99,6 +136,18 @@ reap;
|
|||||||
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
||||||
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
||||||
|
|
||||||
|
# before: binlog_group_commit=2, binlog_group_commit_reason_count=1
|
||||||
|
# before: binlog_group_commit_reason_usec=0, binlog_group_commit_reason_transaction=1
|
||||||
|
# after: binlog_group_commit+1 by reason of binlog_group_commit_reason_transaction+1
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
|
||||||
--connection default
|
--connection default
|
||||||
SET @a= current_timestamp();
|
SET @a= current_timestamp();
|
||||||
|
|
||||||
@@ -114,6 +163,45 @@ reap;
|
|||||||
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
||||||
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
|
||||||
|
|
||||||
|
# before: binlog_group_commit=3, binlog_group_commit_reason_count=1
|
||||||
|
# before: binlog_group_commit_reason_usec=0, binlog_group_commit_reason_transaction=2
|
||||||
|
# after: binlog_group_commit+1 by reason of binlog_group_commit_reason_count+1
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
|
||||||
|
# Test that when the binlog_commit_wait_usec is reached the tranction gets a group commit
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
SET @a= current_timestamp();
|
||||||
|
SET GLOBAL binlog_commit_wait_usec= 5*1000*1000;
|
||||||
|
|
||||||
|
--connection con1
|
||||||
|
reap;
|
||||||
|
INSERT INTO t1 VALUES (9,0);
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
||||||
|
SELECT IF(@b < 4, CONCAT("Error: too little time elapsed: ", @b, " seconds < 4"),
|
||||||
|
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")));
|
||||||
|
|
||||||
|
# before: binlog_group_commit=4, binlog_group_commit_reason_count=2
|
||||||
|
# before: binlog_group_commit_reason_usec=0, binlog_group_commit_reason_transaction=2
|
||||||
|
# after: binlog_group_commit+1 by reason of binlog_group_commit_reason_usec+1
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
|
||||||
--connection default
|
--connection default
|
||||||
SELECT * FROM t1 ORDER BY a;
|
SELECT * FROM t1 ORDER BY a;
|
||||||
|
|
||||||
|
@@ -16,6 +16,16 @@ SET @old_updates= @@GLOBAL.binlog_direct_non_transactional_updates;
|
|||||||
SET GLOBAL binlog_direct_non_transactional_updates=OFF;
|
SET GLOBAL binlog_direct_non_transactional_updates=OFF;
|
||||||
SET SESSION binlog_direct_non_transactional_updates=OFF;
|
SET SESSION binlog_direct_non_transactional_updates=OFF;
|
||||||
CHANGE MASTER TO master_use_gtid=current_pos;
|
CHANGE MASTER TO master_use_gtid=current_pos;
|
||||||
|
SELECT variable_value INTO @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_immediate FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_immediate';
|
||||||
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
|
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
|
||||||
include/stop_slave.inc
|
include/stop_slave.inc
|
||||||
SET GLOBAL slave_parallel_threads=10;
|
SET GLOBAL slave_parallel_threads=10;
|
||||||
@@ -37,6 +47,26 @@ include/sync_with_master_gtid.inc
|
|||||||
SELECT * FROM t1 ORDER BY a;
|
SELECT * FROM t1 ORDER BY a;
|
||||||
a b
|
a b
|
||||||
1 10
|
1 10
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
variable_value - @group_commits
|
||||||
|
3
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
variable_value - @group_commit_reason_count
|
||||||
|
0
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
variable_value - @group_commit_reason_usec
|
||||||
|
3
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
variable_value - @group_commit_reason_transaction
|
||||||
|
0
|
||||||
|
SELECT variable_value - @group_commit_reason_immediate FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_immediate';
|
||||||
|
variable_value - @group_commit_reason_immediate
|
||||||
|
0
|
||||||
include/stop_slave.inc
|
include/stop_slave.inc
|
||||||
SET GLOBAL slave_parallel_threads=@old_parallel_threads;
|
SET GLOBAL slave_parallel_threads=@old_parallel_threads;
|
||||||
SET GLOBAL binlog_commit_wait_count=@old_commit_count;
|
SET GLOBAL binlog_commit_wait_count=@old_commit_count;
|
||||||
|
@@ -27,6 +27,24 @@ SET GLOBAL binlog_direct_non_transactional_updates=OFF;
|
|||||||
SET SESSION binlog_direct_non_transactional_updates=OFF;
|
SET SESSION binlog_direct_non_transactional_updates=OFF;
|
||||||
CHANGE MASTER TO master_use_gtid=current_pos;
|
CHANGE MASTER TO master_use_gtid=current_pos;
|
||||||
|
|
||||||
|
# Get Initial status measurements
|
||||||
|
# we take out measurements from server_2 as that's where
|
||||||
|
# the its critical that 3 separate binlog_group_commits occur
|
||||||
|
SELECT variable_value INTO @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
SELECT variable_value INTO @group_commit_reason_immediate FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_immediate';
|
||||||
|
|
||||||
|
# Note: binlog_group_commits is counted at the start of the group and group_commit_reason_* is
|
||||||
|
# counted near when the groups its finalised.
|
||||||
|
|
||||||
|
|
||||||
--connection server_3
|
--connection server_3
|
||||||
--sync_with_master
|
--sync_with_master
|
||||||
--save_master_pos
|
--save_master_pos
|
||||||
@@ -56,6 +74,18 @@ SELECT * FROM t1 ORDER BY a;
|
|||||||
--source include/sync_with_master_gtid.inc
|
--source include/sync_with_master_gtid.inc
|
||||||
SELECT * FROM t1 ORDER BY a;
|
SELECT * FROM t1 ORDER BY a;
|
||||||
|
|
||||||
|
# Measure status(es)
|
||||||
|
--connection server_2
|
||||||
|
SELECT variable_value - @group_commits FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commits';
|
||||||
|
SELECT variable_value - @group_commit_reason_count FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_count';
|
||||||
|
SELECT variable_value - @group_commit_reason_usec FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_usec';
|
||||||
|
SELECT variable_value - @group_commit_reason_transaction FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_transaction';
|
||||||
|
SELECT variable_value - @group_commit_reason_immediate FROM information_schema.global_status
|
||||||
|
WHERE variable_name = 'binlog_group_commit_reason_immediate';
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
|
|
||||||
|
43
sql/log.cc
43
sql/log.cc
@@ -95,6 +95,10 @@ mysql_mutex_t LOCK_commit_ordered;
|
|||||||
|
|
||||||
static ulonglong binlog_status_var_num_commits;
|
static ulonglong binlog_status_var_num_commits;
|
||||||
static ulonglong binlog_status_var_num_group_commits;
|
static ulonglong binlog_status_var_num_group_commits;
|
||||||
|
static ulonglong binlog_status_group_commit_reason_count;
|
||||||
|
static ulonglong binlog_status_group_commit_reason_immediate;
|
||||||
|
static ulonglong binlog_status_group_commit_reason_transaction;
|
||||||
|
static ulonglong binlog_status_group_commit_reason_usec;
|
||||||
static char binlog_snapshot_file[FN_REFLEN];
|
static char binlog_snapshot_file[FN_REFLEN];
|
||||||
static ulonglong binlog_snapshot_position;
|
static ulonglong binlog_snapshot_position;
|
||||||
|
|
||||||
@@ -104,6 +108,14 @@ static SHOW_VAR binlog_status_vars_detail[]=
|
|||||||
(char *)&binlog_status_var_num_commits, SHOW_LONGLONG},
|
(char *)&binlog_status_var_num_commits, SHOW_LONGLONG},
|
||||||
{"group_commits",
|
{"group_commits",
|
||||||
(char *)&binlog_status_var_num_group_commits, SHOW_LONGLONG},
|
(char *)&binlog_status_var_num_group_commits, SHOW_LONGLONG},
|
||||||
|
{"group_commit_reason_count",
|
||||||
|
(char *)&binlog_status_group_commit_reason_count, SHOW_LONGLONG},
|
||||||
|
{"group_commit_reason_immediate",
|
||||||
|
(char *)&binlog_status_group_commit_reason_immediate, SHOW_LONGLONG},
|
||||||
|
{"group_commit_reason_transaction",
|
||||||
|
(char *)&binlog_status_group_commit_reason_transaction, SHOW_LONGLONG},
|
||||||
|
{"group_commit_reason_usec",
|
||||||
|
(char *)&binlog_status_group_commit_reason_usec, SHOW_LONGLONG},
|
||||||
{"snapshot_file",
|
{"snapshot_file",
|
||||||
(char *)&binlog_snapshot_file, SHOW_CHAR},
|
(char *)&binlog_snapshot_file, SHOW_CHAR},
|
||||||
{"snapshot_position",
|
{"snapshot_position",
|
||||||
@@ -3035,6 +3047,8 @@ MYSQL_BIN_LOG::MYSQL_BIN_LOG(uint *sync_period)
|
|||||||
bytes_written(0), file_id(1), open_count(1),
|
bytes_written(0), file_id(1), open_count(1),
|
||||||
group_commit_queue(0), group_commit_queue_busy(FALSE),
|
group_commit_queue(0), group_commit_queue_busy(FALSE),
|
||||||
num_commits(0), num_group_commits(0),
|
num_commits(0), num_group_commits(0),
|
||||||
|
group_commit_reason_count(0), group_commit_reason_usec(0),
|
||||||
|
group_commit_reason_transaction(0), group_commit_reason_immediate(0),
|
||||||
sync_period_ptr(sync_period), sync_counter(0),
|
sync_period_ptr(sync_period), sync_counter(0),
|
||||||
state_file_deleted(false), binlog_state_recover_done(false),
|
state_file_deleted(false), binlog_state_recover_done(false),
|
||||||
is_relay_log(0), signal_cnt(0),
|
is_relay_log(0), signal_cnt(0),
|
||||||
@@ -7543,8 +7557,18 @@ MYSQL_BIN_LOG::wait_for_sufficient_commits()
|
|||||||
mysql_mutex_assert_owner(&LOCK_prepare_ordered);
|
mysql_mutex_assert_owner(&LOCK_prepare_ordered);
|
||||||
|
|
||||||
for (e= last_head= group_commit_queue, count= 0; e; e= e->next)
|
for (e= last_head= group_commit_queue, count= 0; e; e= e->next)
|
||||||
if (++count >= opt_binlog_commit_wait_count || unlikely(e->thd->has_waiter))
|
{
|
||||||
|
if (++count >= opt_binlog_commit_wait_count)
|
||||||
|
{
|
||||||
|
group_commit_reason_count++;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
if (unlikely(e->thd->has_waiter))
|
||||||
|
{
|
||||||
|
group_commit_reason_transaction++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mysql_mutex_unlock(&LOCK_log);
|
mysql_mutex_unlock(&LOCK_log);
|
||||||
set_timespec_nsec(wait_until, (ulonglong)1000*opt_binlog_commit_wait_usec);
|
set_timespec_nsec(wait_until, (ulonglong)1000*opt_binlog_commit_wait_usec);
|
||||||
@@ -7557,18 +7581,30 @@ MYSQL_BIN_LOG::wait_for_sufficient_commits()
|
|||||||
err= mysql_cond_timedwait(&COND_prepare_ordered, &LOCK_prepare_ordered,
|
err= mysql_cond_timedwait(&COND_prepare_ordered, &LOCK_prepare_ordered,
|
||||||
&wait_until);
|
&wait_until);
|
||||||
if (err == ETIMEDOUT)
|
if (err == ETIMEDOUT)
|
||||||
|
{
|
||||||
|
group_commit_reason_usec++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (unlikely(last_head->thd->has_waiter))
|
if (unlikely(last_head->thd->has_waiter))
|
||||||
|
{
|
||||||
|
group_commit_reason_transaction++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
head= group_commit_queue;
|
head= group_commit_queue;
|
||||||
for (e= head; e && e != last_head; e= e->next)
|
for (e= head; e && e != last_head; e= e->next)
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
if (unlikely(e->thd->has_waiter))
|
if (unlikely(e->thd->has_waiter))
|
||||||
|
{
|
||||||
|
group_commit_reason_transaction++;
|
||||||
goto after_loop;
|
goto after_loop;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (count >= opt_binlog_commit_wait_count)
|
if (count >= opt_binlog_commit_wait_count)
|
||||||
|
{
|
||||||
|
group_commit_reason_count++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
last_head= head;
|
last_head= head;
|
||||||
}
|
}
|
||||||
after_loop:
|
after_loop:
|
||||||
@@ -7603,6 +7639,7 @@ MYSQL_BIN_LOG::binlog_trigger_immediate_group_commit()
|
|||||||
head= group_commit_queue;
|
head= group_commit_queue;
|
||||||
if (head)
|
if (head)
|
||||||
{
|
{
|
||||||
|
group_commit_reason_immediate++;
|
||||||
head->thd->has_waiter= true;
|
head->thd->has_waiter= true;
|
||||||
mysql_cond_signal(&COND_prepare_ordered);
|
mysql_cond_signal(&COND_prepare_ordered);
|
||||||
}
|
}
|
||||||
@@ -9746,6 +9783,10 @@ TC_LOG_BINLOG::set_status_variables(THD *thd)
|
|||||||
mysql_mutex_lock(&LOCK_commit_ordered);
|
mysql_mutex_lock(&LOCK_commit_ordered);
|
||||||
binlog_status_var_num_commits= this->num_commits;
|
binlog_status_var_num_commits= this->num_commits;
|
||||||
binlog_status_var_num_group_commits= this->num_group_commits;
|
binlog_status_var_num_group_commits= this->num_group_commits;
|
||||||
|
binlog_status_group_commit_reason_count= this->group_commit_reason_count;
|
||||||
|
binlog_status_group_commit_reason_usec= this->group_commit_reason_usec;
|
||||||
|
binlog_status_group_commit_reason_transaction= this->group_commit_reason_transaction;
|
||||||
|
binlog_status_group_commit_reason_immediate= this->group_commit_reason_immediate;
|
||||||
if (!have_snapshot)
|
if (!have_snapshot)
|
||||||
{
|
{
|
||||||
set_binlog_snapshot_file(last_commit_pos_file);
|
set_binlog_snapshot_file(last_commit_pos_file);
|
||||||
|
@@ -515,6 +515,9 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
|
|||||||
ulonglong num_commits;
|
ulonglong num_commits;
|
||||||
/* Number of group commits done. */
|
/* Number of group commits done. */
|
||||||
ulonglong num_group_commits;
|
ulonglong num_group_commits;
|
||||||
|
/* The reason why the group commit was grouped */
|
||||||
|
ulonglong group_commit_reason_count, group_commit_reason_usec;
|
||||||
|
ulonglong group_commit_reason_transaction, group_commit_reason_immediate;
|
||||||
|
|
||||||
/* pointer to the sync period variable, for binlog this will be
|
/* pointer to the sync period variable, for binlog this will be
|
||||||
sync_binlog_period, for relay log this will be
|
sync_binlog_period, for relay log this will be
|
||||||
|
Reference in New Issue
Block a user