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 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
|
#
# This is the basic test of support mysql syntax "for channel" used for
# multi-source replication
#
# Test basic replication functionality in multi-source setup
#
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_perfschema.inc
--source include/binlog_start_pos.inc
--let $rpl_server_count= 0
RESET MASTER;
--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
# MDEV-3984: crash/read of freed memory when changing master with named connection
# This fails after adding the new master 'abc1', check we do not free twice.
--error ER_RELAY_LOG_INIT
change master to relay_log_file='' for channel 'abc1';
# This fails before adding the new master, check that we do free it.
--error ER_WRONG_ARGUMENTS
change master to master_host='' for channel 'abc2';
# Start replication from the first master
--replace_result $SERVER_MYPORT_1 MYPORT_1
eval change master to
master_port=$SERVER_MYPORT_1,
master_host='127.0.0.1',
master_user='root', master_ssl_verify_server_cert=0,
master_use_gtid=no
for channel 'master1';
start slave for channel 'master1';
set default_master_connection = 'master1';
--source include/wait_for_slave_to_start.inc
--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
--save_master_pos
--connection slave
--sync_with_master 0,'master1'
# Here and further: add an extra check on SQL thread status
# as the normal sync is not always enough
--source include/wait_for_sql_thread_read_all.inc
# each of the 3 commands should produce
# 'master1' status
let $wait_for_all= 1;
let $show_statement= SHOW ALL SLAVES STATUS;
let $field= Slave_IO_State;
let $condition= = 'Waiting for master to send event';
--source include/wait_show_condition.inc
--echo #
--echo # Checking SHOW SLAVE 'master1' STATUS
--echo #
--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
--let $slave_name= 'master1'
--let for_channel= 1
--source include/show_slave_status.inc
--let $slave_name=
--let for_channel=
--echo #
--echo # Checking SHOW SLAVE STATUS
--echo #
--source include/show_slave_status.inc
--echo #
--echo # Checking SHOW ALL SLAVES STATUS
--echo #
--let $all_slaves_status= 1
--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
--source include/show_slave_status.inc
--let $all_slaves_status=
--echo #
# Check that replication actually works
--connection master1
--disable_warnings
drop database if exists db1;
--enable_warnings
create database db1;
use db1;
create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM;
insert into t1 (f1) values ('one'),('two');
--save_master_pos
--connection slave
--sync_with_master 0,'master1'
--sorted_result
select * from db1.t1;
--let $datadir = `SELECT @@datadir`
--echo # List of relay log files in the datadir
--list_files $datadir mysqld-relay-bin-master1.*
# Check that relay logs are recognizable
let binlog_start=4;
let binlog_file=;
source include/show_relaylog_events.inc;
let binlog_file= mysqld-relay-bin-master1.000002;
source include/show_relaylog_events.inc;
# Try to configure connection with the same name again,
# should get an error because the slave is running
--replace_result $SERVER_MYPORT_2 MYPORT_2
--error ER_SLAVE_MUST_STOP
eval change master to
master_port=$SERVER_MYPORT_2,
master_host='127.0.0.1',
master_user='root'
for channel 'master1';
# Try to configure using the default connection name
# (which is 'master1' at the moment),
# again, should get an error
--replace_result $SERVER_MYPORT_2 MYPORT_2
--error ER_SLAVE_MUST_STOP
eval change master to
master_port=$SERVER_MYPORT_2,
master_host='127.0.0.1',
master_user='root';
# Try to configure a connection with the same master
# using a different name, should get a conflict
--replace_result $SERVER_MYPORT_1 MYPORT_1
--error ER_CONNECTION_ALREADY_EXISTS
eval change master to
master_port=$SERVER_MYPORT_1,
master_host='127.0.0.1',
master_user='root' for channel 'master2';
# Set up a proper 'default' connection to master2
set default_master_connection = '';
--replace_result $SERVER_MYPORT_2 MYPORT_2
eval change master to
master_port=$SERVER_MYPORT_2,
master_host='127.0.0.1',
master_user='root', master_ssl_verify_server_cert=0,
master_use_gtid=no;
start slave;
--source include/wait_for_slave_to_start.inc
--source include/wait_for_sql_thread_read_all.inc
# See both connections in the same status output
let $wait_for_all= 1;
let $show_statement= SHOW ALL SLAVES STATUS;
let $field= Slave_IO_State;
let $condition= = 'Waiting for master to send event';
--source include/wait_show_condition.inc
--echo #
--echo # Checking SHOW ALL SLAVES STATUS
--echo #
--let $all_slaves_status= 1
--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/
--source include/show_slave_status.inc
--let $all_slaves_status=
--echo #
# Check that replication from two servers actually works
--connection master1
insert into t1 (f1) values ('three');
--save_master_pos
--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2)
--disable_warnings
drop database if exists db2;
--enable_warnings
create database db2;
use db2;
create table t1 (pk int auto_increment primary key, f1 int) engine=InnoDB;
begin;
insert into t1 (f1) values (1),(2);
--connection slave
--sync_with_master 0,'master1'
--connection master2
--save_master_pos
--connection slave
--sync_with_master 0
--sorted_result
select * from db1.t1;
select * from db2.t1;
--connection master2
commit;
--save_master_pos
--connection slave
--sync_with_master 0
--sorted_result
select * from db2.t1;
# Flush and purge logs on one master,
# make sure slaves don't get confused
--connection master1
flush logs;
--source include/wait_for_binlog_checkpoint.inc
--save_master_pos
--connection slave
--sync_with_master 0, 'master1'
--connection master1
purge binary logs to 'master-bin.000002';
# Additional events: 43 (Gtid_list) + 2 x 44 (Binlog_checkpoint) = 131
let filesize=`select $binlog_start_pos+131`;
--replace_result $filesize filesize
show binary logs;
insert into t1 (f1) values ('four');
create table db1.t3 (f1 int) engine=InnoDB;
--save_master_pos
--connection slave
--sync_with_master 0,'master1'
--source include/wait_for_sql_thread_read_all.inc
let $wait_for_all= 1;
let $show_statement= SHOW ALL SLAVES STATUS;
let $field= Slave_IO_State;
let $condition= = 'Waiting for master to send event';
--source include/wait_show_condition.inc
--echo #
--echo # Checking SHOW ALL SLAVES STATUS
--echo #
--let $all_slaves_status= 1
--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/
--source include/show_slave_status.inc
--let $all_slaves_status=
--echo #
--echo #
--echo # MDEV:16437: merge 5.7 P_S replication instrumentation and tables
--echo #
--replace_column 2 #
query_vertical SELECT * FROM performance_schema.replication_applier_status_by_coordinator;
--sorted_result
select * from db1.t1;
# This should show relay log events for the default master
# (the one with the empty name)
let binlog_file=;
source include/show_relaylog_events.inc;
let binlog_file= mysqld-relay-bin.000002;
source include/show_relaylog_events.inc;
# Make sure we don't lose control over replication connections
# after reconnecting to the slave
--disconnect slave
--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
stop slave io_thread;
show status like 'Slave_running';
set default_master_connection = 'master1';
show status like 'Slave_running';
--echo
--echo #
--echo # syntax compatible test
--echo #
--echo
--echo #
--echo # show relaylog events
--echo #
--replace_regex /Server ver:.*/Server ver: Version/
SHOW RELAYLOG EVENTS for channel 'master1';
--echo
--echo show slave status for channel 'master1'
--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
--let $slave_name= 'master1'
--let $for_channel= 1
--source include/show_slave_status.inc
--echo
--echo #
--echo # stop slave
--echo #
STOP SLAVE for channel 'master1';
--echo
--echo show slave status for channel 'master1'
--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
--let $slave_name= 'master1'
--let $for_channel= 1
--source include/show_slave_status.inc
--echo
--echo #
--echo # start slave
--echo #
START SLAVE for channel 'master1';
--source include/wait_for_slave_to_start.inc
# Force some data into the relay log to ensure that we get a new relay log
--connection master1
create table foo (a int);
drop table foo;
--save_master_pos
--connection slave
--sync_with_master 0,'master1'
--source include/wait_for_sql_thread_read_all.inc
--echo
--echo show slave status for channel 'master1'
--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /Preparing/Yes/
--let $slave_name= 'master1'
--let $for_channel= 1
--source include/show_slave_status.inc
--echo
--echo #
--echo # flush relay logs
--echo #
FLUSH RELAY LOGS for channel 'master1';
--source include/wait_for_sql_thread_read_all.inc
--echo
--echo show slave status for channel 'master1'
--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
--let $slave_name= 'master1'
--let $for_channel= 1
--source include/show_slave_status.inc
--echo
--echo #
--echo # stop slave
--echo #
STOP SLAVE for channel 'master1';
--echo
--echo show slave status for channel 'master1'
--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
--let $slave_name= 'master1'
--let $for_channel= 1
--source include/show_slave_status.inc
--echo
--echo #
--echo # reset slave
--echo #
RESET SLAVE for channel 'master1';
--echo
--echo show slave status for channel 'master1'
--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
--let $slave_name= 'master1'
--let $for_channel= 1
--source include/show_slave_status.inc
--echo
--echo #
--echo # show relaylog events after reset slave
--echo #
SHOW RELAYLOG EVENTS for channel 'master1';
--let $slave_name=
--let for_channel=
--echo
--echo #
--echo # check error syntax
--echo #
--error ER_WRONG_ARGUMENTS
RESET SLAVE 'master1' for channel 'mmaster2';
--error ER_WRONG_ARGUMENTS
STOP SLAVE 'master1' for channel 'master2';
--error ER_WRONG_ARGUMENTS
FLUSH RELAY LOGS 'master1' for channel 'master2';
--error ER_WRONG_ARGUMENTS
START SLAVE 'master1' for channel 'master2';
--error ER_WRONG_ARGUMENTS
SHOW RELAYLOG 'master1' EVENTS for channel 'master2';
--error ER_WRONG_ARGUMENTS
SHOW SLAVE 'master1' STATUS for channel 'master2';
--echo
# Cleanup
drop database db1;
drop database db2;
--source include/reset_master_slave.inc
--disconnect slave
--connection master1
drop database db1;
--source include/reset_master_slave.inc
--disconnect master1
--connection master2
drop database db2;
--source include/reset_master_slave.inc
--disconnect master2
#
# Check channel as a keyword
#
--connection default
CREATE TABLE channel (channel int);
DROP TABLE channel;
|