mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +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:
@ -13,6 +13,20 @@ connect(con1,localhost,root,,test);
|
||||
connect(con2,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
|
||||
# more transactions to arrive for group commit, the commit of T1 will complete
|
||||
# immediately.
|
||||
@ -37,6 +51,18 @@ reap;
|
||||
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
||||
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
|
||||
--error ER_DUP_ENTRY
|
||||
reap;
|
||||
@ -64,6 +90,17 @@ reap;
|
||||
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
||||
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
|
||||
# waiting on another transaction that reaches its commit.
|
||||
@ -99,6 +136,18 @@ reap;
|
||||
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
||||
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
|
||||
SET @a= current_timestamp();
|
||||
|
||||
@ -114,6 +163,45 @@ reap;
|
||||
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
|
||||
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
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
|
||||
|
Reference in New Issue
Block a user