diff options
Diffstat (limited to 'mysql-test/suite/rpl')
6 files changed, 2089 insertions, 0 deletions
diff --git a/mysql-test/suite/rpl/include/mysqlbinlog_slave_consistency.inc b/mysql-test/suite/rpl/include/mysqlbinlog_slave_consistency.inc new file mode 100644 index 00000000000..48e4399d162 --- /dev/null +++ b/mysql-test/suite/rpl/include/mysqlbinlog_slave_consistency.inc @@ -0,0 +1,194 @@ +# This file provides the structure to run a single test that ensures the +# mariadb-binlog command line tool is consistent with replicas for event +# filtering. The test is configured using the following input parameters, where +# each is nullable (i.e. it will not be used to configure mariadb-binlog or +# the replica). +# +# param $do_domain_ids : A list of domain ids to include in replication +# param $ignore_domain_ids : A list of domain ids to exclude from replication +# param $ignore_server_ids : A list of server ids to exclude from replication +# param $start_position : The GTID positions to begin replication from in +# the specified domains +# param $stop_position : The GTID positions that mark the end of an event +# stream in a particular domain +# +# param $con1 : The connection name of the primary server +# param $con2 : The connection name of the replica server +# param $strict_mode : Uses input and checks for out of order GTIDs +# param $strict_mode_err : A boolean that provides expectations for strict +# mode to error +# param $slave_sql_errno : Expected error number of the slave SQL thread + + +--let $include_filename= mysqlbinlog_slave_consistency.inc +--source include/begin_include_file.inc + +--enable_query_log + +if (!$con1) +{ + --let $con1=master +} +if (!$con2) +{ + --let $con2=slave +} + +if (!$strict_mode) +{ + --connection $con2 + set @@global.gtid_strict_mode=0; + --let $sql_input_file=include/sql_multisource.inc +} + +if ($strict_mode) +{ + --connection $con2 + set @@global.gtid_strict_mode=1; + --let $sql_input_file=include/sql_out_of_order_gtid.inc +} + +--connection $con2 +--source include/stop_slave.inc + +--connection $con1 +--echo # Populating $con1 data +--source $sql_input_file +--source include/save_master_gtid.inc + +--let $MYSQLD_DATADIR=`select @@datadir` +--let $MYSQLBINLOG_STDERR=$MYSQLD_DATADIR/mysqlbinlog_stderr.out +--let BINLOG_FILENAME= query_get_value(SHOW BINARY LOGS, Log_name, 1) +--let BINLOG_FILE_PARAM= $MYSQLD_DATADIR/$BINLOG_FILENAME.orig +--copy_file $MYSQLD_DATADIR/$BINLOG_FILENAME $BINLOG_FILE_PARAM + +--connection $con2 +--let $msbl_args= +if (`SELECT strcmp("$start_position","") != 0`) +{ + eval set global gtid_slave_pos="$start_position"; + --let $msbl_args= $msbl_args --start-position=$start_position +} + +--let $cm_args= MASTER_USE_GTID=slave_pos +if (`SELECT strcmp("$do_domain_ids","") != 0`) +{ + --let $cm_args= $cm_args, DO_DOMAIN_IDS=($do_domain_ids) + --let $msbl_args= $msbl_args --do-domain-ids=$do_domain_ids +} +if (`SELECT strcmp("$ignore_domain_ids","") != 0`) +{ + --let $cm_args= $cm_args, IGNORE_DOMAIN_IDS=($ignore_domain_ids) + --let $msbl_args= $msbl_args --ignore-domain-ids=$ignore_domain_ids +} +if (`SELECT strcmp("$ignore_server_ids","") != 0`) +{ + --let $cm_args= $cm_args, IGNORE_SERVER_IDS=($ignore_server_ids) + --let $msbl_args= $msbl_args --ignore-server-ids=$ignore_server_ids +} +if ($strict_mode) +{ + --let $msbl_args= $msbl_args --gtid-strict-mode +} +eval CHANGE MASTER TO $cm_args; + +--let $start_slave_args= +if (`SELECT strcmp("$stop_position","") != 0`) +{ + --let $start_slave_args= UNTIL master_gtid_pos="$stop_position" + --let $msbl_args= $msbl_args --stop-position=$stop_position +} + +eval START SLAVE $start_slave_args; + +if ($slave_sql_errno) +{ + --echo # $con2 SQL Thread error expected - waiting for errno $slave_sql_errno + --source include/wait_for_slave_sql_error.inc +} + +# If we are not expecting an error, wait for con2 to catch up +if (!$slave_sql_errno) +{ + --echo # No $con2 error expecting - waiting for $con2 to catch up to $con1 + + # Stop position was not specified + if (`SELECT strcmp("$stop_position","") = 0`) + { + --source include/sync_with_master_gtid.inc + } + + # Stop position was specified + if (`SELECT strcmp("$stop_position","") != 0`) + { + --echo # Because there is a stop position we wait for all events to process + --echo # and $con2 to automatically stop + --source include/wait_for_slave_to_stop.inc + } +} + +--echo # Stop $con2 so it stops receiving $con1 events. +--source include/stop_slave.inc + +--connection $con1 +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM $msbl_args 2> MYSQLBINLOG_STDERR | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM $msbl_args 2> $MYSQLBINLOG_STDERR | $MYSQL + +--source include/rpl_check_table_consistency.inc + +if ($strict_mode) +{ + --echo # Strict mode enabled - checking mysqlbinlog error output for out + --echo # of order GTIDs + --let SEARCH_FILE=$MYSQLBINLOG_STDERR + --let SEARCH_PATTERN=Found out of order GTID + if ($strict_mode_err) + { + --echo # Expecting to find out of order GTID error.. + } + if (!$strict_mode_err) + { + --echo # Not expecting to find out of order GTID error.. + } + --source include/search_pattern_in_file.inc +} + +--echo # Test finished - resetting $con1 and $con2.. +--connection $con2 +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); + +--connection $con1 +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +--source include/save_master_gtid.inc + +--connection $con2 +--source include/start_slave.inc +--source include/wait_for_slave_to_start.inc +--source include/sync_with_master_gtid.inc +--source include/stop_slave.inc +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; + +--connection $con1 +RESET MASTER; + +--connection $con2 +if ($strict_mode) +{ + set @@global.gtid_strict_mode=0; +} +--source include/start_slave.inc + +--connection $con1 +--remove_file $BINLOG_FILE_PARAM +--remove_file $MYSQLBINLOG_STDERR + +--let $include_filename= mysqlbinlog_slave_consistency.inc +--source include/end_include_file.inc diff --git a/mysql-test/suite/rpl/include/rpl_check_table_consistency.inc b/mysql-test/suite/rpl/include/rpl_check_table_consistency.inc new file mode 100644 index 00000000000..957a5d525a7 --- /dev/null +++ b/mysql-test/suite/rpl/include/rpl_check_table_consistency.inc @@ -0,0 +1,63 @@ +# This file provides logic to ensure that all tables in a database are the +# same between two connections. +# +# param $check_db : The name of the database to validate all tables are the +# same within (test by default) +# param $con1 : The connection name of the primary server, defaults to +# master +# param $con2 : The connection name of the replica server, defaults to +# slave + +--let $include_filename= rpl_check_table_consistency.inc +--source include/begin_include_file.inc + +if (!$con1) +{ + --let $con1= master +} +if (!$con2) +{ + --let $con2= slave +} +if (!$check_db) +{ + --let $check_db= test +} + +--connection $con2 +--let $n_tables= `select count(*) from information_schema.tables WHERE table_schema = '$check_db'` + +--echo # Checking consistency of '$check_db' database tables between $con1 and $con2 + +--connection $con1 +--let $c1_n_tables= `select count(*) from information_schema.tables WHERE table_schema = '$check_db'` +if (`SELECT $c1_n_tables != $n_tables`) +{ + die "$con1 had $c1_n_tables tables but $con2 had $n_tables after binlog replay"; +} +--echo # Both servers have $n_tables tables + +--let $ctr= 1 +--echo # Verifying integrity of tables.. +while($ctr <= $n_tables) +{ + --let $cksum_tbl= query_get_value(SELECT table_name FROM information_schema.tables WHERE table_schema = 'test' ORDER BY table_name ASC, table_name, $ctr) + --connection $con1 + --let $c1_cksum= `CHECKSUM TABLE $cksum_tbl` + --connection $con2 + --let $c2_cksum= `CHECKSUM TABLE $cksum_tbl` + + if ($c1_cksum != $c2_cksum) + { + die "Table $cksum_tbl differs between connections $con1 and $con2"; + } + if ($c1_cksum == $c2_cksum) + { + --echo # $cksum_tbl is equivalent on $con1 and $con2 + } + --let $ctr= `SELECT $ctr+1` +} +--echo # All tables are consistent + +--let $include_filename= rpl_check_table_consistency.inc +--source include/end_include_file.inc diff --git a/mysql-test/suite/rpl/include/sql_multisource.inc b/mysql-test/suite/rpl/include/sql_multisource.inc new file mode 100644 index 00000000000..761b68421d9 --- /dev/null +++ b/mysql-test/suite/rpl/include/sql_multisource.inc @@ -0,0 +1,45 @@ +# Populate the active connection server with events that come from varying +# domain and server ids + +--disable_query_log + +# Save old state +let $ORIG_GTID_DOMAIN_ID = `select @@session.gtid_domain_id`; +let $ORIG_SERVER_ID = `select @@session.server_id`; + +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); + +SET @@session.server_id= 3; +CREATE TABLE t2 (a int); +INSERT INTO t2 values (3); + +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 1; +CREATE TABLE t3 (a int); +INSERT INTO t3 values (4); + +SET @@session.server_id= 4; +CREATE TABLE t4 (a int); +INSERT INTO t4 values (5); + +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +INSERT INTO t1 values (1); + +SET @@session.gtid_domain_id= 2; +SET @@session.server_id= 1; +CREATE TABLE t5 (a int); +INSERT INTO t5 values (6); + +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +INSERT INTO t1 values (2); + +FLUSH LOGS; + +--eval SET @@session.gtid_domain_id= $ORIG_GTID_DOMAIN_ID +--eval SET @@session.server_id= $ORIG_SERVER_ID + +--enable_query_log diff --git a/mysql-test/suite/rpl/include/sql_out_of_order_gtid.inc b/mysql-test/suite/rpl/include/sql_out_of_order_gtid.inc new file mode 100644 index 00000000000..82291a887e9 --- /dev/null +++ b/mysql-test/suite/rpl/include/sql_out_of_order_gtid.inc @@ -0,0 +1,43 @@ +# SQL file with out of order GTIDs coming from various domains and servers + +--disable_query_log + +# Save old state +let $ORIG_GTID_DOMAIN_ID = `select @@session.gtid_domain_id`; +let $ORIG_SERVER_ID = `select @@session.server_id`; + +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); + +SET @@session.server_id= 3; +CREATE TABLE t2 (a int); +SET @@session.gtid_seq_no= 6; +INSERT INTO t2 values (2); +SET @@session.gtid_seq_no= 5; +INSERT INTO t2 values (1); +SET @@session.gtid_seq_no= 7; +INSERT INTO t2 values (3); + +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 1; +CREATE TABLE t3 (a int); +INSERT INTO t3 values (1); +SET @@session.gtid_seq_no= 4; +INSERT INTO t3 values (3); +SET @@session.gtid_seq_no= 3; +INSERT INTO t3 values (2); +SET @@session.gtid_seq_no= 5; +INSERT INTO t3 values (4); + +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +INSERT INTO t1 values (2); + +FLUSH LOGS; + +--eval SET @@session.gtid_domain_id= $ORIG_GTID_DOMAIN_ID +--eval SET @@session.server_id= $ORIG_SERVER_ID + +--enable_query_log diff --git a/mysql-test/suite/rpl/r/rpl_mysqlbinlog_slave_consistency.result b/mysql-test/suite/rpl/r/rpl_mysqlbinlog_slave_consistency.result new file mode 100644 index 00000000000..e69fb2fc62d --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_mysqlbinlog_slave_consistency.result @@ -0,0 +1,1343 @@ +include/master-slave.inc +[connection master] +connection slave; +SET sql_log_bin=0; +call mtr.add_suppression("Slave: An attempt was made.*"); +call mtr.add_suppression("Both DO_DOMAIN_IDS & IGNORE_DOMAIN_IDS lists can't be non-empty at the same time"); +SET sql_log_bin=1; +include/stop_slave.inc +connection master; +RESET MASTER; +connection slave; +include/start_slave.inc +# +# +# Test Case 1: Base case to ensure that mariadb-binlog and replica +# are consistent without any filtering +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos; +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 5 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t1 is equivalent on master and slave +connection master; +connection slave; +# t2 is equivalent on master and slave +connection master; +connection slave; +# t3 is equivalent on master and slave +connection master; +connection slave; +# t4 is equivalent on master and slave +connection master; +connection slave; +# t5 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 2: Ensure filtering by a single id in --do-domain-ids is +# consistent between mariadb-binlog and replica +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(0); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --do-domain-ids=0 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 2 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t1 is equivalent on master and slave +connection master; +connection slave; +# t2 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 3: Ensure filtering by multiple ids in --do-domain-ids is +# consistent between mariadb-binlog and replica +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(0,1); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --do-domain-ids=0,1 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 4 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t1 is equivalent on master and slave +connection master; +connection slave; +# t2 is equivalent on master and slave +connection master; +connection slave; +# t3 is equivalent on master and slave +connection master; +connection slave; +# t4 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# Test Case 4: Ensure filtering by a single id in --ignore-domain-ids +# is consistent between mariadb-binlog and replica +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_DOMAIN_IDS=(0); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --ignore-domain-ids=0 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 3 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t3 is equivalent on master and slave +connection master; +connection slave; +# t4 is equivalent on master and slave +connection master; +connection slave; +# t5 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t2' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 5: Ensure filtering by multiple ids in --ignore-domain-ids +# is consistent between mariadb-binlog and replica +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_DOMAIN_IDS=(0,1); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --ignore-domain-ids=0,1 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t5 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t2,test.t3,test.t4' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# Test Case 6: Ensure filtering by a single id in --ignore-server-ids +# is consistent between mariadb-binlog and replica +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_SERVER_IDS=(1); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --ignore-server-ids=1 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 2 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t2 is equivalent on master and slave +connection master; +connection slave; +# t4 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t3,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 7: Ensure filtering by multiple ids in --ignore-server-ids +# is consistent between mariadb-binlog and replica +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_SERVER_IDS=(0,1); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --ignore-server-ids=0,1 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 2 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t2 is equivalent on master and slave +connection master; +connection slave; +# t4 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t3,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 8: Ensure stop position consistency +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos; +START SLAVE UNTIL master_gtid_pos="1-1-2"; +# No slave error expecting - waiting for slave to catch up to master +# Because there is a stop position we wait for all events to process +# and slave to automatically stop +# Stop slave so it stops receiving master events. +Warnings: +Note 1255 Slave already has been stopped +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-1-2 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t3 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t2,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 9: Ensure start position consistency +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +set global gtid_slave_pos="1-4-2"; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos; +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-4-2 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 4 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t1 is equivalent on master and slave +connection master; +connection slave; +# t2 is equivalent on master and slave +connection master; +connection slave; +# t4 is equivalent on master and slave +connection master; +connection slave; +# t5 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t3' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 10: Ensure consistency when filtering by both +# --do-domain-ids and --ignore-server-ids +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(0), IGNORE_SERVER_IDS=(1); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --do-domain-ids=0 --ignore-server-ids=1 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t2 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 11: Ensure consistency when filtering by both +# --ignore-domain-ids and --ignore-server-ids +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_DOMAIN_IDS=(1,2), IGNORE_SERVER_IDS=(1); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --ignore-domain-ids=1,2 --ignore-server-ids=1 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t2 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 12: Ensure consistency when filtering by +# --do-domain-ids with a stop position +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(0); +START SLAVE UNTIL master_gtid_pos="0-1-4"; +# No slave error expecting - waiting for slave to catch up to master +# Because there is a stop position we wait for all events to process +# and slave to automatically stop +# Stop slave so it stops receiving master events. +Warnings: +Note 1255 Slave already has been stopped +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --do-domain-ids=0 --stop-position=0-1-4 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 2 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t1 is equivalent on master and slave +connection master; +connection slave; +# t2 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 13: Ensure consistency when filtering by +# --ignore-domain-ids with a stop position +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_DOMAIN_IDS=(0); +START SLAVE UNTIL master_gtid_pos="0-1-4"; +# No slave error expecting - waiting for slave to catch up to master +# Because there is a stop position we wait for all events to process +# and slave to automatically stop +# Stop slave so it stops receiving master events. +Warnings: +Note 1255 Slave already has been stopped +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --ignore-domain-ids=0 --stop-position=0-1-4 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 0 tables +# Verifying integrity of tables.. +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t2,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 14: Ensure consistency when filtering by +# --ignore-server-ids with a stop position +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_SERVER_IDS=(3); +START SLAVE UNTIL master_gtid_pos="0-1-4"; +# No slave error expecting - waiting for slave to catch up to master +# Because there is a stop position we wait for all events to process +# and slave to automatically stop +# Stop slave so it stops receiving master events. +Warnings: +Note 1255 Slave already has been stopped +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --ignore-server-ids=3 --stop-position=0-1-4 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t1 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t2,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 15: Ensure consistency when filtering by +# --do-domain-ids with a start position +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +set global gtid_slave_pos="1-1-2"; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(2); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-1-2 --do-domain-ids=2 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t5 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t2,test.t3,test.t4' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 16: Ensure consistency when filtering by +# --ignore-domain-ids with a start position +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +set global gtid_slave_pos="0-1-1"; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_DOMAIN_IDS=(0); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --ignore-domain-ids=0 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 3 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t3 is equivalent on master and slave +connection master; +connection slave; +# t4 is equivalent on master and slave +connection master; +connection slave; +# t5 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t2' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 17: Ensure consistency when filtering by +# --ignore-server-ids with a start position +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +set global gtid_slave_pos="0-1-1"; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_SERVER_IDS=(1); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --ignore-server-ids=1 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 2 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t2 is equivalent on master and slave +connection master; +connection slave; +# t4 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t3,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 18: Ensure consistency when filtering by +# --do-domain-ids with both a start position and stop position that +# all have the same domain id +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +set global gtid_slave_pos="0-1-1"; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(0); +START SLAVE UNTIL master_gtid_pos="0-3-3"; +# No slave error expecting - waiting for slave to catch up to master +# Because there is a stop position we wait for all events to process +# and slave to automatically stop +# Stop slave so it stops receiving master events. +Warnings: +Note 1255 Slave already has been stopped +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --do-domain-ids=0 --stop-position=0-3-3 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t2 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 19: Ensure consistency when filtering by +# --do-domain-ids with both a start position and stop position that +# have differing domain ids. Due to the implicit filtering in stop +# position, the result should be empty (no tables replicated). +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +set global gtid_slave_pos="0-1-1"; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(1); +START SLAVE UNTIL master_gtid_pos="0-3-3"; +# No slave error expecting - waiting for slave to catch up to master +# Because there is a stop position we wait for all events to process +# and slave to automatically stop +# Stop slave so it stops receiving master events. +Warnings: +Note 1255 Slave already has been stopped +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --do-domain-ids=1 --stop-position=0-3-3 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 0 tables +# Verifying integrity of tables.. +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t2,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 20: Ensure consistency when filtering by +# --ignore-domain-ids with both a start position and stop position that +# all have the same domain id. The result set should be empty due to +# implicit filtering from stop position and ignoring that same domain. +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +set global gtid_slave_pos="0-1-1"; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_DOMAIN_IDS=(0); +START SLAVE UNTIL master_gtid_pos="0-3-3"; +# No slave error expecting - waiting for slave to catch up to master +# Because there is a stop position we wait for all events to process +# and slave to automatically stop +# Stop slave so it stops receiving master events. +Warnings: +Note 1255 Slave already has been stopped +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --ignore-domain-ids=0 --stop-position=0-3-3 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 0 tables +# Verifying integrity of tables.. +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t2,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 21: Ensure consistency when filtering by +# --ignore-domain-ids with both a start position and stop position that +# have differing domain ids. The ignore domain ids should take no +# effect due to the implicit filtering by stop position, i.e. the +# specified domain to ignore is already being filtered. +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +set global gtid_slave_pos="0-1-1"; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_DOMAIN_IDS=(1); +START SLAVE UNTIL master_gtid_pos="0-3-3"; +# No slave error expecting - waiting for slave to catch up to master +# Because there is a stop position we wait for all events to process +# and slave to automatically stop +# Stop slave so it stops receiving master events. +Warnings: +Note 1255 Slave already has been stopped +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --ignore-domain-ids=1 --stop-position=0-3-3 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t2 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 22: Ensure consistency when filtering by +# --ignore-server-ids with both a start position and stop position. +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=0; +connection slave; +connection master; +# Populating master data +connection slave; +set global gtid_slave_pos="0-1-0"; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_SERVER_IDS=(3); +START SLAVE UNTIL master_gtid_pos="0-3-3"; +# No slave error expecting - waiting for slave to catch up to master +# Because there is a stop position we wait for all events to process +# and slave to automatically stop +# Stop slave so it stops receiving master events. +Warnings: +Note 1255 Slave already has been stopped +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --ignore-server-ids=3 --stop-position=0-3-3 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t1 is equivalent on master and slave +# All tables are consistent +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t2,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +connection master; +# +# +# Test Case 23: Out of order GTIDs from domains or servers which are +# filtered out should not error +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=1; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(0), IGNORE_SERVER_IDS=(3); +START SLAVE ; +# No slave error expecting - waiting for slave to catch up to master +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t4,test.t5' +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --do-domain-ids=0 --ignore-server-ids=3 --gtid-strict-mode 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t1 is equivalent on master and slave +# All tables are consistent +# Strict mode enabled - checking mysqlbinlog error output for out +# of order GTIDs +# Not expecting to find out of order GTID error.. +NOT FOUND /Found out of order GTID/ in mysqlbinlog_stderr.out +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t2,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +set @@global.gtid_strict_mode=0; +connection master; +# +# +# Test Case 24: Out of order GTIDs from included domains should error +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=1; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(1); +START SLAVE ; +# slave SQL Thread error expected - waiting for errno 1950 +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t4,test.t5' +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --do-domain-ids=1 --gtid-strict-mode 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t3 is equivalent on master and slave +# All tables are consistent +# Strict mode enabled - checking mysqlbinlog error output for out +# of order GTIDs +# Expecting to find out of order GTID error.. +FOUND 1 /Found out of order GTID/ in mysqlbinlog_stderr.out +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t2,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +set @@global.gtid_strict_mode=0; +connection master; +# +# +# Test Case 25: Out of order GTIDs from included servers should error +# +include/mysqlbinlog_slave_consistency.inc +connection slave; +set @@global.gtid_strict_mode=1; +connection slave; +connection master; +# Populating master data +connection slave; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, IGNORE_SERVER_IDS=(1); +START SLAVE ; +# slave SQL Thread error expected - waiting for errno 1950 +# Stop slave so it stops receiving master events. +connection master; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t4,test.t5' +RESET MASTER; +# MYSQL_BINLOG BINLOG_FILE_PARAM --ignore-server-ids=1 --gtid-strict-mode 2> MYSQLBINLOG_STDERR | MYSQL +connection slave; +# Checking consistency of 'test' database tables between master and slave +connection master; +# Both servers have 1 tables +# Verifying integrity of tables.. +connection master; +connection slave; +# t2 is equivalent on master and slave +# All tables are consistent +# Strict mode enabled - checking mysqlbinlog error output for out +# of order GTIDs +# Expecting to find out of order GTID error.. +FOUND 1 /Found out of order GTID/ in mysqlbinlog_stderr.out +# Test finished - resetting master and slave.. +connection slave; +RESET SLAVE; +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), IGNORE_SERVER_IDS=(); +connection master; +RESET MASTER; +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +Warnings: +Note 1051 Unknown table 'test.t1,test.t3,test.t4,test.t5' +connection slave; +RESET SLAVE; +set global gtid_slave_pos=""; +RESET MASTER; +connection master; +RESET MASTER; +connection slave; +set @@global.gtid_strict_mode=0; +connection master; +# +# +# Test Case 26: Neither mysqlbinlog nor CHANGE MASTER TO should allow +# both do domain ids and ignore domain ids to be set together +# +connection slave; +include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(0), IGNORE_DOMAIN_IDS=(1); +ERROR HY000: Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(); +include/start_slave.inc +connection master; +RESET MASTER; +include/rpl_end.inc +# End of tests (rpl.rpl_mysqlbinlog_slave_consistency) diff --git a/mysql-test/suite/rpl/t/rpl_mysqlbinlog_slave_consistency.test b/mysql-test/suite/rpl/t/rpl_mysqlbinlog_slave_consistency.test new file mode 100644 index 00000000000..d2918e3a890 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_mysqlbinlog_slave_consistency.test @@ -0,0 +1,401 @@ +# +# Purpose: +# +# This test ensures the mariadb-binlog command line tool filters events +# by domain id (via --do-domain-ids and --ignore-domain-ids) and server id (via +# --ignore-server-ids) in the same way that a replica server does. +# +# +# Methodology: +# +# This test validates that the domain and server id filtering logic of +# mariadb-binlog matches that of a replica server. In particular, it validates +# a mariadb-binlog replay of a master's binary log is consistent with a +# replica's state which is configured using the same filtering configuration. +# +# It uses a repeatable process to allow for multiple test cases that span +# different filtering configurations. First, a master is seeded with an initial +# set of SQL statements with varying domain and server ids. Then, a set of +# filtering parameters supported by both mariadb-binlog and replica +# capabilities are defined. The replica is configured using these parameters +# and run it until it has processed all events from the primary server; it is +# stopped afterward. For mariadb-binlog validation, the binary log of the +# primary server is copied to a different location for later replay. The +# primary is then reset to its initial state (i.e. the tables are dropped and +# the logs are reset). The mariadb-binlog tool is then used to replay the +# copied binary log file back onto the clean primary server under the same +# filtering conditions as the replica. At this point, the data on the primary +# and replica should be exactly the same because the filtering conditions were +# the same, and all existing tables on both servers are compared using. +# checksums. +# +# +# References: +# +# MDEV-20119: Implement the --do-domain-ids, --ignore-domain-ids, and +# --ignore-server-ids options for mysqlbinlog +# +--source include/master-slave.inc + +--connection slave +SET sql_log_bin=0; +call mtr.add_suppression("Slave: An attempt was made.*"); +call mtr.add_suppression("Both DO_DOMAIN_IDS & IGNORE_DOMAIN_IDS lists can't be non-empty at the same time"); +SET sql_log_bin=1; + +--source include/stop_slave.inc + +--connection master +RESET MASTER; + +# Save old state +let $ORIG_GTID_DOMAIN_ID = `select @@session.gtid_domain_id`; +let $ORIG_SERVER_ID = `select @@session.server_id`; + +--connection slave +--source include/start_slave.inc + +# Initial tests do not use strict mode +--let $strict_mode=0 +--let $slave_sql_errno=0 + +--echo # +--echo # +--echo # Test Case 1: Base case to ensure that mariadb-binlog and replica +--echo # are consistent without any filtering +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids= +--let $ignore_server_ids= +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 2: Ensure filtering by a single id in --do-domain-ids is +--echo # consistent between mariadb-binlog and replica +--echo # +--let $do_domain_ids=0 +--let $ignore_domain_ids= +--let $ignore_server_ids= +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 3: Ensure filtering by multiple ids in --do-domain-ids is +--echo # consistent between mariadb-binlog and replica +--echo # +--let $do_domain_ids=0,1 +--let $ignore_domain_ids= +--let $ignore_server_ids= +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # Test Case 4: Ensure filtering by a single id in --ignore-domain-ids +--echo # is consistent between mariadb-binlog and replica +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids=0 +--let $ignore_server_ids= +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 5: Ensure filtering by multiple ids in --ignore-domain-ids +--echo # is consistent between mariadb-binlog and replica +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids=0,1 +--let $ignore_server_ids= +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # Test Case 6: Ensure filtering by a single id in --ignore-server-ids +--echo # is consistent between mariadb-binlog and replica +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids= +--let $ignore_server_ids=1 +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 7: Ensure filtering by multiple ids in --ignore-server-ids +--echo # is consistent between mariadb-binlog and replica +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids= +--let $ignore_server_ids=0,1 +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 8: Ensure stop position consistency +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids= +--let $ignore_server_ids= +--let $stop_position=1-1-2 +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 9: Ensure start position consistency +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids= +--let $ignore_server_ids= +--let $stop_position= +--let $start_position=1-4-2 +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 10: Ensure consistency when filtering by both +--echo # --do-domain-ids and --ignore-server-ids +--echo # +--let $do_domain_ids=0 +--let $ignore_domain_ids= +--let $ignore_server_ids=1 +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 11: Ensure consistency when filtering by both +--echo # --ignore-domain-ids and --ignore-server-ids +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids=1,2 +--let $ignore_server_ids=1 +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 12: Ensure consistency when filtering by +--echo # --do-domain-ids with a stop position +--echo # +--let $do_domain_ids=0 +--let $ignore_domain_ids= +--let $ignore_server_ids= +--let $stop_position=0-1-4 +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 13: Ensure consistency when filtering by +--echo # --ignore-domain-ids with a stop position +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids=0 +--let $ignore_server_ids= +--let $stop_position=0-1-4 +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 14: Ensure consistency when filtering by +--echo # --ignore-server-ids with a stop position +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids= +--let $ignore_server_ids=3 +--let $stop_position=0-1-4 +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 15: Ensure consistency when filtering by +--echo # --do-domain-ids with a start position +--echo # +--let $do_domain_ids=2 +--let $ignore_domain_ids= +--let $ignore_server_ids= +--let $stop_position= +--let $start_position=1-1-2 +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 16: Ensure consistency when filtering by +--echo # --ignore-domain-ids with a start position +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids=0 +--let $ignore_server_ids= +--let $stop_position= +--let $start_position=0-1-1 +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 17: Ensure consistency when filtering by +--echo # --ignore-server-ids with a start position +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids= +--let $ignore_server_ids=1 +--let $stop_position= +--let $start_position=0-1-1 +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 18: Ensure consistency when filtering by +--echo # --do-domain-ids with both a start position and stop position that +--echo # all have the same domain id +--echo # +--let $do_domain_ids=0 +--let $ignore_domain_ids= +--let $ignore_server_ids= +--let $stop_position=0-3-3 +--let $start_position=0-1-1 +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 19: Ensure consistency when filtering by +--echo # --do-domain-ids with both a start position and stop position that +--echo # have differing domain ids. Due to the implicit filtering in stop +--echo # position, the result should be empty (no tables replicated). +--echo # +--let $do_domain_ids=1 +--let $ignore_domain_ids= +--let $ignore_server_ids= +--let $stop_position=0-3-3 +--let $start_position=0-1-1 +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 20: Ensure consistency when filtering by +--echo # --ignore-domain-ids with both a start position and stop position that +--echo # all have the same domain id. The result set should be empty due to +--echo # implicit filtering from stop position and ignoring that same domain. +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids=0 +--let $ignore_server_ids= +--let $stop_position=0-3-3 +--let $start_position=0-1-1 +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 21: Ensure consistency when filtering by +--echo # --ignore-domain-ids with both a start position and stop position that +--echo # have differing domain ids. The ignore domain ids should take no +--echo # effect due to the implicit filtering by stop position, i.e. the +--echo # specified domain to ignore is already being filtered. +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids=1 +--let $ignore_server_ids= +--let $stop_position=0-3-3 +--let $start_position=0-1-1 +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 22: Ensure consistency when filtering by +--echo # --ignore-server-ids with both a start position and stop position. +--echo # +--let $do_domain_ids= +--let $ignore_domain_ids= +--let $ignore_server_ids=3 +--let $stop_position=0-3-3 +--let $start_position=0-1-0 +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 23: Out of order GTIDs from domains or servers which are +--echo # filtered out should not error +--echo # +--let $strict_mode=1 +--let $strict_mode_err=0 +--let $slave_sql_errno=0 +--let $do_domain_ids=0 +--let $ignore_domain_ids= +--let $ignore_server_ids=3 +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 24: Out of order GTIDs from included domains should error +--echo # +--let $strict_mode=1 +--let $strict_mode_err=1 +--let $slave_sql_errno=1950 +--let $do_domain_ids=1 +--let $ignore_domain_ids= +--let $ignore_server_ids= +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 25: Out of order GTIDs from included servers should error +--echo # +--let $strict_mode=1 +--let $strict_mode_err=1 +--let $slave_sql_errno=1950 +--let $do_domain_ids= +--let $ignore_domain_ids= +--let $ignore_server_ids=1 +--let $stop_position= +--let $start_position= +--source include/mysqlbinlog_slave_consistency.inc + +--echo # +--echo # +--echo # Test Case 26: Neither mysqlbinlog nor CHANGE MASTER TO should allow +--echo # both do domain ids and ignore domain ids to be set together +--echo # +--connection slave +--source include/stop_slave.inc + +--error 1201 +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(0), IGNORE_DOMAIN_IDS=(1); + +--let $MYSQLD_DATADIR=`select @@datadir` +--let BINLOG_FILENAME= query_get_value(SHOW BINARY LOGS, Log_name, 1) +--let BINLOG_FILE_PARAM= $MYSQLD_DATADIR/$BINLOG_FILENAME.orig +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILENAME --do-domain-ids=0 --ignore-domain-ids=1 + +RESET MASTER; +set global gtid_slave_pos=""; +CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(); +--source include/start_slave.inc + +# Cleanup +--connection master +RESET MASTER; + +--source include/rpl_end.inc + +--echo # End of tests (rpl.rpl_mysqlbinlog_slave_consistency) |