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