| 1 |
# |
| 2 |
# ==== Purpose ==== |
| 3 |
# |
| 4 |
# WL#6559 Optimize GTIDs for passive slave - store GTIDs in table |
| 5 |
# |
| 6 |
# Verify that we can store gtids into gtid_executed table for transactions |
| 7 |
# on binlog rotation and report GLOBAL.GTID_EXECUTED and GLOBAL.GTID_PURGED |
| 8 |
# correctly on master and slave when binlog is enabled. |
| 9 |
# |
| 10 |
|
| 11 |
--source include/force_myisam_default.inc |
| 12 |
--source include/have_myisam.inc |
| 13 |
--source include/not_group_replication_plugin.inc |
| 14 |
--source include/have_debug.inc |
| 15 |
--source include/have_debug_sync.inc |
| 16 |
--source include/master-slave.inc |
| 17 |
|
| 18 |
SET @debug_save= @@GLOBAL.DEBUG; |
| 19 |
call mtr.add_suppression("test the suppression statement"); |
| 20 |
--let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID` |
| 21 |
SHOW CREATE TABLE mysql.gtid_executed; |
| 22 |
|
| 23 |
--echo # |
| 24 |
--echo # Verify that the specified gtid to GTID_NEXT can be reported from |
| 25 |
--echo # global.gtid_executed and is stored into gtid_executed table on |
| 26 |
--echo # following binlog rotation. |
| 27 |
--echo # |
| 28 |
--replace_result $master_uuid MASTER_UUID |
| 29 |
--eval SET GTID_NEXT='$master_uuid:3' |
| 30 |
BEGIN; |
| 31 |
COMMIT; |
| 32 |
--let $assert_text= committed gtids MASTER_UUID:1:3 |
| 33 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1:3" |
| 34 |
--source include/assert.inc |
| 35 |
--eval SET GTID_NEXT='AUTOMATIC' |
| 36 |
FLUSH LOGS; |
| 37 |
--echo # |
| 38 |
--echo # Store gtids MASTER_UUID:1:3 in gtid_executed table on binlog rotation |
| 39 |
--echo # |
| 40 |
--replace_result $master_uuid MASTER_UUID |
| 41 |
SELECT * FROM mysql.gtid_executed; |
| 42 |
|
| 43 |
--echo # |
| 44 |
--echo # Verify that these gtids can be reported from global.gtid_executed and |
| 45 |
--echo # are stored into gtid_executed table on next rotation for normal DDLs. |
| 46 |
--echo # |
| 47 |
CREATE TABLE IF NOT EXISTS t1 (a INT) ENGINE=InnoDB; |
| 48 |
CREATE TABLE t2 (a INT) ENGINE=MyISAM; |
| 49 |
--let $assert_text= committed gtids MASTER_UUID:1-4 |
| 50 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-4" |
| 51 |
--source include/assert.inc |
| 52 |
--echo # |
| 53 |
--echo # Store gtids MASTER_UUID:1-4 in gtid_executed table on binlog rotation |
| 54 |
--echo # |
| 55 |
SET @@GLOBAL.DEBUG= '+d,compress_gtid_table'; |
| 56 |
FLUSH LOGS; |
| 57 |
SET DEBUG_SYNC='now WAIT_FOR complete_compression'; |
| 58 |
--replace_result $master_uuid MASTER_UUID |
| 59 |
SELECT * FROM mysql.gtid_executed; |
| 60 |
|
| 61 |
--echo # |
| 62 |
--echo # Verify that these gtids can be reported from global.gtid_executed |
| 63 |
--echo # and are stored into gtid_executed table for compound statement with |
| 64 |
--echo # regular and temporary tables. |
| 65 |
--echo # |
| 66 |
CREATE TEMPORARY TABLE tmp1 (c1 INT) Engine=MyISAM; |
| 67 |
CREATE TABLE t3 (a INT); |
| 68 |
if (`SELECT @@BINLOG_FORMAT = 'ROW' || @@BINLOG_FORMAT = 'MIXED'`) |
| 69 |
{ |
| 70 |
# We did not generate gtid for above 'CREATE TEMPORARY TABLE' statement |
| 71 |
# in row or mixed format, but we did in statement format. So let the 'INSERT' |
| 72 |
# statement generate the missed gtid in row format. |
| 73 |
--disable_query_log |
| 74 |
INSERT INTO t3 VALUES(1); |
| 75 |
--enable_query_log |
| 76 |
} |
| 77 |
# The below statement is no-op as t3 is non-temporary. |
| 78 |
--error ER_BAD_TABLE_ERROR |
| 79 |
DROP TEMPORARY TABLE tmp1, t3; |
| 80 |
DROP TEMPORARY TABLE tmp1; |
| 81 |
if (`SELECT @@BINLOG_FORMAT = 'ROW' || @@BINLOG_FORMAT = 'MIXED'`) |
| 82 |
{ |
| 83 |
# Likewise for the DROP TEMPORARY TABLE above |
| 84 |
--disable_query_log |
| 85 |
INSERT INTO t3 VALUES(1); |
| 86 |
--enable_query_log |
| 87 |
} |
| 88 |
DROP TABLE t3; |
| 89 |
--let $assert_text= committed gtids MASTER_UUID:1-8 |
| 90 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-8" |
| 91 |
--source include/assert.inc |
| 92 |
--echo # |
| 93 |
--echo # Store gtids MASTER_UUID:1-8 in gtid_executed table on binlog rotation |
| 94 |
--echo # |
| 95 |
SET @@GLOBAL.DEBUG= '+d,compress_gtid_table'; |
| 96 |
FLUSH LOGS; |
| 97 |
SET DEBUG_SYNC='now WAIT_FOR complete_compression'; |
| 98 |
--replace_result $master_uuid MASTER_UUID |
| 99 |
SELECT * FROM mysql.gtid_executed; |
| 100 |
|
| 101 |
--echo # |
| 102 |
--echo # Verify that transactions' gtids can be reported from |
| 103 |
--echo # global.gtid_executed correctly and are stored into |
| 104 |
--echo # gtid_executed table on next binlog rotation. |
| 105 |
--echo # |
| 106 |
BEGIN; |
| 107 |
INSERT INTO t2 VALUES(2); |
| 108 |
INSERT INTO t1 VALUES(1); |
| 109 |
INSERT INTO t1 VALUES(2); |
| 110 |
COMMIT; |
| 111 |
--echo # |
| 112 |
--echo # Verify that specified gtid for transaction can be reported from |
| 113 |
--echo # global.gtid_executed correctly and is stored into gtid_executed |
| 114 |
--echo # table on next binlog rotation. |
| 115 |
--echo # |
| 116 |
--replace_result $master_uuid MASTER_UUID |
| 117 |
--eval SET @@SESSION.GTID_NEXT= '$master_uuid:11' |
| 118 |
BEGIN; |
| 119 |
INSERT INTO t1 VALUES(3); |
| 120 |
COMMIT; |
| 121 |
--let $assert_text= committed gtids MASTER_UUID:1-11 |
| 122 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-11" |
| 123 |
--source include/assert.inc |
| 124 |
--eval SET GTID_NEXT='AUTOMATIC' |
| 125 |
SET @@GLOBAL.DEBUG= '+d,compress_gtid_table'; |
| 126 |
FLUSH LOGS; |
| 127 |
SET DEBUG_SYNC='now WAIT_FOR complete_compression'; |
| 128 |
--echo # |
| 129 |
--echo # Store gtids MASTER_UUID:1-11 in gtid_executed table on binlog rotation |
| 130 |
--echo # |
| 131 |
--replace_result $master_uuid MASTER_UUID |
| 132 |
SELECT * FROM mysql.gtid_executed; |
| 133 |
|
| 134 |
--echo # |
| 135 |
--echo # Verify that transaction's gtid can not be reported from |
| 136 |
--echo # global.gtid_executed and is not stored into gtid_executed table |
| 137 |
--echo # on next binlog rotation if the transaction is rollbacked. |
| 138 |
--echo # |
| 139 |
BEGIN; |
| 140 |
INSERT INTO t1 VALUES(4); |
| 141 |
ROLLBACK; |
| 142 |
--let $assert_text= committed gtids MASTER_UUID:1-11 |
| 143 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-11" |
| 144 |
--source include/assert.inc |
| 145 |
--echo # |
| 146 |
--echo # Store gtids MASTER_UUID:1-11 in gtid_executed table on binlog rotation |
| 147 |
--echo # |
| 148 |
FLUSH LOGS; |
| 149 |
--replace_result $master_uuid MASTER_UUID |
| 150 |
SELECT * FROM mysql.gtid_executed; |
| 151 |
SET GLOBAL DEBUG= @debug_save; |
| 152 |
|
| 153 |
|
| 154 |
--source include/sync_slave_sql_with_master.inc |
| 155 |
--echo # |
| 156 |
--echo # connection slave |
| 157 |
--echo # |
| 158 |
--let $replica_uuid= `SELECT @@GLOBAL.SERVER_UUID` |
| 159 |
|
| 160 |
--echo # |
| 161 |
--echo # Verify that the transaction is skiped if its specified gtid is |
| 162 |
--echo # already in global.gtid_executed, although not in gtid_executed table. |
| 163 |
--echo # |
| 164 |
--replace_result $master_uuid MASTER_UUID |
| 165 |
--eval SET @@SESSION.GTID_NEXT= '$master_uuid:6' |
| 166 |
INSERT INTO t1 VALUES(11); |
| 167 |
--let $assert_text= Table t1 must not contain 11 |
| 168 |
--let $assert_cond= "[SELECT a FROM t1 WHERE a=11]" = "" |
| 169 |
--source include/assert.inc |
| 170 |
--let $assert_text= committed gtids MASTER_UUID:1-11 |
| 171 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-11" |
| 172 |
--source include/assert.inc |
| 173 |
--echo # |
| 174 |
--echo # The gtid_executed table would only have GTID for Innodb transactions |
| 175 |
--echo # |
| 176 |
#--replace_result $master_uuid MASTER_UUID |
| 177 |
#SELECT * FROM mysql.gtid_executed; |
| 178 |
--echo # |
| 179 |
--echo # Store gtids MASTER_UUID:1-11 in gtid_executed table on binlog rotation |
| 180 |
--echo # |
| 181 |
--eval SET GTID_NEXT='AUTOMATIC' |
| 182 |
FLUSH LOGS; |
| 183 |
--replace_result $master_uuid MASTER_UUID |
| 184 |
SELECT * FROM mysql.gtid_executed; |
| 185 |
|
| 186 |
--echo # |
| 187 |
--echo # Verify that the specified gtid to GTID_NEXT is stored into |
| 188 |
--echo # global.gtid_executed immediately and stored into gtid_executed table |
| 189 |
--echo # on next binlog rotation. |
| 190 |
--echo # |
| 191 |
--replace_result $master_uuid MASTER_UUID |
| 192 |
--eval SET @@SESSION.GTID_NEXT= '$master_uuid:17' |
| 193 |
COMMIT; |
| 194 |
--let $assert_text= committed gtids MASTER_UUID:1-11:17 |
| 195 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-11:17" |
| 196 |
--source include/assert.inc |
| 197 |
--echo # |
| 198 |
--echo # Store gtids MASTER_UUID:1-11:17 in gtid_executed table |
| 199 |
--echo # on next binlog rotation. |
| 200 |
--echo # |
| 201 |
--eval SET GTID_NEXT='AUTOMATIC' |
| 202 |
FLUSH LOGS; |
| 203 |
--replace_result $master_uuid MASTER_UUID |
| 204 |
SELECT * FROM mysql.gtid_executed; |
| 205 |
|
| 206 |
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 207 |
--echo # |
| 208 |
--echo # Verify that we can get the correct set of gtid_purged |
| 209 |
--echo # when purging logs. |
| 210 |
--echo # |
| 211 |
--eval PURGE BINARY LOGS TO '$binlog_file' |
| 212 |
--let $assert_text= purged gtids MASTER_UUID:1-11:17 |
| 213 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_PURGED]" = "$master_uuid:1-11:17" |
| 214 |
--source include/assert.inc |
| 215 |
|
| 216 |
--echo # |
| 217 |
--echo # Verify that transaction's gtid generated on slave is stored |
| 218 |
--echo # into gtid_executed table on next binlog rotation. |
| 219 |
--echo # |
| 220 |
BEGIN; |
| 221 |
INSERT INTO t1 VALUES(12); |
| 222 |
COMMIT; |
| 223 |
--echo # |
| 224 |
--echo # Store gtids MASTER_UUID:1-11:17 and SLAVE_UUID:1 |
| 225 |
--echo # in gtid_executed table on binlog rotation. |
| 226 |
--echo # |
| 227 |
FLUSH LOGS; |
| 228 |
--replace_result $master_uuid MASTER_UUID |
| 229 |
--eval SELECT * FROM mysql.gtid_executed where source_uuid="$master_uuid" |
| 230 |
--replace_result $replica_uuid SLAVE_UUID |
| 231 |
--eval SELECT * FROM mysql.gtid_executed where source_uuid="$replica_uuid" |
| 232 |
|
| 233 |
--connection master |
| 234 |
DROP TABLE t1, t2; |
| 235 |
|
| 236 |
--source include/rpl_end.inc |