| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/have_log_bin.inc |
| 3 |
--source include/have_binlog_format_mixed_or_statement.inc |
| 4 |
--source include/binlog_start_pos.inc |
| 5 |
|
| 6 |
RESET MASTER; |
| 7 |
|
| 8 |
# Test that we get the correct binlog position from START TRANSACTION WITH |
| 9 |
# CONSISTENT SNAPSHOT even when other transactions are active. |
| 10 |
|
| 11 |
connect(con1,localhost,root,,); |
| 12 |
connect(con2,localhost,root,,); |
| 13 |
connect(con3,localhost,root,,); |
| 14 |
connect(con4,localhost,root,,); |
| 15 |
|
| 16 |
connection default; |
| 17 |
|
| 18 |
CREATE TABLE t1 (a INT, b VARCHAR(100), PRIMARY KEY (a,b)) ENGINE=innodb; |
| 19 |
# MDEV-515 takes X-lock on the table for the first insert. |
| 20 |
# So concurrent insert won't happen on the table |
| 21 |
INSERT INTO t1 VALUES(9, ""); |
| 22 |
let pos=`select $binlog_start_pos + 431`; |
| 23 |
--replace_result $pos <pos> |
| 24 |
SHOW MASTER STATUS; |
| 25 |
--replace_result $pos <pos> |
| 26 |
SHOW STATUS LIKE 'binlog_snapshot_%'; |
| 27 |
BEGIN; |
| 28 |
INSERT INTO t1 VALUES (0, ""); |
| 29 |
|
| 30 |
connection con1; |
| 31 |
BEGIN; |
| 32 |
INSERT INTO t1 VALUES (1, ""); |
| 33 |
|
| 34 |
connection con2; |
| 35 |
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=myisam; |
| 36 |
BEGIN; |
| 37 |
INSERT INTO t1 VALUES (2, "first"); |
| 38 |
INSERT INTO t2 VALUES (2); |
| 39 |
INSERT INTO t1 VALUES (2, "second"); |
| 40 |
|
| 41 |
connection default; |
| 42 |
COMMIT; |
| 43 |
|
| 44 |
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; |
| 45 |
START TRANSACTION WITH CONSISTENT SNAPSHOT; |
| 46 |
|
| 47 |
connection con3; |
| 48 |
BEGIN; |
| 49 |
INSERT INTO t1 VALUES (3, ""); |
| 50 |
INSERT INTO t2 VALUES (3); |
| 51 |
|
| 52 |
connection con4; |
| 53 |
BEGIN; |
| 54 |
INSERT INTO t1 VALUES (4, ""); |
| 55 |
COMMIT; |
| 56 |
|
| 57 |
connection default; |
| 58 |
SELECT * FROM t1 ORDER BY a,b; |
| 59 |
let pos=`select $binlog_start_pos + 974`; |
| 60 |
--replace_result $pos <pos> |
| 61 |
SHOW STATUS LIKE 'binlog_snapshot_%'; |
| 62 |
let pos=`select $binlog_start_pos + 1350`; |
| 63 |
--replace_result $pos <pos> |
| 64 |
SHOW MASTER STATUS; |
| 65 |
SELECT * FROM t2 ORDER BY a; |
| 66 |
|
| 67 |
connection con1; |
| 68 |
COMMIT; |
| 69 |
|
| 70 |
connection con2; |
| 71 |
COMMIT; |
| 72 |
|
| 73 |
connection con3; |
| 74 |
COMMIT; |
| 75 |
FLUSH LOGS; |
| 76 |
--source include/wait_for_binlog_checkpoint.inc |
| 77 |
|
| 78 |
connection default; |
| 79 |
SELECT * FROM t1 ORDER BY a,b; |
| 80 |
let pos=`select $binlog_start_pos + 974`; |
| 81 |
--replace_result $pos <pos> |
| 82 |
SHOW STATUS LIKE 'binlog_snapshot_%'; |
| 83 |
let pos=`select $binlog_start_pos + 131`; |
| 84 |
--replace_result $pos <pos> |
| 85 |
SHOW MASTER STATUS; |
| 86 |
COMMIT; |
| 87 |
--replace_result $pos <pos> |
| 88 |
SHOW STATUS LIKE 'binlog_snapshot_%'; |
| 89 |
--replace_result $pos <pos> |
| 90 |
SHOW MASTER STATUS; |
| 91 |
|
| 92 |
source include/show_binlog_events.inc; |
| 93 |
|
| 94 |
|
| 95 |
--echo *** MDEV-7310: last_commit_pos_offset set to wrong value after binlog rotate in group commit *** |
| 96 |
|
| 97 |
SET @old_size= @@GLOBAL.max_binlog_size; |
| 98 |
SET GLOBAL max_binlog_size=4096; |
| 99 |
|
| 100 |
CREATE TABLE t3 (a INT PRIMARY KEY, b VARBINARY(8192)) ENGINE=MyISAM; |
| 101 |
INSERT INTO t3 VALUES (10, ''); |
| 102 |
--let $bigdata= `SELECT REPEAT('a', 5000)` |
| 103 |
eval INSERT INTO t3 VALUES (11, '$bigdata'); |
| 104 |
|
| 105 |
# The bug was that binlog_snapshot_file pointed to the new file after binlog |
| 106 |
# rotation, but binlog_snapshot_position was the offset in the old file before |
| 107 |
# binlog rotation. So the position was invalid. |
| 108 |
# So here, we check that the values are consistent with SHOW MASTER STATUS, |
| 109 |
# which uses a different code path and did not have the bug. |
| 110 |
|
| 111 |
--source include/wait_for_binlog_checkpoint.inc |
| 112 |
--let $snap_file= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_file', Value, 1) |
| 113 |
--let $snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1) |
| 114 |
|
| 115 |
--let $master_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 116 |
--let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 117 |
|
| 118 |
--disable_query_log |
| 119 |
eval SET @errmsg= 'ERROR: ($snap_file, $snap_pos) != ($master_file, $master_pos)'; |
| 120 |
eval SELECT IF('$snap_file' = '$master_file' AND $snap_pos = $master_pos, 'OK', @errmsg) AS test_result; |
| 121 |
--enable_query_log |
| 122 |
|
| 123 |
SET GLOBAL max_binlog_size=@old_size; |
| 124 |
|
| 125 |
|
| 126 |
DROP TABLE t1,t2, t3; |