1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
|
if (`SELECT $PS_PROTOCOL + $CURSOR_PROTOCOL > 0`)
{
--skip Test temporarily disabled for ps-protocol and cursor-protocol
}
--source include/no_valgrind_without_big.inc
--let $rpl_topology=1->2
--source include/rpl_init.inc
--source include/have_innodb.inc
--echo *** Test normal shutdown/restart of slave server configured as a GTID slave. ***
--connection server_1
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (1);
--save_master_pos
--connection server_2
--sync_with_master
--source include/stop_slave.inc
--let $status_items= Master_Log_File,Using_Gtid
--source include/show_slave_status.inc
# Now try to restart the slave mysqld server without starting the slave first
# threads after the CHANGE MASTER.
# When the slave restarts, it should reconnect using GTID.
# We test that it really uses GTID by purging on the master the
# old binlog the slave would need if connecting with old style
# file name/offset.
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
FLUSH LOGS;
--shutdown_server
--source include/wait_until_disconnected.inc
--connection server_1
FLUSH LOGS;
--let $purge_binlogs_to=master-bin.000002
--source include/wait_for_purge.inc
--source include/show_binary_logs.inc
INSERT INTO t1 VALUES (2);
FLUSH LOGS;
INSERT INTO t1 VALUES (3);
--source include/save_master_gtid.inc
--source include/show_binary_logs.inc
# Let the slave mysqld server start again.
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
restart: --skip-slave-start=0
EOF
--connection server_2
--enable_reconnect
--source include/wait_until_connected_again.inc
--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
--echo *** Test normal shutdown/restart of master server, check binlog state is preserved. ***
--connection server_1
SET SESSION gtid_domain_id= 1;
INSERT INTO t1 VALUES (4);
--replace_column 2 # 4 # 5 #
SHOW BINLOG EVENTS IN 'master-bin.000003' LIMIT 1,1;
FLUSH LOGS;
--replace_column 2 # 4 # 5 # 6 #
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
wait
EOF
--shutdown_server
--source include/wait_until_disconnected.inc
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF
--connection default
--enable_reconnect
--source include/wait_until_connected_again.inc
--connection server_1
--enable_reconnect
--source include/wait_until_connected_again.inc
--replace_column 2 # 4 # 5 # 6 #
SHOW BINLOG EVENTS IN 'master-bin.000005' LIMIT 1,1;
--source include/show_binary_logs.inc
INSERT INTO t1 VALUES(5);
--source include/save_master_gtid.inc
--connection server_2
--source include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
--echo *** Test that @@gtid_slave_pos and @@gtid_current_pos are correctly loaded even if slave threads have not started. ***
--let $slave_pos1= `SELECT @@GLOBAL.gtid_slave_pos`
--let $current_pos1= `SELECT @@GLOBAL.gtid_current_pos`
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--shutdown_server
--source include/wait_until_disconnected.inc
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
restart: --skip-slave-start=1 --skip-log-bin
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_query_log
eval SET @slave_pos1= "$slave_pos1";
eval SET @current_pos1= "$current_pos1";
--enable_query_log
SET @slave_pos2= @@GLOBAL.gtid_slave_pos;
SET @current_pos2= @@GLOBAL.gtid_current_pos;
SELECT IF(@slave_pos1=@slave_pos2, "OK", CONCAT(@slave_pos1, " != ", @slave_pos2));
SELECT IF(@current_pos1=@current_pos2, "OK", CONCAT(@current_pos1, " != ", @current_pos2));
--connection server_1
INSERT INTO t1 VALUES (6);
--save_master_pos
--connection server_2
--source include/start_slave.inc
--sync_with_master
SELECT * FROM t1 ORDER BY a;
--echo *** MDEV-4490: Old-style master position points at the last GTID event after slave restart ***
--connection server_1
INSERT INTO t1 VALUES (7);
--save_master_pos
--connection server_2
--sync_with_master
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
# Now we restart the slave server. When it restarts, there is nothing new
# to replicate. Check that the position is nevertheless updated and
# MASTER_POS_WAIT() works correctly and detects that we are up-to-date.
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--shutdown_server
--source include/wait_until_disconnected.inc
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
restart: --skip-slave-start=0
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
--source include/wait_for_slave_to_start.inc
--connection server_1
--save_master_pos
--connection server_2
--sync_with_master
SELECT * FROM t1 ORDER BY a;
--echo *** MDEV-4486: Allow to start old-style replication even if mysql.gtid_slave_pos is unavailable
# In GTID mode, the old-style replication position is also updated. But during
# GTID connect, the old-style position is not known until receiving the fake
# GTID list event, which contains the required position value. If we happened
# to stop the slave above before this fake GTID list event, the test could fail
# with duplicate key errors due to switching to non-GTID mode at a wrong
# position too far back in the binlog.
#
# Work-around this by injecting an extra dummt event and syncing the slave to
# it, ensuring the old-style position will be updated.
#
# This work-around could be removed after MDEV-33996 is fixed.
--connection server_1
INSERT INTO t1 VALUES (8);
DELETE FROM t1 WHERE a=8;
--save_master_pos
--connection server_2
--sync_with_master
--connection server_2
--source include/stop_slave.inc
CHANGE MASTER TO master_use_gtid= no;
--source include/start_slave.inc
--connection server_1
INSERT INTO t1 VALUES (8);
--save_master_pos
--connection server_2
--sync_with_master
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
--source include/stop_slave.inc
SET sql_log_bin= 0;
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
SET sql_log_bin= 1;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--shutdown_server
--source include/wait_until_disconnected.inc
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
restart: --skip-slave-start=1 --skip-innodb
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
--error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM mysql.gtid_slave_pos;
SET sql_log_bin=0;
call mtr.add_suppression("Failed to load slave replication state from table");
call mtr.add_suppression("Unable to load replication GTID slave state");
SET sql_log_bin=1;
--let rpl_allow_error= 1
--source include/start_slave.inc
--connection server_1
INSERT INTO t1 VALUES (9);
--save_master_pos
--connection server_2
--sync_with_master
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
# Put things back as they were.
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--shutdown_server
--source include/wait_until_disconnected.inc
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
restart:
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
SET sql_log_bin= 0;
ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria;
SET sql_log_bin= 1;
# Do a second restart to get the mysql.gtid_slave_pos table loaded with
# the right engine.
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--shutdown_server
--source include/wait_until_disconnected.inc
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
restart:
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
--source include/start_slave.inc
--connection server_1
INSERT INTO t1 VALUES (10);
--save_master_pos
--connection server_2
--sync_with_master
--source include/stop_slave.inc
CHANGE MASTER TO master_use_gtid= slave_pos;
--source include/start_slave.inc
--echo *** MDEV-4692: mysql.gtid_slave_pos accumulates values for a domain ***
SELECT domain_id, COUNT(*) FROM mysql.gtid_slave_pos GROUP BY domain_id;
--connection server_1
INSERT INTO t1 VALUES (11);
--save_master_pos
--connection server_2
--sync_with_master
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT domain_id, COUNT(*) FROM mysql.gtid_slave_pos GROUP BY domain_id;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--shutdown_server
--source include/wait_until_disconnected.inc
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
restart:
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
--source include/start_slave.inc
--connection server_1
INSERT INTO t1 VALUES (12);
INSERT INTO t1 VALUES (13);
--save_master_pos
--connection server_2
--sync_with_master
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT domain_id, COUNT(*) FROM mysql.gtid_slave_pos GROUP BY domain_id;
--echo *** MDEV-4650: show variables; ERROR 1946 (HY000): Failed to load replication slave GTID position ***
--connection server_2
SET sql_log_bin=0;
--let $old_pos= `SELECT @@GLOBAL.gtid_slave_pos`
RENAME TABLE mysql.gtid_slave_pos TO mysql.old_gtid_slave_pos;
SET sql_log_bin=1;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--shutdown_server
--source include/wait_until_disconnected.inc
# Let the slave mysqld server start again.
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
restart
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_result_log
SHOW VARIABLES;
--enable_result_log
SHOW VARIABLES LIKE 'gtid_slave_pos';
--error ER_CANNOT_LOAD_SLAVE_GTID_STATE,ER_NO_SUCH_TABLE
SET GLOBAL gtid_slave_pos = '0-1-2';
SHOW WARNINGS;
# Restore things.
SET sql_log_bin=0;
RENAME TABLE mysql.old_gtid_slave_pos TO mysql.gtid_slave_pos;
CALL mtr.add_suppression("Failed to load slave replication state from table mysql.gtid_slave_pos");
SET sql_log_bin=1;
SHOW VARIABLES LIKE 'gtid_slave_pos';
SET GLOBAL gtid_slave_pos = '0-1-2';
SHOW VARIABLES LIKE 'gtid_slave_pos';
# Don't let .result file depend on old state of gtid_slave_pos
--disable_query_log
--disable_result_log
eval SET GLOBAL gtid_slave_pos = '$old_pos';
--enable_query_log
--enable_result_log
--source include/start_slave.inc
--connection server_1
DROP TABLE t1;
--source include/rpl_end.inc
|