diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-06-24 07:16:08 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-06-24 07:16:08 +0300 |
commit | 2e4984c185ddcd2da789017cd147338846ff409a (patch) | |
tree | 0293831900c860600efbaa747ea886d9d1cbf5bd /mysql-test/suite/binlog | |
parent | 792b53e80806df893ee62c9a1c1bd117114c8c6d (diff) | |
parent | a6087e7dc1ef3561d8189c8db15e9591d0f9b520 (diff) | |
download | mariadb-git-10.0-FusionIO.tar.gz |
Merge tag 'mariadb-10.0.20' into 10.0-FusionIO10.0-FusionIO
Conflicts:
storage/innobase/os/os0file.cc
storage/xtradb/os/os0file.cc
storage/xtradb/srv/srv0start.cc
Diffstat (limited to 'mysql-test/suite/binlog')
7 files changed, 555 insertions, 4 deletions
diff --git a/mysql-test/suite/binlog/r/binlog_commit_wait.result b/mysql-test/suite/binlog/r/binlog_commit_wait.result new file mode 100644 index 00000000000..07019c12905 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_commit_wait.result @@ -0,0 +1,155 @@ +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +SET @old_count= @@GLOBAL.binlog_commit_wait_count; +SET GLOBAL binlog_commit_wait_count= 3; +SET @old_usec= @@GLOBAL.binlog_commit_wait_usec; +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_trigger_count FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_count'; +SELECT variable_value INTO @group_commit_trigger_timeout FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +SELECT variable_value INTO @group_commit_trigger_lock_wait FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; +SET @a= current_timestamp(); +BEGIN; +INSERT INTO t1 VALUES (1,0); +COMMIT; +INSERT INTO t1 VALUES (1,1); +SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a); +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")) +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_trigger_count FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_count'; +variable_value - @group_commit_trigger_count +0 +SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +variable_value - @group_commit_trigger_timeout +0 +SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; +variable_value - @group_commit_trigger_lock_wait +1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SET @a= current_timestamp(); +INSERT INTO t1 VALUES (2,0); +INSERT INTO t1 VALUES (3,0); +INSERT INTO t1 VALUES (4,0); +SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a); +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")) +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_trigger_count FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_count'; +variable_value - @group_commit_trigger_count +1 +SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +variable_value - @group_commit_trigger_timeout +0 +SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; +variable_value - @group_commit_trigger_lock_wait +1 +SET @a= current_timestamp(); +INSERT INTO t1 VALUES (6,0); +BEGIN; +UPDATE t1 SET b=b+1 WHERE a=1; +UPDATE t1 SET b=b+10 WHERE a=1; +SELECT SLEEP(0.25); +SLEEP(0.25) +0 +UPDATE t1 SET b=b+1 WHERE a=3; +COMMIT; +SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a); +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")) +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_trigger_count FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_count'; +variable_value - @group_commit_trigger_count +1 +SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +variable_value - @group_commit_trigger_timeout +0 +SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; +variable_value - @group_commit_trigger_lock_wait +2 +SET @a= current_timestamp(); +INSERT INTO t1 VALUES (7,0); +INSERT INTO t1 VALUES (8,0); +SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a); +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")) +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_trigger_count FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_count'; +variable_value - @group_commit_trigger_count +2 +SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +variable_value - @group_commit_trigger_timeout +0 +SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; +variable_value - @group_commit_trigger_lock_wait +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_trigger_count FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_count'; +variable_value - @group_commit_trigger_count +2 +SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +variable_value - @group_commit_trigger_timeout +1 +SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status +WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; +variable_value - @group_commit_trigger_lock_wait +2 +SELECT * FROM t1 ORDER BY a; +a b +1 11 +2 0 +3 1 +4 0 +6 0 +7 0 +8 0 +9 0 +DROP TABLE t1; +SET GLOBAL binlog_commit_wait_count= @old_count; +SET GLOBAL binlog_commit_wait_usec= @old_usec; diff --git a/mysql-test/suite/binlog/r/binlog_database.result b/mysql-test/suite/binlog/r/binlog_database.result index 4f7d2dc7b94..504b3daa206 100644 --- a/mysql-test/suite/binlog/r/binlog_database.result +++ b/mysql-test/suite/binlog/r/binlog_database.result @@ -50,10 +50,31 @@ master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE `tt1` /* generate master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ FLUSH STATUS; + +# 'DROP TABLE IF EXISTS <deleted tables>' is binlogged +# when 'DROP DATABASE' fails and at least one table is deleted +# from the database. +RESET MASTER; +CREATE DATABASE testing_1; +USE testing_1; +CREATE TABLE t1(c1 INT); +CREATE TABLE t2(c1 INT); +# Create a file in the database directory +SELECT 'hello' INTO OUTFILE 'fake_file.FAKE_FILE'; + +# 'DROP DATABASE' will fail if there is any other file in the the +# database directory +DROP DATABASE testing_1; +ERROR HY000: Error dropping database (can't rmdir './testing_1', errno: 39 "Directory not empty") + +# Remove the fake file. +# Now we can drop the database. +DROP DATABASE testing_1; # # Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT # BASED REPLICATION # +USE test; DROP DATABASE IF EXISTS db1; DROP TABLE IF EXISTS t3; CREATE DATABASE db1; @@ -70,7 +91,7 @@ t2 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `db1`; DROP TABLE `t1` +master-bin.000001 # Query # # use `db1`; DROP TABLE IF EXISTS `t1` DROP TABLE t3; DROP DATABASE db1; set binlog_format=mixed; @@ -125,10 +146,31 @@ master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE `tt1` /* generate master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ FLUSH STATUS; + +# 'DROP TABLE IF EXISTS <deleted tables>' is binlogged +# when 'DROP DATABASE' fails and at least one table is deleted +# from the database. +RESET MASTER; +CREATE DATABASE testing_1; +USE testing_1; +CREATE TABLE t1(c1 INT); +CREATE TABLE t2(c1 INT); +# Create a file in the database directory +SELECT 'hello' INTO OUTFILE 'fake_file.FAKE_FILE'; + +# 'DROP DATABASE' will fail if there is any other file in the the +# database directory +DROP DATABASE testing_1; +ERROR HY000: Error dropping database (can't rmdir './testing_1', errno: 39 "Directory not empty") + +# Remove the fake file. +# Now we can drop the database. +DROP DATABASE testing_1; # # Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT # BASED REPLICATION # +USE test; DROP DATABASE IF EXISTS db1; DROP TABLE IF EXISTS t3; CREATE DATABASE db1; @@ -145,7 +187,7 @@ t2 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `db1`; DROP TABLE `t1` +master-bin.000001 # Query # # use `db1`; DROP TABLE IF EXISTS `t1` DROP TABLE t3; DROP DATABASE db1; set binlog_format=row; @@ -200,10 +242,31 @@ master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`tt1` /* gen master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ FLUSH STATUS; + +# 'DROP TABLE IF EXISTS <deleted tables>' is binlogged +# when 'DROP DATABASE' fails and at least one table is deleted +# from the database. +RESET MASTER; +CREATE DATABASE testing_1; +USE testing_1; +CREATE TABLE t1(c1 INT); +CREATE TABLE t2(c1 INT); +# Create a file in the database directory +SELECT 'hello' INTO OUTFILE 'fake_file.FAKE_FILE'; + +# 'DROP DATABASE' will fail if there is any other file in the the +# database directory +DROP DATABASE testing_1; +ERROR HY000: Error dropping database (can't rmdir './testing_1', errno: 39 "Directory not empty") + +# Remove the fake file. +# Now we can drop the database. +DROP DATABASE testing_1; # # Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT # BASED REPLICATION # +USE test; DROP DATABASE IF EXISTS db1; DROP TABLE IF EXISTS t3; CREATE DATABASE db1; @@ -220,7 +283,7 @@ t2 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `db1`; DROP TABLE `t1` +master-bin.000001 # Query # # use `db1`; DROP TABLE IF EXISTS `t1` DROP TABLE t3; DROP DATABASE db1; show databases; diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result index f24cd30167c..86c4c68d02b 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result @@ -327,6 +327,18 @@ INSERT INTO t2 SET a=1; INSERT INTO t2 SET b=1; UPDATE t1, t2 SET t1.a=10, t2.a=20; DROP TABLE t1,t2; +INSERT INTO t1dec102 VALUES (-999.99); +INSERT INTO t1dec102 VALUES (0); +INSERT INTO t1dec102 VALUES (999.99); +SELECT * FROM t1dec102 ORDER BY a; +a +-999.99 +0.00 +123.45 +123.46 +123.47 +999.99 +DROP TABLE t1dec102; flush logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/; @@ -4554,6 +4566,62 @@ SET TIMESTAMP=1000000000/*!*/; DROP TABLE `t1`,`t2` /* generated by server */ /*!*/; # at # +#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-317 +/*!100001 SET @@session.gtid_seq_no=317*//*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1dec102` mapped to number # +#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO `test`.`t1dec102` +### SET +### @1=!! Old DECIMAL (mysql-4.1 or earlier). Not enough metadata to display the value. # at # +#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-318 +/*!100001 SET @@session.gtid_seq_no=318*//*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1dec102` mapped to number # +#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO `test`.`t1dec102` +### SET +### @1=!! Old DECIMAL (mysql-4.1 or earlier). Not enough metadata to display the value. # at # +#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-319 +/*!100001 SET @@session.gtid_seq_no=319*//*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1dec102` mapped to number # +#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO `test`.`t1dec102` +### SET +### @1=!! Old DECIMAL (mysql-4.1 or earlier). Not enough metadata to display the value. # at # +#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-320 +/*!100001 SET @@session.gtid_seq_no=320*//*!*/; +# at # +#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +DROP TABLE `t1dec102` /* generated by server */ +/*!*/; +# at # #010909 4:46:40 server id 1 end_log_pos # Rotate to master-bin.000002 pos: 4 DELIMITER ; # End of log file diff --git a/mysql-test/suite/binlog/r/temptable_uservar_disconnect-7938.result b/mysql-test/suite/binlog/r/temptable_uservar_disconnect-7938.result new file mode 100644 index 00000000000..f09216cb539 --- /dev/null +++ b/mysql-test/suite/binlog/r/temptable_uservar_disconnect-7938.result @@ -0,0 +1,8 @@ +create table t1 (i int); +create trigger tr after insert on t1 for each row set @b=@a; +create temporary table tmp like t1; +insert into t1 values (1); +select * from t1; +i +1 +drop table t1; diff --git a/mysql-test/suite/binlog/t/binlog_commit_wait.test b/mysql-test/suite/binlog/t/binlog_commit_wait.test new file mode 100644 index 00000000000..7d7af2a90e2 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_commit_wait.test @@ -0,0 +1,229 @@ +--source include/have_innodb.inc +--source include/have_log_bin.inc + +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; + +SET @old_count= @@GLOBAL.binlog_commit_wait_count; +SET GLOBAL binlog_commit_wait_count= 3; +SET @old_usec= @@GLOBAL.binlog_commit_wait_usec; +SET GLOBAL binlog_commit_wait_usec= 20000000; + +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_trigger_count FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_count'; +SELECT variable_value INTO @group_commit_trigger_timeout FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +SELECT variable_value INTO @group_commit_trigger_lock_wait FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; + +# Note: binlog_group_commits is counted at the start of the group and group_commit_trigger_* 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. +# We test this by setting a very high timeout (20 seconds), and testing that +# that much time does not elapse. + +--connection default +SET @a= current_timestamp(); + +--connection con1 +BEGIN; +INSERT INTO t1 VALUES (1,0); +send COMMIT; + +--connection con2 +send INSERT INTO t1 VALUES (1,1); + +--connection con1 +reap; + +--connection default +SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a); +SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")); + +# All connections are to the same server. One transaction occurs on con1. It is +# commited before con2 is started. con2 transaction violates the unique key contraint. This +# type of group commit is binlog_group_commit_trigger_lock_wait so that further con2 +# transactions will occur afterwards as they may be as result of the ER_DUP_ENTRY on the +# application side. +# before: binlog_group_commit=0, binlog_group_commit_trigger_count=0 +# before: binlog_group_commit_trigger_timeout=0, binlog_group_commit_trigger_lock_wait=0 +# after: binlog_group_commit+1 by reason of binlog_group_commit_trigger_lock_wait+1 +SELECT variable_value - @group_commits FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commits'; +SELECT variable_value - @group_commit_trigger_count FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_count'; +SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; + +--connection con2 +--error ER_DUP_ENTRY +reap; + + +# Test that the commit triggers when sufficient commits have queued up. +--connection default +SET @a= current_timestamp(); + +--connection con1 +send INSERT INTO t1 VALUES (2,0); + +--connection con2 +send INSERT INTO t1 VALUES (3,0); + +--connection con3 +INSERT INTO t1 VALUES (4,0); + +--connection con1 +reap; +--connection con2 +reap; + +--connection default +SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a); +SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")); + +# All connections are to the same server. 3 non-conflicting transaction occur +# on each connection. The binlog_commit_wait_count=3 at the start therefore 1 +# group is committed by virtue of reaching 3 transactions. Hence +# binlog_group_commit_trigger_count is incremented. +# before: binlog_group_commit=1, binlog_group_commit_trigger_count=0 +# before: binlog_group_commit_trigger_timeout=0, binlog_group_commit_trigger_lock_wait=1 +# after: binlog_group_commit+1 by reason of binlog_group_commit_trigger_count+1 +SELECT variable_value - @group_commits FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commits'; +SELECT variable_value - @group_commit_trigger_count FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_count'; +SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; + +# Test that commit triggers immediately if there is already a transaction +# waiting on another transaction that reaches its commit. + +--connection default +SET @a= current_timestamp(); + +--connection con1 +send INSERT INTO t1 VALUES (6,0); + +--connection con2 +BEGIN; +UPDATE t1 SET b=b+1 WHERE a=1; + +--connection con3 +send UPDATE t1 SET b=b+10 WHERE a=1; + +--connection con2 +# A small sleep to let con3 have time to wait on con2. +# The sleep might be too small on loaded host, but that is not a big problem; +# it only means we will trigger a different code path (con3 waits after con2 +# is ready to commit rather than before); and either path should work the same. +# So we will not get false positive in case of different timing; at worst false +# negative. +SELECT SLEEP(0.25); +UPDATE t1 SET b=b+1 WHERE a=3; +COMMIT; + +--connection con1 +reap; + +--connection default +SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a); +SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")); + +# All connections are to the same server. con2 and con3 updates are aquiring +# the same row lock for a=1. Either con2 or con3 will be in a lock wait +# thefore the binlog_group_commit_trigger_lock_wait is incremented. +# before: binlog_group_commit=2, binlog_group_commit_trigger_count=1 +# before: binlog_group_commit_trigger_timeout=0, binlog_group_commit_trigger_lock_wait=1 +# after: binlog_group_commit+1 by reason of binlog_group_commit_trigger_lock_wait+1 +SELECT variable_value - @group_commits FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commits'; +SELECT variable_value - @group_commit_trigger_count FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_count'; +SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; + +--connection default +SET @a= current_timestamp(); + +# Now con3 will be waiting for a following group commit to trigger. +--connection con1 +send INSERT INTO t1 VALUES (7,0); +--connection con2 +INSERT INTO t1 VALUES (8,0); +--connection con3 +reap; + +--connection default +SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a); +SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20")); + +# The con1 and con2 transactions above are combined with the 'send UPDATE t1 SET b=b+10 WHERE a=1;' +# on con3 from the previous block. So we have 3 so this is a count based group. +# before: binlog_group_commit=3, binlog_group_commit_trigger_count=1 +# before: binlog_group_commit_trigger_timeout=0, binlog_group_commit_trigger_lock_wait=2 +# after: binlog_group_commit+1 by reason of binlog_group_commit_trigger_count+1 +SELECT variable_value - @group_commits FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commits'; +SELECT variable_value - @group_commit_trigger_count FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_count'; +SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; + +# 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"))); + +# con1 pushes 1 transaction. The count was for 3 to occur before a group commit. +# The timeout is 5 seconds but we allow between 4 and 20 because of the fragile nature +# of time in test. This is a timeout causing the commit so binlog_group_commit_trigger_timeout +# is incremented. +# before: binlog_group_commit=4, binlog_group_commit_trigger_count=2 +# before: binlog_group_commit_trigger_timeout=0, binlog_group_commit_trigger_lock_wait=2 +# after: binlog_group_commit+1 by reason of binlog_group_commit_trigger_timeout+1 +SELECT variable_value - @group_commits FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commits'; +SELECT variable_value - @group_commit_trigger_count FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_count'; +SELECT variable_value - @group_commit_trigger_timeout FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_timeout'; +SELECT variable_value - @group_commit_trigger_lock_wait FROM information_schema.global_status + WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; + +--connection default +SELECT * FROM t1 ORDER BY a; + +--connection default +DROP TABLE t1; +SET GLOBAL binlog_commit_wait_count= @old_count; +SET GLOBAL binlog_commit_wait_usec= @old_usec; diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row.test index 9b41c63d195..9609a9af384 100644 --- a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row.test +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row.test @@ -438,9 +438,20 @@ INSERT INTO t2 SET b=1; UPDATE t1, t2 SET t1.a=10, t2.a=20; DROP TABLE t1,t2; +let $MYSQLD_DATADIR= `select @@datadir`; + +--copy_file std_data/old_decimal/t1dec102.frm $MYSQLD_DATADIR/test/t1dec102.frm +--copy_file std_data/old_decimal/t1dec102.MYD $MYSQLD_DATADIR/test/t1dec102.MYD +--copy_file std_data/old_decimal/t1dec102.MYI $MYSQLD_DATADIR/test/t1dec102.MYI + +INSERT INTO t1dec102 VALUES (-999.99); +INSERT INTO t1dec102 VALUES (0); +INSERT INTO t1dec102 VALUES (999.99); +SELECT * FROM t1dec102 ORDER BY a; +DROP TABLE t1dec102; + flush logs; -let $MYSQLD_DATADIR= `select @@datadir`; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9]*[.][0-9]{1,3})[0-9e+-]*[^ ]*(.*(FLOAT|DOUBLE).*[*].)/\1...\2/ --exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001 diff --git a/mysql-test/suite/binlog/t/temptable_uservar_disconnect-7938.test b/mysql-test/suite/binlog/t/temptable_uservar_disconnect-7938.test new file mode 100644 index 00000000000..a1d91e2f98f --- /dev/null +++ b/mysql-test/suite/binlog/t/temptable_uservar_disconnect-7938.test @@ -0,0 +1,17 @@ +# +# MDEV-7938 MariaDB Crashes Suddenly while writing binlogs +# +--source include/have_log_bin.inc +--source include/have_binlog_format_mixed.inc + +--connect(con1,localhost,root,,) +create table t1 (i int); +create trigger tr after insert on t1 for each row set @b=@a; + +create temporary table tmp like t1; +insert into t1 values (1); +--disconnect con1 + +--connection default +select * from t1; +drop table t1; |