| 1 |
################################################################################ |
| 2 |
# BUG#26666609 SLAVE HANGS - WAITING FOR TABLE METADATA LOCK |
| 3 |
# |
| 4 |
# REPAIR/OPTIMIZE/ANALYZE TABLE and |
| 5 |
# ALTER TABLE ... REPAIR/OPTIMIZE/ANALYZE PARTITION |
| 6 |
# Above statements maintain the tables one bye one and the metadata lock |
| 7 |
# of the table is released immediately after it is maintained. That is |
| 8 |
# earlier than the statement is binlogged and committed. That means |
| 9 |
# the following statements which updates the same table may go to the same |
| 10 |
# binlog flush queue with the preceding admin statement together. Normally, |
| 11 |
# the transactions in same flush queue can be applied parallel on slave. |
| 12 |
# But for this case, they should not be applied parallel on slave. |
| 13 |
# |
| 14 |
# For example: |
| 15 |
# REPAIR TABLE t1; |
| 16 |
# INSERT INTO TABLE t1 VALUES(1); |
| 17 |
# |
| 18 |
# They could go into the same flush queue. But there is a mechanism to set |
| 19 |
# INSERT's last_committed as REPAIR's sequence_number. That guarantees INSERT |
| 20 |
# cannot be applied parallel with REPAIR on slave. |
| 21 |
# |
| 22 |
# This test verify INSERT's last_committed is always equal to the sequence_number |
| 23 |
# of above admin statements, but not smaller than it in all possible situations. |
| 24 |
################################################################################ |
| 25 |
--source include/have_debug_sync.inc |
| 26 |
--source include/have_binlog_format_statement.inc |
| 27 |
|
| 28 |
--connect(insert_conn, localhost, root) |
| 29 |
--connect(admin_conn, localhost, root) |
| 30 |
|
| 31 |
RESET MASTER; |
| 32 |
|
| 33 |
CREATE TABLE t1(c1 INT AUTO_INCREMENT PRIMARY KEY, c2 VARCHAR(200)) |
| 34 |
PARTITION BY HASH (c1) PARTITIONS 4; |
| 35 |
|
| 36 |
INSERT INTO t1 VALUES(1, ""), (2, ""), (3, ""),(4, ""); |
| 37 |
|
| 38 |
--echo # |
| 39 |
--echo # Verify INSERT after ANALYZE TABLE logs correct last_committed |
| 40 |
--echo # |
| 41 |
--let $admin_statement= ANALYZE TABLE t1; |
| 42 |
--source extra/binlog_tests/binlog_unsafe_commit_parent.inc |
| 43 |
--let $binlog_file= binlog.000001 |
| 44 |
--let $logical_timestamps= 3 4 |
| 45 |
--source include/assert_logical_timestamps.inc |
| 46 |
|
| 47 |
--echo # |
| 48 |
--echo # Verify INSERT after OPTIMIZE TABLE logs correct last_committed |
| 49 |
--echo # |
| 50 |
--let $admin_statement= OPTIMIZE TABLE t1; |
| 51 |
--source extra/binlog_tests/binlog_unsafe_commit_parent.inc |
| 52 |
--let $logical_timestamps= 5 6 |
| 53 |
--source include/assert_logical_timestamps.inc |
| 54 |
|
| 55 |
--echo # |
| 56 |
--echo # Verify INSERT after REPAIR TABLE logs correct last_committed |
| 57 |
--echo # |
| 58 |
--let $admin_statement= REPAIR TABLE t1; |
| 59 |
--source extra/binlog_tests/binlog_unsafe_commit_parent.inc |
| 60 |
--let $logical_timestamps= 7 8 |
| 61 |
--source include/assert_logical_timestamps.inc |
| 62 |
|
| 63 |
--echo # |
| 64 |
--echo # Verify INSERT after ALTER TABLE ... REPAIR TABLE logs correct |
| 65 |
--echo # last_committed |
| 66 |
--echo # |
| 67 |
--let $admin_statement= ALTER TABLE t1 REPAIR PARTITION p0; |
| 68 |
--source extra/binlog_tests/binlog_unsafe_commit_parent.inc |
| 69 |
--let $logical_timestamps= 9 10 |
| 70 |
--source include/assert_logical_timestamps.inc |
| 71 |
|
| 72 |
--echo # |
| 73 |
--echo # Verify INSERT after ALTER TABLE ... OPTIMIZE TABLE logs correct |
| 74 |
--echo # last_committed |
| 75 |
--echo # |
| 76 |
--let $admin_statement= ALTER TABLE t1 OPTIMIZE PARTITION p1; |
| 77 |
--source extra/binlog_tests/binlog_unsafe_commit_parent.inc |
| 78 |
--let $logical_timestamps= 11 12 |
| 79 |
--source include/assert_logical_timestamps.inc |
| 80 |
|
| 81 |
--echo # |
| 82 |
--echo # Verify INSERT after ALTER TABLE ... ANALYZE TABLE logs correct |
| 83 |
--echo # last_committed |
| 84 |
--echo # |
| 85 |
--let $admin_statement= ALTER TABLE t1 ANALYZE PARTITION p2; |
| 86 |
--source extra/binlog_tests/binlog_unsafe_commit_parent.inc |
| 87 |
--let $logical_timestamps= 13 14 |
| 88 |
--source include/assert_logical_timestamps.inc |
| 89 |
|
| 90 |
--echo # |
| 91 |
--echo # Verify the statements the following statement in different commit |
| 92 |
--echo # window logs correct last_committed |
| 93 |
--echo # |
| 94 |
INSERT INTO t1(c2) VALUES("use max_comitted as last_committed"); |
| 95 |
--let $logical_timestamps= 2 3 |
| 96 |
--source include/assert_logical_timestamps.inc |
| 97 |
|
| 98 |
--echo # |
| 99 |
--echo # Verify binlog rotation doesn't effect the correctness of last_committed |
| 100 |
--echo # |
| 101 |
FLUSH BINARY LOGS; |
| 102 |
--let $admin_statement= REPAIR TABLE t1; |
| 103 |
--source extra/binlog_tests/binlog_unsafe_commit_parent.inc |
| 104 |
--let $binlog_file= binlog.000002 |
| 105 |
--let $logical_timestamps= 0 2 |
| 106 |
--source include/assert_logical_timestamps.inc |
| 107 |
|
| 108 |
REPAIR TABLE t1; |
| 109 |
FLUSH BINARY LOGS; |
| 110 |
INSERT INTO t1(c2) VALUES("use 0 as last_committed"); |
| 111 |
--let $binlog_file= binlog.000003 |
| 112 |
--let $logical_timestamps= 0 1 |
| 113 |
--source include/assert_logical_timestamps.inc |
| 114 |
|
| 115 |
--echo # |
| 116 |
--echo # Verify ALTER TABLE without [OPTIMIZE|REPAIR|ANALYZE] PARTITION and |
| 117 |
--echo # INSERT on different table should be logged in same commit window |
| 118 |
--echo # |
| 119 |
CREATE TABLE t2(c1 INT); |
| 120 |
|
| 121 |
--let $admin_statement= ALTER TABLE t2 ADD COLUMN c2 INT; |
| 122 |
--source extra/binlog_tests/binlog_unsafe_commit_parent.inc |
| 123 |
--let $logical_timestamps= 2 4 |
| 124 |
--source include/assert_logical_timestamps.inc |
| 125 |
|
| 126 |
DROP TABLE t1, t2; |