summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2014-12-03 22:30:48 -0500
committerNirbhay Choubey <nirbhay@mariadb.com>2014-12-03 22:30:48 -0500
commita50ddebb5cfa7b79540d155e8e41c7a07c4c3fbf (patch)
treef3eb22219d77fe510fce912278a44d0e81650856
parent7bf4f9f7f66192f07fa46ed30c38f8842502fc4f (diff)
downloadmariadb-git-a50ddebb5cfa7b79540d155e8e41c7a07c4c3fbf.tar.gz
MDEV-6593 : domain_id based replication filters
Implementation for domain ID based filtering of replication events.
-rw-r--r--mysql-test/include/check-testcase.test2
-rw-r--r--mysql-test/suite/multi_source/info_logs.result12
-rw-r--r--mysql-test/suite/multi_source/multisource.result24
-rw-r--r--mysql-test/suite/multi_source/reset_slave.result8
-rw-r--r--mysql-test/suite/multi_source/simple.result22
-rw-r--r--mysql-test/suite/multi_source/syntax.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_domain_id_filter.result261
-rw-r--r--mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result415
-rw-r--r--mysql-test/suite/rpl/r/rpl_domain_id_filter_master_crash.result59
-rw-r--r--mysql-test/suite/rpl/r/rpl_domain_id_filter_parallel.result177
-rw-r--r--mysql-test/suite/rpl/r/rpl_domain_id_filter_restart.result46
-rw-r--r--mysql-test/suite/rpl/t/rpl_domain_id_filter.test431
-rw-r--r--mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test399
-rw-r--r--mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test98
-rw-r--r--mysql-test/suite/rpl/t/rpl_domain_id_filter_parallel.test221
-rw-r--r--mysql-test/suite/rpl/t/rpl_domain_id_filter_restart.test79
-rw-r--r--sql/lex.h2
-rw-r--r--sql/rpl_gtid.h2
-rw-r--r--sql/rpl_mi.cc390
-rw-r--r--sql/rpl_mi.h119
-rw-r--r--sql/slave.cc110
-rw-r--r--sql/sql_lex.h16
-rw-r--r--sql/sql_repl.cc68
-rw-r--r--sql/sql_yacc.yy34
24 files changed, 2889 insertions, 112 deletions
diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test
index dcf6bd154ce..da0b570ae35 100644
--- a/mysql-test/include/check-testcase.test
+++ b/mysql-test/include/check-testcase.test
@@ -64,6 +64,8 @@ if ($tmp)
--echo Master_SSL_Crlpath #
--echo Using_Gtid No
--echo Gtid_IO_Pos #
+ --echo Replicate_Do_Domain_Ids
+ --echo Replicate_Ignore_Domain_Ids
}
if (!$tmp) {
# Note: after WL#5177, fields 13-18 shall not be filtered-out.
diff --git a/mysql-test/suite/multi_source/info_logs.result b/mysql-test/suite/multi_source/info_logs.result
index 57980be22f6..2730a5531f5 100644
--- a/mysql-test/suite/multi_source/info_logs.result
+++ b/mysql-test/suite/multi_source/info_logs.result
@@ -84,17 +84,17 @@ MASTER 2.2
# EOF
#
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
- Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 relay.000002 601 master-bin.000001 Yes Yes 0 0 313 888 None 0 No 0 No 0 0 1 No 0 1073741824 7 0 60.000
-MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 relay-master@00202@002e2.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+ Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 relay.000002 601 master-bin.000001 Yes Yes 0 0 313 888 None 0 No 0 No 0 0 1 No 0 1073741824 7 0 60.000
+MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 relay-master@00202@002e2.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000
include/wait_for_slave_to_start.inc
set default_master_connection = 'MASTER 2.2';
include/wait_for_slave_to_start.inc
set default_master_connection = '';
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
- Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 relay.000004 536 master-bin.000001 Yes Yes 0 0 313 823 None 0 No 0 No 0 0 1 No 0 1073741824 6 0 60.000
-MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 relay-master@00202@002e2.000004 536 master-bin.000001 Yes Yes 0 0 313 842 None 0 No 0 No 0 0 2 No 0 1073741824 6 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+ Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 relay.000004 536 master-bin.000001 Yes Yes 0 0 313 823 None 0 No 0 No 0 0 1 No 0 1073741824 6 0 60.000
+MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 relay-master@00202@002e2.000004 536 master-bin.000001 Yes Yes 0 0 313 842 None 0 No 0 No 0 0 2 No 0 1073741824 6 0 60.000
#
# List of files matching '*info*' pattern
# after slave server restart
diff --git a/mysql-test/suite/multi_source/multisource.result b/mysql-test/suite/multi_source/multisource.result
index 94677e84cc8..308ccec9dd8 100644
--- a/mysql-test/suite/multi_source/multisource.result
+++ b/mysql-test/suite/multi_source/multisource.result
@@ -10,14 +10,14 @@ start slave 'master1';
set default_master_connection = 'master1';
include/wait_for_slave_to_start.inc
show slave 'master1' status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos
-Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-master1.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 1 No
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids
+Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-master1.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 1 No
show slave status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos
-Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-master1.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 1 No
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids
+Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-master1.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 1 No
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
-master1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-master1.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 1 No 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+master1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-master1.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 1 No 0 1073741824 7 0 60.000
drop database if exists db1;
create database db1;
use db1;
@@ -75,9 +75,9 @@ master_user='root';
start slave;
include/wait_for_slave_to_start.inc
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
- Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin.000002 601 master-bin.000001 Yes Yes 0 0 313 899 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000 0-1-4
-master1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 988 mysqld-relay-bin-master1.000002 1276 master-bin.000001 Yes Yes 0 0 988 1582 None 0 No 0 No 0 0 1 No 0 1073741824 17 0 60.000 0-1-4
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+ Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin.000002 601 master-bin.000001 Yes Yes 0 0 313 899 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000 0-1-4
+master1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 988 mysqld-relay-bin-master1.000002 1276 master-bin.000001 Yes Yes 0 0 988 1582 None 0 No 0 No 0 0 1 No 0 1073741824 17 0 60.000 0-1-4
insert into t1 (f1) values ('three');
drop database if exists db2;
create database db2;
@@ -105,9 +105,9 @@ master-bin.000002 367
insert into t1 (f1) values ('four');
create table db1.t3 (f1 int) engine=InnoDB;
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
- Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 921 mysqld-relay-bin.000002 1209 master-bin.000001 Yes Yes 0 0 921 1507 None 0 No 0 No 0 0 2 No 0 1073741824 17 0 60.000 0-1-7
-master1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000002 740 mysqld-relay-bin-master1.000004 1028 master-bin.000002 Yes Yes 0 0 740 1378 None 0 No 0 No 0 0 1 No 0 1073741824 37 0 60.000 0-1-7
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+ Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 921 mysqld-relay-bin.000002 1209 master-bin.000001 Yes Yes 0 0 921 1507 None 0 No 0 No 0 0 2 No 0 1073741824 17 0 60.000 0-1-7
+master1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000002 740 mysqld-relay-bin-master1.000004 1028 master-bin.000002 Yes Yes 0 0 740 1378 None 0 No 0 No 0 0 1 No 0 1073741824 37 0 60.000 0-1-7
select * from db1.t1;
i f1
1 one
diff --git a/mysql-test/suite/multi_source/reset_slave.result b/mysql-test/suite/multi_source/reset_slave.result
index b78566ea933..d5fd405b050 100644
--- a/mysql-test/suite/multi_source/reset_slave.result
+++ b/mysql-test/suite/multi_source/reset_slave.result
@@ -10,15 +10,15 @@ create table t1 (i int) engine=MyISAM;
insert into t1 values (1),(2);
stop slave 'master1';
show slave 'master1' status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos
- 127.0.0.1 root MYPORT_1 60 master-bin.000001 802 mysqld-relay-bin-master1.000002 1090 master-bin.000001 No No 0 0 802 1396 None 0 No NULL No 0 0 1 No
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids
+ 127.0.0.1 root MYPORT_1 60 master-bin.000001 802 mysqld-relay-bin-master1.000002 1090 master-bin.000001 No No 0 0 802 1396 None 0 No NULL No 0 0 1 No
mysqld-relay-bin-master1.000001
mysqld-relay-bin-master1.000002
mysqld-relay-bin-master1.index
reset slave 'master1';
show slave 'master1' status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos
- 127.0.0.1 root MYPORT_1 60 4 1090 No No 0 0 0 1396 None 0 No NULL No 0 0 1 No
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids
+ 127.0.0.1 root MYPORT_1 60 4 1090 No No 0 0 0 1396 None 0 No NULL No 0 0 1 No
reset slave 'master1' all;
show slave 'master1' status;
ERROR HY000: There is no master connection 'master1'
diff --git a/mysql-test/suite/multi_source/simple.result b/mysql-test/suite/multi_source/simple.result
index 6e4bb9b6309..2b4590ae095 100644
--- a/mysql-test/suite/multi_source/simple.result
+++ b/mysql-test/suite/multi_source/simple.result
@@ -10,9 +10,9 @@ Note 1937 SLAVE 'slave2' started
include/wait_for_slave_to_start.inc
set default_master_connection = '';
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
-slave1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-slave1.000002 601 master-bin.000001 Yes Yes 0 0 313 906 None 0 No 0 No 0 0 1 No 0 1073741824 7 0 60.000
-slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin-slave2.000002 601 master-bin.000001 Yes Yes 0 0 313 906 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-slave1.000002 601 master-bin.000001 Yes Yes 0 0 313 906 None 0 No 0 No 0 0 1 No 0 1073741824 7 0 60.000
+slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin-slave2.000002 601 master-bin.000001 Yes Yes 0 0 313 906 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000
start all slaves;
stop slave 'slave1';
show slave 'slave1' status;
@@ -60,21 +60,23 @@ Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid No
Gtid_IO_Pos
+Replicate_Do_Domain_Ids
+Replicate_Ignore_Domain_Ids
reset slave 'slave1';
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
-slave1 127.0.0.1 root MYPORT_1 60 4 601 No No 0 0 0 906 None 0 No NULL No 0 0 1 No 0 1073741824 7 0 60.000
-slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin-slave2.000002 601 master-bin.000001 Yes Yes 0 0 313 906 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave1 127.0.0.1 root MYPORT_1 60 4 601 No No 0 0 0 906 None 0 No NULL No 0 0 1 No 0 1073741824 7 0 60.000
+slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin-slave2.000002 601 master-bin.000001 Yes Yes 0 0 313 906 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000
reset slave 'slave1' all;
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
-slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin-slave2.000002 601 master-bin.000001 Yes Yes 0 0 313 906 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin-slave2.000002 601 master-bin.000001 Yes Yes 0 0 313 906 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000
stop all slaves;
Warnings:
Note 1938 SLAVE 'slave2' stopped
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
-slave2 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin-slave2.000002 601 master-bin.000001 No No 0 0 313 906 None 0 No NULL No 0 0 2 No 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave2 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin-slave2.000002 601 master-bin.000001 No No 0 0 313 906 None 0 No NULL No 0 0 2 No 0 1073741824 7 0 60.000
stop all slaves;
include/reset_master_slave.inc
include/reset_master_slave.inc
diff --git a/mysql-test/suite/multi_source/syntax.result b/mysql-test/suite/multi_source/syntax.result
index 5666e43c16e..166dd09c1a3 100644
--- a/mysql-test/suite/multi_source/syntax.result
+++ b/mysql-test/suite/multi_source/syntax.result
@@ -1,11 +1,11 @@
include/master-slave.inc
[connection master]
show slave status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids
show slave '' status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
#
# Check error handling
#
diff --git a/mysql-test/suite/rpl/r/rpl_domain_id_filter.result b/mysql-test/suite/rpl/r/rpl_domain_id_filter.result
new file mode 100644
index 00000000000..b2ed5511d71
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_domain_id_filter.result
@@ -0,0 +1,261 @@
+include/master-slave.inc
+[connection master]
+# On slave
+call mtr.add_suppression("Both DO_DOMAIN_IDS & IGNORE_DOMAIN_IDS lists can't be non-empty at the same time");
+call mtr.add_suppression("DO_DOMAIN_IDS or IGNORE_DOMAIN_IDS lists can't be non-empty in non-GTID mode.*");
+# On master
+SET @@session.gtid_domain_id= 1;
+SELECT @@session.gtid_domain_id;
+@@session.gtid_domain_id
+1
+CREATE TABLE t1(i INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+i
+1
+# On slave
+SELECT * FROM t1;
+i
+1
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) : 1
+IGNORE_DOMAIN_IDS (AFTER) :
+# On master
+SET @@session.gtid_domain_id= 2;
+INSERT INTO t1 VALUES(2);
+SET @@session.gtid_domain_id= 1;
+INSERT INTO t1 VALUES(3);
+SELECT * FROM t1;
+i
+1
+2
+3
+# On slave
+SELECT * FROM t1;
+i
+1
+3
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) : 1
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+# On master
+SELECT @@session.gtid_domain_id;
+@@session.gtid_domain_id
+1
+INSERT INTO t1 VALUES(4);
+SET @@session.gtid_domain_id= 2;
+INSERT INTO t1 VALUES(5);
+SELECT * FROM t1;
+i
+1
+2
+3
+4
+5
+# On slave
+SELECT * FROM t1;
+i
+1
+3
+5
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) : 1
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), IGNORE_DOMAIN_IDS=(2), MASTER_USE_GTID=slave_pos;
+ERROR HY000: Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+include/stop_slave.inc
+Warnings:
+Note 1255 Slave already has been stopped
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) : 1
+CHANGE MASTER TO DO_DOMAIN_IDS=(4,4,5,1,7,7,7,1,1,2,6,8,1,4,5,5,9,3), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) : 1, 2, 3, 4, 5, 6, 7, 8, 9
+IGNORE_DOMAIN_IDS (AFTER) :
+# On master
+SELECT @@session.gtid_domain_id;
+@@session.gtid_domain_id
+2
+INSERT INTO t1 VALUES(8);
+SET @@session.gtid_domain_id= 7;
+INSERT INTO t1 VALUES(9);
+SET @@session.gtid_domain_id= 10;
+INSERT INTO t1 VALUES(10);
+INSERT INTO t1 VALUES(11);
+START TRANSACTION;
+INSERT INTO t1 VALUES(12);
+INSERT INTO t1 VALUES(13);
+COMMIT;
+INSERT INTO t1 VALUES(14);
+INSERT INTO t1 VALUES(15);
+# On slave
+SELECT * FROM t1;
+i
+1
+3
+5
+8
+9
+# On slave
+# Seconds_Behind_Master should be zero here because the slave is fully caught up and idle.
+Seconds_Behind_Master = '0'
+# On slave
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) : 1, 2, 3, 4, 5, 6, 7, 8, 9
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+# On master
+SET @@session.gtid_domain_id=2;
+CREATE TABLE t2(i int) ENGINE=MYISAM;
+CREATE TABLE t3(i int) ENGINE=INNODB;
+SET @@session.gtid_domain_id=1;
+BEGIN;
+INSERT INTO t2 VALUES(1);
+INSERT INTO t3 VALUES(1);
+# On slave
+include/stop_slave.inc
+include/wait_for_slave_to_stop.inc
+# On master
+INSERT INTO t2 VALUES(2);
+INSERT INTO t3 VALUES(2);
+COMMIT;
+# On slave
+include/start_slave.inc
+SELECT * FROM t2;
+i
+SELECT * FROM t3;
+i
+# On master
+SET @@session.gtid_domain_id=1;
+BEGIN;
+INSERT INTO t2 VALUES(3);
+INSERT INTO t3 VALUES(3);
+# On slave
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) : 1
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) :
+# On master
+INSERT INTO t2 VALUES(4);
+INSERT INTO t3 VALUES(4);
+COMMIT;
+# On slave
+SELECT * FROM t2;
+i
+4
+SELECT * FROM t3;
+i
+3
+4
+# On master
+SET @@session.gtid_domain_id=1;
+BEGIN;
+INSERT INTO t2 VALUES(5);
+INSERT INTO t3 VALUES(5);
+# On slave
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+# On master
+INSERT INTO t2 VALUES(6);
+INSERT INTO t3 VALUES(6);
+COMMIT;
+# On slave
+SELECT * FROM t2;
+i
+4
+5
+SELECT * FROM t3;
+i
+3
+4
+# On slave
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) : 1
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(2), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 2
+# On master
+SET @@session.gtid_domain_id=2;
+BEGIN;
+INSERT INTO t2 VALUES(7);
+INSERT INTO t3 VALUES(7);
+COMMIT;
+# On slave
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) : 2
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) :
+# On master
+SET @@session.gtid_domain_id=2;
+BEGIN;
+INSERT INTO t2 VALUES(8);
+INSERT INTO t3 VALUES(8);
+COMMIT;
+SELECT * FROM t2;
+i
+4
+5
+8
+SELECT * FROM t3;
+i
+3
+4
+8
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS;
+ERROR HY000: Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS;
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS;
+ERROR HY000: Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS;
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS;
+ERROR HY000: Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) : 1
+CHANGE MASTER TO MASTER_USE_GTID=NO;
+ERROR HY000: Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=NO;
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), MASTER_USE_GTID=NO;
+ERROR HY000: Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=NO;
+ERROR HY000: Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) :
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), DO_DOMAIN_IDS=(), MASTER_USE_GTID=SLAVE_POS;
+include/start_slave.inc
+# On master
+SET @@session.gtid_domain_id=2;
+DROP TABLE t1, t2, t3;
+# On slave
+include/stop_slave.inc
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=();
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result b/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result
new file mode 100644
index 00000000000..0c4fe90ba9a
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result
@@ -0,0 +1,415 @@
+include/master-slave.inc
+[connection master]
+# On master
+SET @@session.gtid_domain_id= 1;
+SELECT @@session.gtid_domain_id;
+@@session.gtid_domain_id
+1
+CREATE TABLE t1(i INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+i
+1
+# On slave
+call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*");
+# Case 0 : Start slave with IGNORE_DOMAIN_IDS=(), then restart
+# replication with IGNORE_DOMAIN_IDS=() after IO thread is
+# killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_before_commit").
+SELECT * FROM t1;
+i
+1
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) :
+SET @@global.debug_dbug="+d,kill_slave_io_before_commit";
+# On master
+START TRANSACTION;
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(3);
+COMMIT;
+SELECT * FROM t1;
+i
+1
+2
+3
+# On slave
+include/wait_for_slave_io_error.inc [errno=1595]
+SELECT * FROM t1;
+i
+1
+SET @@global.debug_dbug="-d";
+START SLAVE io_thread;
+include/wait_for_slave_io_to_start.inc
+SELECT * FROM t1;
+i
+1
+2
+3
+# Case 1 : Start slave with IGNORE_DOMAIN_IDS=(1), then restart
+# replication with IGNORE_DOMAIN_IDS=(1) after IO thread is
+# killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_before_commit").
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+SET @@global.debug_dbug="+d,kill_slave_io_before_commit";
+# On master
+START TRANSACTION;
+INSERT INTO t1 VALUES(4);
+INSERT INTO t1 VALUES(5);
+COMMIT;
+SELECT * FROM t1;
+i
+1
+2
+3
+4
+5
+# On slave
+include/wait_for_slave_io_error.inc [errno=1595]
+SELECT * FROM t1;
+i
+1
+2
+3
+SET @@global.debug_dbug="-d";
+START SLAVE io_thread;
+include/wait_for_slave_io_to_start.inc
+SELECT * FROM t1;
+i
+1
+2
+3
+# Case 2 : Start slave with IGNORE_DOMAIN_IDS=(), then restart
+# replication with IGNORE_DOMAIN_IDS=(1) after IO thread is
+# killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_before_commit").
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) : 1
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) :
+SET @@global.debug_dbug="+d,kill_slave_io_before_commit";
+# On master
+START TRANSACTION;
+INSERT INTO t1 VALUES(6);
+INSERT INTO t1 VALUES(7);
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 VALUES(8);
+INSERT INTO t1 VALUES(9);
+COMMIT;
+SET @@session.gtid_domain_id= 2;
+START TRANSACTION;
+INSERT INTO t1 VALUES(10);
+INSERT INTO t1 VALUES(11);
+COMMIT;
+SELECT * FROM t1;
+i
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+# On slave
+include/wait_for_slave_io_error.inc [errno=1595]
+SELECT * FROM t1;
+i
+1
+2
+3
+SET @@global.debug_dbug="-d";
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+SELECT * FROM t1;
+i
+1
+2
+3
+10
+11
+# Case 3 : Start slave with IGNORE_DOMAIN_IDS=(1), then restart
+# replication with IGNORE_DOMAIN_IDS=() after IO thread is
+# killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_before_commit").
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) : 1
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+SET @@global.debug_dbug="+d,kill_slave_io_before_commit";
+# On master
+SET @@session.gtid_domain_id= 1;
+START TRANSACTION;
+INSERT INTO t1 VALUES(12);
+INSERT INTO t1 VALUES(13);
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 VALUES(14);
+INSERT INTO t1 VALUES(15);
+COMMIT;
+SET @@session.gtid_domain_id= 2;
+START TRANSACTION;
+INSERT INTO t1 VALUES(16);
+INSERT INTO t1 VALUES(17);
+COMMIT;
+SELECT * FROM t1;
+i
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+# On slave
+include/wait_for_slave_io_error.inc [errno=1595]
+SELECT * FROM t1;
+i
+1
+2
+3
+10
+11
+SET @@global.debug_dbug="-d";
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) : 1
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) :
+SELECT * FROM t1;
+i
+1
+2
+3
+10
+11
+14
+15
+16
+17
+# Case 4 : Start slave with IGNORE_DOMAIN_IDS=(1), then restart
+# replication with IGNORE_DOMAIN_IDS=() after IO thread is
+# killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_after_2_events").
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+SET @@global.debug_dbug="+d,kill_slave_io_after_2_events";
+# On master
+SET @@session.gtid_domain_id= 1;
+START TRANSACTION;
+INSERT INTO t1 VALUES(18);
+INSERT INTO t1 VALUES(19);
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 VALUES(20);
+INSERT INTO t1 VALUES(21);
+COMMIT;
+SET @@session.gtid_domain_id= 2;
+START TRANSACTION;
+INSERT INTO t1 VALUES(22);
+INSERT INTO t1 VALUES(23);
+COMMIT;
+SELECT * FROM t1;
+i
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+# On slave
+include/wait_for_slave_io_error.inc [errno=1595]
+SELECT * FROM t1;
+i
+1
+2
+3
+10
+11
+14
+15
+16
+17
+SET @@global.debug_dbug="-d";
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) : 1
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) :
+SELECT * FROM t1;
+i
+1
+2
+3
+10
+11
+14
+15
+16
+17
+20
+21
+22
+23
+# Case 5 : Start slave with IGNORE_DOMAIN_IDS=(), then restart
+# replication with IGNORE_DOMAIN_IDS=(1) after IO thread is
+# killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_after_2_events").
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) :
+SET @@global.debug_dbug="+d,kill_slave_io_after_2_events";
+# On master
+SET @@session.gtid_domain_id= 1;
+START TRANSACTION;
+INSERT INTO t1 VALUES(24);
+INSERT INTO t1 VALUES(25);
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 VALUES(26);
+INSERT INTO t1 VALUES(27);
+COMMIT;
+SET @@session.gtid_domain_id= 2;
+START TRANSACTION;
+INSERT INTO t1 VALUES(28);
+INSERT INTO t1 VALUES(29);
+COMMIT;
+SELECT * FROM t1;
+i
+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
+# On slave
+include/wait_for_slave_io_error.inc [errno=1595]
+SELECT * FROM t1;
+i
+1
+2
+3
+10
+11
+14
+15
+16
+17
+20
+21
+22
+23
+SET @@global.debug_dbug="-d";
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+SELECT * FROM t1;
+i
+1
+2
+3
+10
+11
+14
+15
+16
+17
+20
+21
+22
+23
+28
+29
+# On master
+DROP TABLE t1;
+# On slave
+include/stop_slave.inc
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=();
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_domain_id_filter_master_crash.result b/mysql-test/suite/rpl/r/rpl_domain_id_filter_master_crash.result
new file mode 100644
index 00000000000..f26619a0871
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_domain_id_filter_master_crash.result
@@ -0,0 +1,59 @@
+include/master-slave.inc
+[connection master]
+# On master
+call mtr.add_suppression("mysqld: Table './mysql/gtid_slave_pos' is marked as crashed and should be repaired");
+call mtr.add_suppression("Checking table: './mysql/gtid_slave_pos'");
+call mtr.add_suppression("mysql.gtid_slave_pos: 1 client is using or hasn't closed the table properly");
+SET @@session.gtid_domain_id= 0;
+create table ti (a int auto_increment primary key) engine=innodb;
+create table tm (a int auto_increment primary key) engine=myisam;
+insert into ti set a=null;
+insert into tm set a=null;
+# On slave
+include/stop_slave.inc
+select * from ti;
+a
+1
+select * from tm;
+a
+1
+# On master
+SET @@session.gtid_domain_id= 1;
+begin;
+insert into ti set a=null;
+insert into tm set a=null;
+commit;
+SET @@session.gtid_domain_id= 0;
+insert into ti set a=null;
+insert into tm set a=null;
+set @@global.debug_dbug="+d,crash_before_send_xid";
+# On slave
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+# On master
+include/rpl_start_server.inc [server_number=1]
+# Master has restarted successfully
+set @@global.debug_dbug="-d";
+# On slave
+include/stop_slave.inc
+include/start_slave.inc
+select * from ti;
+a
+1
+3
+select * from tm;
+a
+1
+3
+# On master
+drop table ti;
+drop table tm;
+# On slave
+include/stop_slave.inc
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=NO;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_domain_id_filter_parallel.result b/mysql-test/suite/rpl/r/rpl_domain_id_filter_parallel.result
new file mode 100644
index 00000000000..d3e17a991b6
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_domain_id_filter_parallel.result
@@ -0,0 +1,177 @@
+include/rpl_init.inc [topology=1->2]
+# On slave
+SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
+include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=10;
+# On slave
+CHANGE MASTER TO master_use_gtid=slave_pos, DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=();
+include/start_slave.inc
+# On master
+SELECT @@session.gtid_domain_id;
+@@session.gtid_domain_id
+0
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
+CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=MyISAM;
+CREATE TABLE t2 (a int PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+# On slave
+# New connection 'con_temp1'
+LOCK TABLE t1 WRITE;
+# On master
+SET @@session.gtid_domain_id=1;
+INSERT INTO t1 VALUES (2);
+SET @@session.gtid_domain_id=0;
+INSERT INTO t2 VALUES (2);
+INSERT INTO t2 VALUES (3);
+BEGIN;
+INSERT INTO t2 VALUES (4);
+INSERT INTO t2 VALUES (5);
+COMMIT;
+INSERT INTO t2 VALUES (6);
+# On slave
+SELECT * FROM t2 ORDER by a;
+a
+1
+2
+3
+4
+5
+6
+# On con_temp1
+SELECT * FROM t1;
+a
+1
+UNLOCK TABLES;
+# On slave
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+# On slave
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) : 1
+IGNORE_DOMAIN_IDS (AFTER) :
+# On slave
+# On con_temp1
+LOCK TABLE t1 WRITE;
+# On master
+SET @@session.gtid_domain_id=0;
+INSERT INTO t1 VALUES (3);
+SET @@session.gtid_domain_id=1;
+INSERT INTO t2 VALUES (7);
+INSERT INTO t2 VALUES (8);
+BEGIN;
+INSERT INTO t2 VALUES (9);
+INSERT INTO t2 VALUES (10);
+COMMIT;
+INSERT INTO t2 VALUES (11);
+# On slave
+SELECT * FROM t2 ORDER by a;
+a
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+# On con_temp1
+SELECT * FROM t1;
+a
+1
+2
+UNLOCK TABLES;
+# On slave
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+# On slave
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) : 1
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+# On slave
+# On con_temp1
+LOCK TABLE t1 WRITE;
+# On master
+SET @@session.gtid_domain_id=1;
+INSERT INTO t1 VALUES (4);
+SET @@session.gtid_domain_id=0;
+INSERT INTO t2 VALUES (12);
+INSERT INTO t2 VALUES (13);
+BEGIN;
+INSERT INTO t2 VALUES (14);
+INSERT INTO t2 VALUES (15);
+COMMIT;
+INSERT INTO t2 VALUES (16);
+# On slave
+SELECT * FROM t2 ORDER by a;
+a
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+# On con_temp1
+SELECT * FROM t1;
+a
+1
+2
+UNLOCK TABLES;
+# On slave
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+SELECT * FROM t2;
+a
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+# Restore original settings.
+# On master
+SET @@session.gtid_domain_id=0;
+DROP TABLE t1, t2;
+# On slave
+include/stop_slave.inc
+SET GLOBAL slave_parallel_threads= @old_parallel_threads;
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=();
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_domain_id_filter_restart.result b/mysql-test/suite/rpl/r/rpl_domain_id_filter_restart.result
new file mode 100644
index 00000000000..b4706ea5f11
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_domain_id_filter_restart.result
@@ -0,0 +1,46 @@
+include/master-slave.inc
+[connection master]
+# On slave
+include/stop_slave.inc
+DO_DOMAIN_IDS (BEFORE) :
+IGNORE_DOMAIN_IDS (BEFORE) :
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) : 1
+# On master
+SET @@session.gtid_domain_id= 0;
+CREATE TABLE t1(i INT);
+CREATE TABLE t2(i INT);
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+i
+1
+SET @@session.gtid_domain_id= 1;
+INSERT INTO t2 VALUES(1);
+SELECT * FROM t2;
+i
+1
+# On slave
+SELECT * FROM t1;
+i
+1
+SELECT * FROM t2;
+i
+include/rpl_restart_server.inc [server_number=2]
+# On slave
+DO_DOMAIN_IDS (AFTER RESTART) :
+IGNORE_DOMAIN_IDS (AFTER RESTART) : 1
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=();
+include/start_slave.inc
+DO_DOMAIN_IDS (AFTER) :
+IGNORE_DOMAIN_IDS (AFTER) :
+SELECT * FROM t1;
+i
+1
+SELECT * FROM t2;
+i
+# On master
+SET @@session.gtid_domain_id= 0;
+DROP TABLE t1, t2;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_domain_id_filter.test b/mysql-test/suite/rpl/t/rpl_domain_id_filter.test
new file mode 100644
index 00000000000..1b03490c071
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter.test
@@ -0,0 +1,431 @@
+--source include/have_innodb.inc
+--source include/master-slave.inc
+
+#
+# Test for DO_DOMAIN_IDS=(M1, M2, ..) and IGNORE_DOMAIN_IDS=(N1, N2, ..)
+#
+
+--echo # On slave
+connection slave;
+call mtr.add_suppression("Both DO_DOMAIN_IDS & IGNORE_DOMAIN_IDS lists can't be non-empty at the same time");
+call mtr.add_suppression("DO_DOMAIN_IDS or IGNORE_DOMAIN_IDS lists can't be non-empty in non-GTID mode.*");
+
+--echo # On master
+connection master;
+SET @@session.gtid_domain_id= 1;
+SELECT @@session.gtid_domain_id;
+CREATE TABLE t1(i INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+
+##### Case 0 : When both DO_DOMAIN_IDS and IGNORE_DOMAIN_IDS are empty.
+SELECT * FROM t1;
+
+##### Case 1: When DO_DOMAIN_IDS is non-empty.
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# Replicate events belonging to "domain_id 1".
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On master
+connection master;
+# Lets change the session domain_id to 2(not in DO_DOMAIN_IDS).
+SET @@session.gtid_domain_id= 2;
+# Should get filtered out on slave.
+INSERT INTO t1 VALUES(2);
+# Change it back to 1 (in DO_DOMAIN_IDS).
+SET @@session.gtid_domain_id= 1;
+# Should get applied on slave.
+INSERT INTO t1 VALUES(3);
+
+SELECT * FROM t1;
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+SELECT * FROM t1;
+
+##### Case 2: When IGNORE_DOMAIN_IDS is non-empty.
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# Ignore events belonging to "domain_id 1".
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On master
+connection master;
+# @@session.gtid_domain_id = 1 (in IGNORE_DOMAIN_IDS)
+SELECT @@session.gtid_domain_id;
+# Should get filtered out on slave.
+INSERT INTO t1 VALUES(4);
+# Change it to 2 (not in IGNORE_DOMAIN_IDS).
+SET @@session.gtid_domain_id= 2;
+# Should get applied on slave.
+INSERT INTO t1 VALUES(5);
+
+SELECT * FROM t1;
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+SELECT * FROM t1;
+
+##### Case 3: When both DO_DOMAIN_IDS and IGNORE_DOMAIN_IDS are non-empty
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+--error ER_MASTER_INFO
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), IGNORE_DOMAIN_IDS=(2), MASTER_USE_GTID=slave_pos;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+##### Case 4: Multiple domain ids.
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# Replicate events belonging to "domain_id 1".
+CHANGE MASTER TO DO_DOMAIN_IDS=(4,4,5,1,7,7,7,1,1,2,6,8,1,4,5,5,9,3), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On master
+connection master;
+# @@session.gtid_domain_id = 1 (in DO_DOMAIN_IDS)
+SELECT @@session.gtid_domain_id;
+# Should get applied on slave.
+INSERT INTO t1 VALUES(8);
+# Change it to 7 (in DO_DOMAIN_IDS).
+SET @@session.gtid_domain_id= 7;
+# Should get applied on slave.
+INSERT INTO t1 VALUES(9);
+# Change it to 10 (no in DO_DOMAIN_IDS).
+SET @@session.gtid_domain_id= 10;
+# Following should get filtered out on slave.
+INSERT INTO t1 VALUES(10);
+INSERT INTO t1 VALUES(11);
+START TRANSACTION;
+INSERT INTO t1 VALUES(12);
+INSERT INTO t1 VALUES(13);
+COMMIT;
+INSERT INTO t1 VALUES(14);
+INSERT INTO t1 VALUES(15);
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+SELECT * FROM t1;
+
+##### Case 5: Seconds_Behind_Master
+--echo # On slave
+connection slave;
+--echo # Seconds_Behind_Master should be zero here because the slave is fully caught up and idle.
+--let $status_items= Seconds_Behind_Master
+--source include/show_slave_status.inc
+
+##### Case 6: Stop slave before a transaction (involving MyISAM and InnoDB
+# table) being filtered commits.
+
+--echo # On slave
+connection slave;
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# IGNORE_DOMAIN_IDS=(1)
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On master
+connection master;
+# following statements should not get filtered.
+SET @@session.gtid_domain_id=2;
+CREATE TABLE t2(i int) ENGINE=MYISAM;
+CREATE TABLE t3(i int) ENGINE=INNODB;
+
+SET @@session.gtid_domain_id=1;
+BEGIN;
+INSERT INTO t2 VALUES(1);
+INSERT INTO t3 VALUES(1);
+sync_slave_with_master;
+
+# Now switch to slave to stop replication.
+--echo # On slave
+connection slave;
+--source include/stop_slave.inc
+--source include/wait_for_slave_to_stop.inc
+
+# Back to master to finish the transaction.
+--echo # On master
+connection master;
+INSERT INTO t2 VALUES(2);
+INSERT INTO t3 VALUES(2);
+COMMIT;
+save_master_pos;
+
+# On slave to start replication.
+--echo # On slave
+connection slave;
+--source include/start_slave.inc
+sync_with_master;
+
+SELECT * FROM t2;
+SELECT * FROM t3;
+
+##### Case 7: Stop slave before a transaction (involving MyISAM and InnoDB
+# table) being filtered commits and start it back with filtering
+# disabled.
+
+--echo # On master
+connection master;
+SET @@session.gtid_domain_id=1;
+BEGIN;
+INSERT INTO t2 VALUES(3);
+INSERT INTO t3 VALUES(3);
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# Clear IGNORE_DOMAIN_IDS
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On master
+connection master;
+INSERT INTO t2 VALUES(4);
+INSERT INTO t3 VALUES(4);
+COMMIT;
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+SELECT * FROM t2;
+SELECT * FROM t3;
+
+##### Case 8: Stop slave into the middle of a transaction and start it back
+# with filtering enabled.
+
+--echo # On master
+connection master;
+SET @@session.gtid_domain_id=1;
+BEGIN;
+INSERT INTO t2 VALUES(5);
+INSERT INTO t3 VALUES(5);
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# IGNORE_DOMAIN_IDS(1)
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On master
+connection master;
+INSERT INTO t2 VALUES(6);
+INSERT INTO t3 VALUES(6);
+COMMIT;
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+SELECT * FROM t2;
+SELECT * FROM t3;
+
+##### Case 9: Initially filter out events belonging to domain_id=2 and then
+# remove the rule to check if event are not being filtered out.
+
+--echo # On slave
+connection slave;
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# IGNORE_DOMAIN_IDS(2)
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(2), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On master
+connection master;
+SET @@session.gtid_domain_id=2;
+BEGIN;
+INSERT INTO t2 VALUES(7);
+INSERT INTO t3 VALUES(7);
+COMMIT;
+sync_slave_with_master;
+
+# Clear the filter
+--echo # On slave
+connection slave;
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# IGNORE_DOMAIN_IDS()
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On master
+connection master;
+SET @@session.gtid_domain_id=2;
+BEGIN;
+INSERT INTO t2 VALUES(8);
+INSERT INTO t3 VALUES(8);
+COMMIT;
+sync_slave_with_master;
+
+# On slave
+connection slave;
+SELECT * FROM t2;
+SELECT * FROM t3;
+
+##### Case 10: Test CHANGE MASTER with various "incompatible" combinations.
+# On slave
+connection slave;
+--source include/stop_slave.inc
+
+# 10a: Both DO_DOMAIN_IDS & IGNORE_DOMAIN_IDS can't be non-empty at the same
+# time.
+
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+--error ER_MASTER_INFO
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS;
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS;
+--error ER_MASTER_INFO
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS;
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS;
+--error ER_MASTER_INFO
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS;
+
+# 10b: Neither DO_DOMAIN_IDS nor IGNORE_DOMAIN_IDS can be set when
+# MASTER_USE_GTID=NO
+
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# MASTER_USE_GTID can't be set to NO when either of IGNORE_DOMAIN_IDS or
+# DO_DOMAIN_IDS is non-empty.
+--error ER_MASTER_INFO
+CHANGE MASTER TO MASTER_USE_GTID=NO;
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=NO;
+--error ER_MASTER_INFO
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), MASTER_USE_GTID=NO;
+--error ER_MASTER_INFO
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=NO;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), DO_DOMAIN_IDS=(), MASTER_USE_GTID=SLAVE_POS;
+--source include/start_slave.inc
+sync_with_master;
+
+# Cleanup
+--echo # On master
+connection master;
+SET @@session.gtid_domain_id=2;
+DROP TABLE t1, t2, t3;
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+--source include/stop_slave.inc
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=();
+--source include/start_slave.inc
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test b/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test
new file mode 100644
index 00000000000..a28edfc0c83
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test
@@ -0,0 +1,399 @@
+--source include/have_debug.inc
+--source include/have_innodb.inc
+--source include/master-slave.inc
+
+--echo # On master
+connection master;
+SET @@session.gtid_domain_id= 1;
+SELECT @@session.gtid_domain_id;
+CREATE TABLE t1(i INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+
+call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*");
+
+--echo # Case 0 : Start slave with IGNORE_DOMAIN_IDS=(), then restart
+--echo # replication with IGNORE_DOMAIN_IDS=() after IO thread is
+--echo # killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_before_commit").
+
+SELECT * FROM t1;
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SET @@global.debug_dbug="+d,kill_slave_io_before_commit";
+
+--echo # On master
+connection master;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(3);
+COMMIT;
+save_master_pos;
+SELECT * FROM t1;
+
+--echo # On slave
+connection slave;
+--let $slave_io_errno= 1595
+--source include/wait_for_slave_io_error.inc
+SELECT * FROM t1;
+SET @@global.debug_dbug="-d";
+
+START SLAVE io_thread;
+--source include/wait_for_slave_io_to_start.inc
+sync_with_master;
+SELECT * FROM t1;
+
+--echo # Case 1 : Start slave with IGNORE_DOMAIN_IDS=(1), then restart
+--echo # replication with IGNORE_DOMAIN_IDS=(1) after IO thread is
+--echo # killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_before_commit").
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SET @@global.debug_dbug="+d,kill_slave_io_before_commit";
+
+--echo # On master
+connection master;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(4);
+INSERT INTO t1 VALUES(5);
+COMMIT;
+
+save_master_pos;
+SELECT * FROM t1;
+
+--echo # On slave
+connection slave;
+--let $slave_io_errno= 1595
+--source include/wait_for_slave_io_error.inc
+SELECT * FROM t1;
+SET @@global.debug_dbug="-d";
+
+START SLAVE io_thread;
+--source include/wait_for_slave_io_to_start.inc
+sync_with_master;
+SELECT * FROM t1;
+
+--echo # Case 2 : Start slave with IGNORE_DOMAIN_IDS=(), then restart
+--echo # replication with IGNORE_DOMAIN_IDS=(1) after IO thread is
+--echo # killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_before_commit").
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SET @@global.debug_dbug="+d,kill_slave_io_before_commit";
+
+--echo # On master
+connection master;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(6);
+INSERT INTO t1 VALUES(7);
+COMMIT; # IO thread gets killed here.
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(8);
+INSERT INTO t1 VALUES(9);
+COMMIT;
+
+SET @@session.gtid_domain_id= 2;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(10);
+INSERT INTO t1 VALUES(11);
+COMMIT;
+
+save_master_pos;
+SELECT * FROM t1;
+
+--echo # On slave
+connection slave;
+--let $slave_io_errno= 1595
+--source include/wait_for_slave_io_error.inc
+SELECT * FROM t1;
+
+SET @@global.debug_dbug="-d";
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SELECT * FROM t1;
+
+--echo # Case 3 : Start slave with IGNORE_DOMAIN_IDS=(1), then restart
+--echo # replication with IGNORE_DOMAIN_IDS=() after IO thread is
+--echo # killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_before_commit").
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SET @@global.debug_dbug="+d,kill_slave_io_before_commit";
+
+--echo # On master
+connection master;
+
+SET @@session.gtid_domain_id= 1;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(12);
+INSERT INTO t1 VALUES(13);
+COMMIT; # IO thread gets killed here.
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(14);
+INSERT INTO t1 VALUES(15);
+COMMIT;
+
+SET @@session.gtid_domain_id= 2;
+START TRANSACTION;
+INSERT INTO t1 VALUES(16);
+INSERT INTO t1 VALUES(17);
+COMMIT;
+
+save_master_pos;
+SELECT * FROM t1;
+
+--echo # On slave
+connection slave;
+--let $slave_io_errno= 1595
+--source include/wait_for_slave_io_error.inc
+SELECT * FROM t1;
+
+SET @@global.debug_dbug="-d";
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SELECT * FROM t1;
+
+--echo # Case 4 : Start slave with IGNORE_DOMAIN_IDS=(1), then restart
+--echo # replication with IGNORE_DOMAIN_IDS=() after IO thread is
+--echo # killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_after_2_events").
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SET @@global.debug_dbug="+d,kill_slave_io_after_2_events";
+
+--echo # On master
+connection master;
+
+SET @@session.gtid_domain_id= 1;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(18);
+INSERT INTO t1 VALUES(19); # IO thread gets killed here.
+COMMIT;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(20);
+INSERT INTO t1 VALUES(21);
+COMMIT;
+
+SET @@session.gtid_domain_id= 2;
+START TRANSACTION;
+INSERT INTO t1 VALUES(22);
+INSERT INTO t1 VALUES(23);
+COMMIT;
+
+save_master_pos;
+SELECT * FROM t1;
+
+--echo # On slave
+connection slave;
+--let $slave_io_errno= 1595
+--source include/wait_for_slave_io_error.inc
+SELECT * FROM t1;
+
+SET @@global.debug_dbug="-d";
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SELECT * FROM t1;
+
+--echo # Case 5 : Start slave with IGNORE_DOMAIN_IDS=(), then restart
+--echo # replication with IGNORE_DOMAIN_IDS=(1) after IO thread is
+--echo # killed due to DBUG_EXECUTE_IF("+d,kill_slave_io_after_2_events").
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SET @@global.debug_dbug="+d,kill_slave_io_after_2_events";
+
+--echo # On master
+connection master;
+
+SET @@session.gtid_domain_id= 1;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(24);
+INSERT INTO t1 VALUES(25); # IO thread gets killed here.
+COMMIT;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(26);
+INSERT INTO t1 VALUES(27);
+COMMIT;
+
+SET @@session.gtid_domain_id= 2;
+START TRANSACTION;
+INSERT INTO t1 VALUES(28);
+INSERT INTO t1 VALUES(29);
+COMMIT;
+
+save_master_pos;
+SELECT * FROM t1;
+
+--echo # On slave
+connection slave;
+--let $slave_io_errno= 1595
+--source include/wait_for_slave_io_error.inc
+SELECT * FROM t1;
+
+SET @@global.debug_dbug="-d";
+
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SELECT * FROM t1;
+
+# Cleanup
+--echo # On master
+connection master;
+DROP TABLE t1;
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+--source include/stop_slave.inc
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=();
+--source include/start_slave.inc
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test b/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test
new file mode 100644
index 00000000000..032dbfdd184
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test
@@ -0,0 +1,98 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+# Valgrind does not work well with test that crashes the server
+--source include/not_valgrind.inc
+--source include/master-slave.inc
+
+--echo # On master
+connection master;
+
+call mtr.add_suppression("mysqld: Table './mysql/gtid_slave_pos' is marked as crashed and should be repaired");
+call mtr.add_suppression("Checking table: './mysql/gtid_slave_pos'");
+call mtr.add_suppression("mysql.gtid_slave_pos: 1 client is using or hasn't closed the table properly");
+
+SET @@session.gtid_domain_id= 0;
+
+create table ti (a int auto_increment primary key) engine=innodb;
+create table tm (a int auto_increment primary key) engine=myisam;
+
+insert into ti set a=null;
+insert into tm set a=null;
+
+save_master_pos;
+
+--echo # On slave
+connection slave;
+sync_with_master;
+--source include/stop_slave.inc
+
+select * from ti;
+select * from tm;
+
+--echo # On master
+connection master;
+SET @@session.gtid_domain_id= 1;
+
+begin;
+insert into ti set a=null;
+insert into tm set a=null;
+commit;
+
+SET @@session.gtid_domain_id= 0;
+insert into ti set a=null;
+insert into tm set a=null;
+
+set @@global.debug_dbug="+d,crash_before_send_xid";
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+--echo # On slave
+connection slave;
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# IGNORE_DOMAIN_IDS=(1)
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On master
+connection master;
+--source include/wait_until_disconnected.inc
+--enable_reconnect
+--let $rpl_server_number=1
+--source include/rpl_start_server.inc
+#--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/wait_until_connected_again.inc
+--echo # Master has restarted successfully
+set @@global.debug_dbug="-d";
+save_master_pos;
+
+--echo # On slave
+--connection slave
+--source include/stop_slave.inc
+--source include/start_slave.inc
+sync_with_master;
+select * from ti;
+select * from tm;
+
+# Cleanup
+--echo # On master
+--connection master
+drop table ti;
+drop table tm;
+sync_slave_with_master;
+
+--echo # On slave
+--connection slave
+--source include/stop_slave.inc
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=NO;
+--source include/start_slave.inc
+
+--source include/rpl_end.inc
+
diff --git a/mysql-test/suite/rpl/t/rpl_domain_id_filter_parallel.test b/mysql-test/suite/rpl/t/rpl_domain_id_filter_parallel.test
new file mode 100644
index 00000000000..4a997dbdf52
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter_parallel.test
@@ -0,0 +1,221 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--let $rpl_topology=1->2
+--source include/rpl_init.inc
+
+--echo # On slave
+--connection server_2
+SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
+--source include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=10;
+
+##### Case 0 : When both DO_DOMAIN_IDS and IGNORE_DOMAIN_IDS are empty.
+
+--echo # On slave
+--connection server_2
+CHANGE MASTER TO master_use_gtid=slave_pos, DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=();
+--source include/start_slave.inc
+
+--echo # On master
+--connection server_1
+SELECT @@session.gtid_domain_id;
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
+CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=MyISAM;
+CREATE TABLE t2 (a int PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+--save_master_pos
+
+--echo # On slave
+--connection server_2
+--sync_with_master
+
+--echo # New connection 'con_temp1'
+# Block the table t1 to simulate a replicated query taking a long time.
+--connect (con_temp1,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
+LOCK TABLE t1 WRITE;
+
+--echo # On master
+--connection server_1
+SET @@session.gtid_domain_id=1;
+# This query will be blocked on the slave until UNLOCK TABLES.
+INSERT INTO t1 VALUES (2);
+SET @@session.gtid_domain_id=0;
+# These t2 queries can be replicated in parallel with the prior t1 query, as
+# they are in a separate replication domain.
+INSERT INTO t2 VALUES (2);
+INSERT INTO t2 VALUES (3);
+BEGIN;
+INSERT INTO t2 VALUES (4);
+INSERT INTO t2 VALUES (5);
+COMMIT;
+INSERT INTO t2 VALUES (6);
+
+--echo # On slave
+--connection server_2
+--let $wait_condition= SELECT COUNT(*) = 6 FROM t2
+--source include/wait_condition.inc
+
+SELECT * FROM t2 ORDER by a;
+
+--echo # On con_temp1
+--connection con_temp1
+SELECT * FROM t1;
+UNLOCK TABLES;
+
+--echo # On slave
+--connection server_2
+--let $wait_condition= SELECT COUNT(*) = 2 FROM t1
+--source include/wait_condition.inc
+
+SELECT * FROM t1 ORDER BY a;
+
+##### Case 1 : When DO_DOMAIN_IDS=(1)
+
+--echo # On slave
+--connection server_2
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# Replicate events belonging to "domain_id 1".
+CHANGE MASTER TO DO_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On slave
+--connection server_2
+--sync_with_master
+
+--echo # On con_temp1
+# Block the table t1 to simulate a replicated query taking a long time.
+--connection con_temp1
+LOCK TABLE t1 WRITE;
+
+--echo # On master
+--connection server_1
+SET @@session.gtid_domain_id=0;
+# This query will be blocked on the slave until UNLOCK TABLES.
+# But, since DO_DOMAIN_IDS=(1), it will be filtered out on slave.
+INSERT INTO t1 VALUES (3);
+
+SET @@session.gtid_domain_id=1;
+# These t2 queries can be replicated in parallel with the prior t1 query, as
+# they are in a separate replication domain.
+INSERT INTO t2 VALUES (7);
+INSERT INTO t2 VALUES (8);
+BEGIN;
+INSERT INTO t2 VALUES (9);
+INSERT INTO t2 VALUES (10);
+COMMIT;
+INSERT INTO t2 VALUES (11);
+
+--echo # On slave
+--connection server_2
+--let $wait_condition= SELECT COUNT(*) = 11 FROM t2
+--source include/wait_condition.inc
+
+SELECT * FROM t2 ORDER by a;
+
+--echo # On con_temp1
+--connection con_temp1
+SELECT * FROM t1;
+UNLOCK TABLES;
+
+--echo # On slave
+--connection server_2
+--let $wait_condition= SELECT COUNT(*) = 2 FROM t1
+--source include/wait_condition.inc
+
+SELECT * FROM t1 ORDER BY a;
+
+##### Case 2 : When IGNORE_DOMAIN_IDS=(1)
+
+--echo # On slave
+--connection server_2
+--source include/stop_slave.inc
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# Replicate events belonging to "domain_id 1".
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+--source include/start_slave.inc
+sync_with_master;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On slave
+--connection server_2
+--sync_with_master
+
+--echo # On con_temp1
+# Block the table t1 to simulate a replicated query taking a long time.
+--connection con_temp1
+LOCK TABLE t1 WRITE;
+
+--echo # On master
+--connection server_1
+SET @@session.gtid_domain_id=1;
+# This query will be blocked on the slave until UNLOCK TABLES. However, since
+# IGNORE_DOMAIN_IDS=(1), it will be filtered out on slave.
+INSERT INTO t1 VALUES (4);
+SET @@session.gtid_domain_id=0;
+# These t2 queries can be replicated in parallel with the prior t1 query, as
+# they are in a separate replication domain.
+INSERT INTO t2 VALUES (12);
+INSERT INTO t2 VALUES (13);
+BEGIN;
+INSERT INTO t2 VALUES (14);
+INSERT INTO t2 VALUES (15);
+COMMIT;
+INSERT INTO t2 VALUES (16);
+
+--echo # On slave
+--connection server_2
+--let $wait_condition= SELECT COUNT(*) = 16 FROM t2
+--source include/wait_condition.inc
+
+SELECT * FROM t2 ORDER by a;
+
+--echo # On con_temp1
+--connection con_temp1
+SELECT * FROM t1;
+UNLOCK TABLES;
+
+--echo # On slave
+--connection server_2
+--let $wait_condition= SELECT COUNT(*) = 2 FROM t1
+--source include/wait_condition.inc
+
+SELECT * FROM t1 ORDER BY a;
+SELECT * FROM t2;
+
+--echo # Restore original settings.
+--echo # On master
+--connection server_1
+SET @@session.gtid_domain_id=0;
+DROP TABLE t1, t2;
+--save_master_pos
+
+--echo # On slave
+--connection server_2
+--sync_with_master
+--source include/stop_slave.inc
+SET GLOBAL slave_parallel_threads= @old_parallel_threads;
+CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=();
+--source include/start_slave.inc
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_domain_id_filter_restart.test b/mysql-test/suite/rpl/t/rpl_domain_id_filter_restart.test
new file mode 100644
index 00000000000..e21700995bb
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter_restart.test
@@ -0,0 +1,79 @@
+--source include/master-slave.inc
+
+#
+# Test for domain-id based filter on slave restart in GTID-mode.
+#
+
+
+--echo # On slave
+connection slave;
+
+source include/stop_slave.inc;
+let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
+--echo IGNORE_DOMAIN_IDS (BEFORE) : $ignore_domain_ids_before
+
+# Ignore events belonging to "domain_id 1".
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
+source include/start_slave.inc;
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+--echo # On master
+connection master;
+SET @@session.gtid_domain_id= 0;
+CREATE TABLE t1(i INT);
+CREATE TABLE t2(i INT);
+
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+
+SET @@session.gtid_domain_id= 1;
+# the following will get filtered out.
+INSERT INTO t2 VALUES(1);
+SELECT * FROM t2;
+
+sync_slave_with_master;
+
+--echo # On slave
+connection slave;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+# restart the slave
+--let $rpl_server_number= 2
+--source include/rpl_restart_server.inc
+
+--echo # On slave
+# Replicate_Do_Domain_Ids/Replicate_Ignore_Domain_Ids should reinitialize
+# properly on restart.
+connection slave;
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER RESTART) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER RESTART) : $ignore_domain_ids_after
+
+# Now, lets clear IGNORE_DOMAIN_IDS.
+CHANGE MASTER TO IGNORE_DOMAIN_IDS=();
+--source include/start_slave.inc
+
+let $do_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
+let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
+--echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after
+--echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+--echo # On master
+connection master;
+SET @@session.gtid_domain_id= 0;
+DROP TABLE t1, t2;
+sync_slave_with_master;
+
+--source include/rpl_end.inc
+
diff --git a/sql/lex.h b/sql/lex.h
index 137790e6227..48bf6eb9c35 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -195,6 +195,7 @@ static SYMBOL symbols[] = {
{ "DIV", SYM(DIV_SYM)},
{ "DO", SYM(DO_SYM)},
{ "DOUBLE", SYM(DOUBLE_SYM)},
+ { "DO_DOMAIN_IDS", SYM(DO_DOMAIN_IDS_SYM)},
{ "DROP", SYM(DROP)},
{ "DUAL", SYM(DUAL_SYM)},
{ "DUMPFILE", SYM(DUMPFILE)},
@@ -274,6 +275,7 @@ static SYMBOL symbols[] = {
{ "IDENTIFIED", SYM(IDENTIFIED_SYM)},
{ "IF", SYM(IF_SYM)},
{ "IGNORE", SYM(IGNORE_SYM)},
+ { "IGNORE_DOMAIN_IDS", SYM(IGNORE_DOMAIN_IDS_SYM)},
{ "IGNORE_SERVER_IDS", SYM(IGNORE_SERVER_IDS_SYM)},
{ "IMPORT", SYM(IMPORT)},
{ "IN", SYM(IN_SYM)},
diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h
index 3e9e2fce25f..b203f34df5a 100644
--- a/sql/rpl_gtid.h
+++ b/sql/rpl_gtid.h
@@ -201,7 +201,7 @@ struct rpl_slave_state
(domain_id, server_id) pair.
This will be logged at the start of the next binlog file as a
Gtid_list_log_event; this way, it is easy to find the binlog file
- containing a gigen GTID, by simply scanning backwards from the newest
+ containing a given GTID, by simply scanning backwards from the newest
one until a lower seq_no is found in the Gtid_list_log_event at the
start of a binlog for the given domain_id and server_id.
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 055dd09ac5c..6df9c237904 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -109,12 +109,11 @@ Master_info::~Master_info()
@return -1 if first argument is less, 0 if it equal to, 1 if it is greater
than the second
*/
-int change_master_server_id_cmp(ulong *id1, ulong *id2)
+static int change_master_id_cmp(const void *id1, const void *id2)
{
- return *id1 < *id2? -1 : (*id1 > *id2? 1 : 0);
+ return (*(ulong *) id1 - *(ulong *) id2);
}
-
/**
Reports if the s_id server has been configured to ignore events
it generates with
@@ -132,12 +131,11 @@ bool Master_info::shall_ignore_server_id(ulong s_id)
{
if (likely(ignore_server_ids.elements == 1))
return (* (ulong*) dynamic_array_ptr(&ignore_server_ids, 0)) == s_id;
- else
+ else
return bsearch((const ulong *) &s_id,
ignore_server_ids.buffer,
ignore_server_ids.elements, sizeof(ulong),
- (int (*) (const void*, const void*)) change_master_server_id_cmp)
- != NULL;
+ change_master_id_cmp) != NULL;
}
void Master_info::clear_in_memory_info(bool all)
@@ -195,6 +193,46 @@ void init_master_log_pos(Master_info* mi)
DBUG_VOID_RETURN;
}
+/**
+ Parses the IO_CACHE for "key=" and returns the "key".
+
+ @param key [OUT] Key buffer
+ @param max_size [IN] Maximum buffer size
+ @param f [IN] IO_CACHE file
+
+ @retval 0 Either "key=" or '\n' found
+ @retval 1 EOF
+*/
+static int read_mi_key_from_file(char *key, int max_size, IO_CACHE *f)
+{
+ int i= 0, c;
+ char *last_p;
+
+ DBUG_ENTER("read_key_from_file");
+
+ while (((c= my_b_get(f)) != '\n') && (c != my_b_EOF))
+ {
+ last_p= key + i;
+
+ if (i < max_size)
+ {
+ if (c == '=')
+ {
+ /* We found '=', replace it by 0 and return. */
+ *last_p= 0;
+ DBUG_RETURN(0);
+ }
+ else
+ *last_p= c;
+ }
+ ++i;
+ }
+
+ if (c == my_b_EOF)
+ DBUG_RETURN(1);
+
+ DBUG_RETURN(0);
+}
enum {
LINES_IN_MASTER_INFO_WITH_SSL= 14,
@@ -499,20 +537,55 @@ file '%s')", fname);
}
/*
- Parse any extra key=value lines.
- Ignore unknown lines, to facilitate downgrades.
+ Parse any extra key=value lines. read_key_from_file() parses the file
+ for "key=" and returns the "key" if found. The "value" can then the
+ parsed on case by case basis. The "unknown" lines would be ignored to
+ facilitate downgrades.
*/
- while (!init_strvar_from_file(buf, sizeof(buf), &mi->file, 0))
+ while (!read_mi_key_from_file(buf, sizeof(buf), &mi->file))
{
- if (0 == strncmp(buf, STRING_WITH_LEN("using_gtid=")))
+ /* using_gtid */
+ if (!strncmp(buf, STRING_WITH_LEN("using_gtid")))
+ {
+ int val;
+ if (!init_intvar_from_file(&val, &mi->file, 0))
+ {
+ if (val == Master_info::USE_GTID_CURRENT_POS)
+ mi->using_gtid= Master_info::USE_GTID_CURRENT_POS;
+ else if (val == Master_info::USE_GTID_SLAVE_POS)
+ mi->using_gtid= Master_info::USE_GTID_SLAVE_POS;
+ else
+ mi->using_gtid= Master_info::USE_GTID_NO;
+ continue;
+ } else {
+ sql_print_error("Failed to initialize master info using_gtid");
+ goto errwithmsg;
+ }
+ }
+
+ /* DO_DOMAIN_IDS */
+ if (!strncmp(buf, STRING_WITH_LEN("do_domain_ids")))
{
- int val= atoi(buf + sizeof("using_gtid"));
- if (val == Master_info::USE_GTID_CURRENT_POS)
- mi->using_gtid= Master_info::USE_GTID_CURRENT_POS;
- else if (val == Master_info::USE_GTID_SLAVE_POS)
- mi->using_gtid= Master_info::USE_GTID_SLAVE_POS;
- else
- mi->using_gtid= Master_info::USE_GTID_NO;
+ if (mi->domain_id_filter.init_ids(&mi->file,
+ Domain_id_filter::DO_DOMAIN_IDS))
+ {
+ sql_print_error("Failed to initialize master info do_domain_ids");
+ goto errwithmsg;
+ }
+ continue;
+ }
+
+ /* IGNORE_DOMAIN_IDS */
+ if (!strncmp(buf, STRING_WITH_LEN("ignore_domain_ids")))
+ {
+ if (mi->domain_id_filter.init_ids(&mi->file,
+ Domain_id_filter::IGNORE_DOMAIN_IDS))
+ {
+ sql_print_error("Failed to initialize master info "
+ "ignore_domain_ids");
+ goto errwithmsg;
+ }
+ continue;
}
}
}
@@ -614,7 +687,7 @@ int flush_master_info(Master_info* mi,
if (err)
DBUG_RETURN(2);
}
-
+
/*
produce a line listing the total number and all the ignored server_id:s
*/
@@ -624,7 +697,7 @@ int flush_master_info(Master_info* mi,
(char *) my_malloc((sizeof(global_system_variables.server_id) * 3 + 1) *
(1 + mi->ignore_server_ids.elements), MYF(MY_WME));
if (!ignore_server_ids_buf)
- DBUG_RETURN(1);
+ DBUG_RETURN(1); /* error */
ulong cur_len= sprintf(ignore_server_ids_buf, "%u",
mi->ignore_server_ids.elements);
for (ulong i= 0; i < mi->ignore_server_ids.elements; i++)
@@ -635,6 +708,24 @@ int flush_master_info(Master_info* mi,
}
}
+ char *do_domain_ids_buf= 0, *ignore_domain_ids_buf= 0;
+
+ do_domain_ids_buf=
+ mi->domain_id_filter.as_string(Domain_id_filter::DO_DOMAIN_IDS);
+ if (do_domain_ids_buf == NULL)
+ {
+ err= 1; /* error */
+ goto done;
+ }
+
+ ignore_domain_ids_buf=
+ mi->domain_id_filter.as_string(Domain_id_filter::IGNORE_DOMAIN_IDS);
+ if (ignore_domain_ids_buf == NULL)
+ {
+ err= 1; /* error */
+ goto done;
+ }
+
/*
We flushed the relay log BEFORE the master.info file, because if we crash
now, we will get a duplicate event in the relay log at restart. If we
@@ -657,7 +748,9 @@ int flush_master_info(Master_info* mi,
my_b_printf(file,
"%u\n%s\n%s\n%s\n%s\n%s\n%d\n%d\n%d\n%s\n%s\n%s\n%s\n%s\n%d\n%s\n%s\n%s\n%s\n%d\n%s\n%s\n"
"\n\n\n\n\n\n\n\n\n\n\n"
- "using_gtid=%d\n",
+ "using_gtid=%d\n"
+ "do_domain_ids=%s\n"
+ "ignore_domain_ids=%s\n",
LINES_IN_MASTER_INFO,
mi->master_log_name, llstr(mi->master_log_pos, lbuf),
mi->host, mi->user,
@@ -666,16 +759,24 @@ int flush_master_info(Master_info* mi,
mi->ssl_cipher, mi->ssl_key, mi->ssl_verify_server_cert,
heartbeat_buf, "", ignore_server_ids_buf,
"", 0,
- mi->ssl_crl, mi->ssl_crlpath, mi->using_gtid);
- my_free(ignore_server_ids_buf);
+ mi->ssl_crl, mi->ssl_crlpath, mi->using_gtid,
+ do_domain_ids_buf, ignore_domain_ids_buf);
err= flush_io_cache(file);
- if (sync_masterinfo_period && !err &&
+ if (sync_masterinfo_period && !err &&
++(mi->sync_counter) >= sync_masterinfo_period)
{
err= my_sync(mi->fd, MYF(MY_WME));
mi->sync_counter= 0;
}
- DBUG_RETURN(-err);
+
+ /* Fix err; flush_io_cache()/my_sync() may return -1 */
+ err= (err != 0) ? 1 : 0;
+
+done:
+ my_free(ignore_server_ids_buf);
+ my_free(do_domain_ids_buf);
+ my_free(ignore_domain_ids_buf);
+ DBUG_RETURN(err);
}
@@ -1361,4 +1462,245 @@ bool Master_info_index::stop_all_slaves(THD *thd)
DBUG_RETURN(result);
}
+Domain_id_filter::Domain_id_filter() : m_filter(false)
+{
+ for (int i= DO_DOMAIN_IDS; i <= IGNORE_DOMAIN_IDS; i ++)
+ {
+ my_init_dynamic_array(&m_domain_ids[i], sizeof(ulong), 16, 16, MYF(0));
+ }
+}
+
+Domain_id_filter::~Domain_id_filter()
+{
+ for (int i= DO_DOMAIN_IDS; i <= IGNORE_DOMAIN_IDS; i ++)
+ {
+ delete_dynamic(&m_domain_ids[i]);
+ }
+}
+
+/**
+ Update m_filter flag for the current group by looking up its domain id in the
+ domain ids list. DO_DOMAIN_IDS list is only looked-up is both (do & ignore)
+ list are non-empty.
+*/
+void Domain_id_filter::do_filter(ulong domain_id)
+{
+ DYNAMIC_ARRAY *do_domain_ids= &m_domain_ids[DO_DOMAIN_IDS];
+ DYNAMIC_ARRAY *ignore_domain_ids= &m_domain_ids[IGNORE_DOMAIN_IDS];
+
+ if (do_domain_ids->elements > 0)
+ {
+ if (likely(do_domain_ids->elements == 1))
+ m_filter= ((* (ulong *) dynamic_array_ptr(do_domain_ids, 0))
+ != domain_id);
+ else
+ m_filter= (bsearch((const ulong *) &domain_id, do_domain_ids->buffer,
+ do_domain_ids->elements, sizeof(ulong),
+ change_master_id_cmp) == NULL);
+ }
+ else if (ignore_domain_ids->elements > 0)
+ {
+ if (likely(ignore_domain_ids->elements == 1))
+ m_filter= ((* (ulong *) dynamic_array_ptr(ignore_domain_ids, 0)) ==
+ domain_id);
+ else
+ m_filter= (bsearch((const ulong *) &domain_id, ignore_domain_ids->buffer,
+ ignore_domain_ids->elements, sizeof(ulong),
+ change_master_id_cmp) != NULL);
+ }
+ return;
+}
+
+/**
+ Reset m_filter. It should be called when IO thread receives COMMIT_EVENT or
+ XID_EVENT.
+*/
+void Domain_id_filter::reset_filter()
+{
+ m_filter= false;
+}
+
+/**
+ Update the do/ignore domain id filter lists.
+
+ @param do_ids [IN] domain ids to be kept
+ @param ignore_ids [IN] domain ids to be filtered out
+ @param using_gtid [IN] use GTID?
+
+ @retval false Success
+ true Error
+*/
+bool Domain_id_filter::update_ids(DYNAMIC_ARRAY *do_ids,
+ DYNAMIC_ARRAY *ignore_ids,
+ bool using_gtid)
+{
+ bool do_list_empty, ignore_list_empty;
+
+ if (do_ids)
+ {
+ do_list_empty= (do_ids->elements > 0) ? false : true;
+ } else {
+ do_list_empty= (m_domain_ids[DO_DOMAIN_IDS].elements > 0) ? false : true;
+ }
+
+ if (ignore_ids)
+ {
+ ignore_list_empty= (ignore_ids->elements > 0) ? false : true;
+ } else {
+ ignore_list_empty= (m_domain_ids[IGNORE_DOMAIN_IDS].elements > 0) ? false :
+ true;
+ }
+
+ if (!do_list_empty && !ignore_list_empty)
+ {
+ sql_print_error("Both DO_DOMAIN_IDS & IGNORE_DOMAIN_IDS lists can't be "
+ "non-empty at the same time");
+ return true;
+ }
+
+ if (using_gtid == Master_info::USE_GTID_NO &&
+ (!do_list_empty || !ignore_list_empty))
+ {
+ sql_print_error("DO_DOMAIN_IDS or IGNORE_DOMAIN_IDS lists can't be "
+ "non-empty in non-GTID mode (MASTER_USE_GTID=no)");
+ return true;
+ }
+
+ if (do_ids)
+ update_change_master_ids(do_ids, &m_domain_ids[DO_DOMAIN_IDS]);
+
+ if (ignore_ids)
+ update_change_master_ids(ignore_ids, &m_domain_ids[IGNORE_DOMAIN_IDS]);
+
+ m_filter= false;
+
+ return false;
+}
+
+/**
+ Serialize and store the ids from domain id lists into the thd's protocol
+ buffer.
+
+ @param thd [IN] thread handler
+
+ @retval void
+*/
+void Domain_id_filter::store_ids(THD *thd)
+{
+ for (int i= DO_DOMAIN_IDS; i <= IGNORE_DOMAIN_IDS; i ++)
+ {
+ prot_store_ids(thd, &m_domain_ids[i]);
+ }
+}
+
+/**
+ Initialize the given domain_id list (DYNAMIC_ARRAY) with the
+ space-separated list of numbers from the specified IO_CACHE where
+ the first number represents the total number of entries to follows.
+
+ @param f [IN] IO_CACHE file
+ @param type [IN] domain id list type
+
+ @retval false Success
+ true Error
+*/
+bool Domain_id_filter::init_ids(IO_CACHE *f, enum_list_type type)
+{
+ return init_dynarray_intvar_from_file(&m_domain_ids[type], f);
+}
+
+/**
+ Return the elements of the give domain id list type as string.
+
+ @param type [IN] domain id list type
+
+ @retval a string buffer storing the total number
+ of elements followed by the individual
+ elements (space-separated) in the
+ specified list.
+
+ Note: Its caller's responsibility to free the returned string buffer.
+*/
+char *Domain_id_filter::as_string(enum_list_type type)
+{
+ char *buf;
+ size_t sz;
+ DYNAMIC_ARRAY *ids= &m_domain_ids[type];
+
+ sz= (sizeof(ulong) * 3 + 1) * (1 + ids->elements);
+
+ if (!(buf= (char *) my_malloc(sz, MYF(MY_WME))))
+ return NULL;
+
+ // Store the total number of elements followed by the individual elements.
+ ulong cur_len= sprintf(buf, "%u", ids->elements);
+ sz-= cur_len;
+
+ for (uint i= 0; i < ids->elements; i++)
+ {
+ ulong domain_id;
+ get_dynamic(ids, (void *) &domain_id, i);
+ cur_len+= my_snprintf(buf + cur_len, sz, " %u", domain_id);
+ sz-= cur_len;
+ }
+ return buf;
+}
+
+void update_change_master_ids(DYNAMIC_ARRAY *new_ids, DYNAMIC_ARRAY *old_ids)
+{
+ reset_dynamic(old_ids);
+
+ /* bsearch requires an ordered list. */
+ sort_dynamic(new_ids, change_master_id_cmp);
+
+ for (uint i= 0; i < new_ids->elements; i++)
+ {
+ ulong id;
+ get_dynamic(new_ids, (void *) &id, i);
+
+ if (bsearch((const ulong *) &id, old_ids->buffer, old_ids->elements,
+ sizeof(ulong), change_master_id_cmp) == NULL)
+ {
+ insert_dynamic(old_ids, (ulong *) &id);
+ }
+ }
+ return;
+}
+
+/**
+ Serialize and store the ids from the given ids DYNAMIC_ARRAY into the thd's
+ protocol buffer.
+
+ @param thd [IN] thread handler
+ @param ids [IN] ids list
+
+ @retval void
+*/
+
+void prot_store_ids(THD *thd, DYNAMIC_ARRAY *ids)
+{
+ char buff[FN_REFLEN];
+ uint i, cur_len;
+
+ for (i= 0, buff[0]= 0, cur_len= 0; i < ids->elements; i++)
+ {
+ ulong id, len;
+ char dbuff[FN_REFLEN];
+ get_dynamic(ids, (void *) &id, i);
+ len= sprintf(dbuff, (i == 0 ? "%lu" : ", %lu"), id);
+ if (cur_len + len + 4 > FN_REFLEN)
+ {
+ /*
+ break the loop whenever remained space could not fit
+ ellipses on the next cycle
+ */
+ sprintf(dbuff + cur_len, "...");
+ break;
+ }
+ cur_len += sprintf(buff + cur_len, "%s", dbuff);
+ }
+ thd->protocol->store(buff, &my_charset_bin);
+ return;
+}
+
#endif /* HAVE_REPLICATION */
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index 7dbe6d9b534..5eacbc97a95 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -26,6 +26,111 @@
typedef struct st_mysql MYSQL;
+/**
+ Domain id based filter to handle DO_DOMAIN_IDS and IGNORE_DOMAIN_IDS used to
+ set filtering on replication slave based on event's GTID domain_id.
+*/
+class Domain_id_filter
+{
+private:
+ /*
+ Flag to tell whether the events in the current GTID group get written to
+ the relay log. It is set according to the domain_id based filtering rule
+ on every GTID_EVENT and reset at the end of current GTID event group.
+ */
+ bool m_filter;
+
+ /*
+ DO_DOMAIN_IDS (0):
+ Ignore all the events which do not belong to any of the domain ids in the
+ list.
+
+ IGNORE_DOMAIN_IDS (1):
+ Ignore the events which belong to one of the domain ids in the list.
+ */
+ DYNAMIC_ARRAY m_domain_ids[2];
+
+public:
+ /* domain id list types */
+ enum enum_list_type {
+ DO_DOMAIN_IDS= 0,
+ IGNORE_DOMAIN_IDS
+ };
+
+ Domain_id_filter();
+
+ ~Domain_id_filter();
+
+ /*
+ Returns whether the current group needs to be filtered.
+ */
+ bool is_group_filtered() { return m_filter; }
+
+ /*
+ Checks whether the group with the specified domain_id needs to be
+ filtered and updates m_filter flag accordingly.
+ */
+ void do_filter(ulong domain_id);
+
+ /*
+ Reset m_filter. It should be called when IO thread receives COMMIT_EVENT or
+ XID_EVENT.
+ */
+ void reset_filter();
+
+ /*
+ Update the do/ignore domain id filter lists.
+
+ @param do_ids [IN] domain ids to be kept
+ @param ignore_ids [IN] domain ids to be filtered out
+ @param using_gtid [IN] use GTID?
+
+ @retval false Success
+ true Error
+ */
+ bool update_ids(DYNAMIC_ARRAY *do_ids, DYNAMIC_ARRAY *ignore_ids,
+ bool using_gtid);
+
+ /*
+ Serialize and store the ids from domain id lists into the thd's protocol
+ buffer.
+
+ @param thd [IN] thread handler
+
+ @retval void
+ */
+ void store_ids(THD *thd);
+
+ /*
+ Initialize the given domain id list (DYNAMIC_ARRAY) with the
+ space-separated list of numbers from the specified IO_CACHE where
+ the first number is the total number of entries to follows.
+
+ @param f [IN] IO_CACHE file
+ @param type [IN] domain id list type
+
+ @retval false Success
+ true Error
+ */
+ bool init_ids(IO_CACHE *f, enum_list_type type);
+
+ /*
+ Return the elements of the give domain id list type as string.
+
+ @param type [IN] domain id list type
+
+ @retval a string buffer storing the total number
+ of elements followed by the individual
+ elements (space-separated) in the
+ specified list.
+
+ Note: Its caller's responsibility to free the returned string buffer.
+ */
+ char *as_string(enum_list_type type);
+
+};
+
+
/*****************************************************************************
Replication IO Thread
@@ -110,6 +215,13 @@ class Master_info : public Slave_reporting_capability
uint connect_retry;
#ifndef DBUG_OFF
int events_till_disconnect;
+
+ /*
+ The following are auxiliary DBUG variables used to kill IO thread in the
+ middle of a group/transaction (see "kill_slave_io_after_2_events").
+ */
+ bool dbug_do_disconnect;
+ int dbug_event_counter;
#endif
bool inited;
volatile bool abort_slave;
@@ -178,7 +290,11 @@ class Master_info : public Slave_reporting_capability
uint64 gtid_reconnect_event_skip_count;
/* gtid_event_seen is false until we receive first GTID event from master. */
bool gtid_event_seen;
+
+ /* domain-id based filter */
+ Domain_id_filter domain_id_filter;
};
+
int init_master_info(Master_info* mi, const char* master_info_fname,
const char* slave_info_fname,
bool abort_if_no_master_info_file,
@@ -187,8 +303,9 @@ void end_master_info(Master_info* mi);
int flush_master_info(Master_info* mi,
bool flush_relay_log_cache,
bool need_lock_relay_log);
-int change_master_server_id_cmp(ulong *id1, ulong *id2);
void copy_filter_setting(Rpl_filter* dst_filter, Rpl_filter* src_filter);
+void update_change_master_ids(DYNAMIC_ARRAY *new_ids, DYNAMIC_ARRAY *old_ids);
+void prot_store_ids(THD *thd, DYNAMIC_ARRAY *ids);
/*
Multi master are handled trough this struct.
diff --git a/sql/slave.cc b/sql/slave.cc
index 98ad3da90c2..c4c37dd9566 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1202,7 +1202,6 @@ int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
DBUG_RETURN(1);
}
-
/*
when moving these functions to mysys, don't forget to
remove slave.cc from libmysqld/CMakeLists.txt
@@ -1258,6 +1257,7 @@ int init_floatvar_from_file(float* var, IO_CACHE* f, float default_val)
going to ignore (to not log them in the relay log).
Items being read are supposed to be decimal output of values of a
type shorter or equal of @c long and separated by the single space.
+ It also used to restore DO_DOMAIN_IDS & IGNORE_DOMAIN_IDS lists.
@param arr @c DYNAMIC_ARRAY pointer to storage for servers id
@param f @c IO_CACHE pointer to the source file
@@ -1278,7 +1278,7 @@ int init_dynarray_intvar_from_file(DYNAMIC_ARRAY* arr, IO_CACHE* f)
if ((read_size= my_b_gets(f, buf_act, sizeof(buf))) == 0)
{
- return 0; // no line in master.info
+ DBUG_RETURN(0); // no line in master.info
}
if (read_size + 1 == sizeof(buf) && buf[sizeof(buf) - 2] != '\n')
{
@@ -2581,6 +2581,10 @@ static bool send_show_master_info_header(THD *thd, bool full,
field_list.push_back(new Item_empty_string("Using_Gtid",
sizeof("Current_Pos")-1));
field_list.push_back(new Item_empty_string("Gtid_IO_Pos", 30));
+ field_list.push_back(new Item_empty_string("Replicate_Do_Domain_Ids",
+ FN_REFLEN));
+ field_list.push_back(new Item_empty_string("Replicate_Ignore_Domain_Ids",
+ FN_REFLEN));
if (full)
{
field_list.push_back(new Item_return_int("Retried_transactions",
@@ -2762,29 +2766,7 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
// Last_SQL_Error
protocol->store(mi->rli.last_error().message, &my_charset_bin);
// Replicate_Ignore_Server_Ids
- {
- char buff[FN_REFLEN];
- ulong i, cur_len;
- for (i= 0, buff[0]= 0, cur_len= 0;
- i < mi->ignore_server_ids.elements; i++)
- {
- ulong s_id, slen;
- char sbuff[FN_REFLEN];
- get_dynamic(&mi->ignore_server_ids, (uchar*) &s_id, i);
- slen= sprintf(sbuff, (i==0? "%lu" : ", %lu"), s_id);
- if (cur_len + slen + 4 > FN_REFLEN)
- {
- /*
- break the loop whenever remained space could not fit
- ellipses on the next cycle
- */
- sprintf(buff + cur_len, "...");
- break;
- }
- cur_len += sprintf(buff + cur_len, "%s", sbuff);
- }
- protocol->store(buff, &my_charset_bin);
- }
+ prot_store_ids(thd, &mi->ignore_server_ids);
// Master_Server_id
protocol->store((uint32) mi->master_id);
// Master_Ssl_Crl
@@ -2798,6 +2780,10 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
mi->gtid_current_pos.to_string(&tmp);
protocol->store(tmp.ptr(), tmp.length(), &my_charset_bin);
}
+
+ // Replicate_Do_Domain_Ids & Replicate_Ignore_Domain_Ids
+ mi->domain_id_filter.store_ids(thd);
+
if (full)
{
protocol->store((uint32) mi->rli.retried_trans);
@@ -3784,6 +3770,7 @@ pthread_handler_t handle_slave_io(void *arg)
rpl_io_thread_info io_info;
#ifndef DBUG_OFF
uint retry_count_reg= 0, retry_count_dump= 0, retry_count_event= 0;
+ mi->dbug_do_disconnect= false;
#endif
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
my_thread_init();
@@ -5587,6 +5574,12 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
case GTID_EVENT:
{
+ DBUG_EXECUTE_IF("kill_slave_io_after_2_events",
+ {
+ mi->dbug_do_disconnect= true;
+ mi->dbug_event_counter= 2;
+ };);
+
uchar gtid_flag;
if (Gtid_log_event::peek(buf, event_len, checksum_alg,
@@ -5656,6 +5649,10 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
mi->last_queued_gtid= event_gtid;
mi->last_queued_gtid_standalone=
(gtid_flag & Gtid_log_event::FL_STANDALONE) != 0;
+
+ /* Should filter all the subsequent events in the current GTID group? */
+ mi->domain_id_filter.do_filter(event_gtid.domain_id);
+
++mi->events_queued_since_last_gtid;
inc_pos= event_len;
}
@@ -5663,6 +5660,47 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
default:
default_action:
+ DBUG_EXECUTE_IF("kill_slave_io_after_2_events",
+ {
+ if (mi->dbug_do_disconnect &&
+ (((uchar)buf[EVENT_TYPE_OFFSET] == QUERY_EVENT) ||
+ ((uchar)buf[EVENT_TYPE_OFFSET] == TABLE_MAP_EVENT))
+ && (--mi->dbug_event_counter == 0))
+ {
+ error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE;
+ mi->dbug_do_disconnect= false; /* Safety */
+ goto err;
+ }
+ };);
+
+ DBUG_EXECUTE_IF("kill_slave_io_before_commit",
+ {
+ if ((uchar)buf[EVENT_TYPE_OFFSET] == XID_EVENT ||
+ ((uchar)buf[EVENT_TYPE_OFFSET] == QUERY_EVENT &&
+ Query_log_event::peek_is_commit_rollback(buf, event_len,
+ checksum_alg)))
+ {
+ error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE;
+ goto err;
+ }
+ };);
+
+ if (mi->using_gtid != Master_info::USE_GTID_NO &&
+ mi->domain_id_filter.is_group_filtered() &&
+ mi->events_queued_since_last_gtid > 0 &&
+ ((mi->last_queued_gtid_standalone &&
+ !Log_event::is_part_of_group((Log_event_type)(uchar)
+ buf[EVENT_TYPE_OFFSET])) ||
+ (!mi->last_queued_gtid_standalone &&
+ ((uchar)buf[EVENT_TYPE_OFFSET] == XID_EVENT ||
+ ((uchar)buf[EVENT_TYPE_OFFSET] == QUERY_EVENT &&
+ Query_log_event::peek_is_commit_rollback(buf, event_len,
+ checksum_alg))))))
+ {
+ /* Reset the domain_id_filter flag. */
+ mi->domain_id_filter.reset_filter();
+ }
+
if (mi->using_gtid != Master_info::USE_GTID_NO && mi->gtid_event_seen)
{
if (unlikely(mi->gtid_reconnect_event_skip_count))
@@ -5765,7 +5803,15 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
(s_id != mi->master_id ||
/* for the master meta information is necessary */
(buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT &&
- buf[EVENT_TYPE_OFFSET] != ROTATE_EVENT))))
+ buf[EVENT_TYPE_OFFSET] != ROTATE_EVENT))) ||
+
+ /*
+ Check whether it needs to be filtered based on domain_id
+ (DO_DOMAIN_IDS/IGNORE_DOMAIN_IDS).
+ */
+ (mi->domain_id_filter.is_group_filtered() &&
+ Log_event::is_group_event((Log_event_type)(uchar)
+ buf[EVENT_TYPE_OFFSET])))
{
/*
Do not write it to the relay log.
@@ -5842,16 +5888,20 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
}
skip_relay_logging:
-
+
err:
if (unlock_data_lock)
mysql_mutex_unlock(&mi->data_lock);
DBUG_PRINT("info", ("error: %d", error));
- if (error)
+
+ /*
+ Do not print ER_SLAVE_RELAY_LOG_WRITE_FAILURE error here, as the caller
+ handle_slave_io() prints it on return.
+ */
+ if (error && error != ER_SLAVE_RELAY_LOG_WRITE_FAILURE)
mi->report(ERROR_LEVEL, error, NULL, ER(error),
- (error == ER_SLAVE_RELAY_LOG_WRITE_FAILURE)?
- "could not queue event from master" :
error_msg.ptr());
+
DBUG_RETURN(error);
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index dec46c61ef4..7aa6aae9289 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -217,6 +217,8 @@ typedef struct st_lex_server_options
struct LEX_MASTER_INFO
{
DYNAMIC_ARRAY repl_ignore_server_ids;
+ DYNAMIC_ARRAY repl_do_domain_ids;
+ DYNAMIC_ARRAY repl_ignore_domain_ids;
char *host, *user, *password, *log_file_name;
char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
char *ssl_crl, *ssl_crlpath;
@@ -234,7 +236,8 @@ struct LEX_MASTER_INFO
changed variable or if it should be left at old value
*/
enum {LEX_MI_UNCHANGED, LEX_MI_DISABLE, LEX_MI_ENABLE}
- ssl, ssl_verify_server_cert, heartbeat_opt, repl_ignore_server_ids_opt;
+ ssl, ssl_verify_server_cert, heartbeat_opt, repl_ignore_server_ids_opt,
+ repl_do_domain_ids_opt, repl_ignore_domain_ids_opt;
enum {
LEX_GTID_UNCHANGED, LEX_GTID_NO, LEX_GTID_CURRENT_POS, LEX_GTID_SLAVE_POS
} use_gtid_opt;
@@ -244,16 +247,25 @@ struct LEX_MASTER_INFO
bzero(this, sizeof(*this));
my_init_dynamic_array(&repl_ignore_server_ids,
sizeof(::server_id), 0, 16, MYF(0));
+ my_init_dynamic_array(&repl_do_domain_ids,
+ sizeof(ulong), 0, 16, MYF(0));
+ my_init_dynamic_array(&repl_ignore_domain_ids,
+ sizeof(ulong), 0, 16, MYF(0));
}
void reset()
{
delete_dynamic(&repl_ignore_server_ids);
+ /* Free all the array elements. */
+ delete_dynamic(&repl_do_domain_ids);
+ delete_dynamic(&repl_ignore_domain_ids);
+
host= user= password= log_file_name= ssl_key= ssl_cert= ssl_ca=
ssl_capath= ssl_cipher= relay_log_name= 0;
pos= relay_log_pos= server_id= port= connect_retry= 0;
heartbeat_period= 0;
ssl= ssl_verify_server_cert= heartbeat_opt=
- repl_ignore_server_ids_opt= LEX_MI_UNCHANGED;
+ repl_ignore_server_ids_opt= repl_do_domain_ids_opt=
+ repl_ignore_domain_ids_opt= LEX_MI_UNCHANGED;
gtid_pos_str= null_lex_str;
use_gtid_opt= LEX_GTID_UNCHANGED;
}
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 3e3adb2c5b4..edc24e45bdb 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -2429,6 +2429,16 @@ impossible position";
}
});
+ /* Abort server before it sends the XID_EVENT */
+ DBUG_EXECUTE_IF("crash_before_send_xid",
+ {
+ if (event_type == XID_EVENT)
+ {
+ my_sleep(2000000);
+ DBUG_SUICIDE();
+ }
+ });
+
/* reset transmit packet for next loop */
if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg))
goto err;
@@ -3224,6 +3234,8 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
char relay_log_info_file_tmp[FN_REFLEN];
my_off_t saved_log_pos;
LEX_MASTER_INFO* lex_mi= &thd->lex->mi;
+ DYNAMIC_ARRAY *do_ids, *ignore_ids;
+
DBUG_ENTER("change_master");
mysql_mutex_assert_owner(&LOCK_active_mi);
@@ -3355,33 +3367,30 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
mi->heartbeat_period= (float) MY_MIN(SLAVE_MAX_HEARTBEAT_PERIOD,
(slave_net_timeout/2.0));
mi->received_heartbeats= 0; // counter lives until master is CHANGEd
+
/*
- reset the last time server_id list if the current CHANGE MASTER
+ Reset the last time server_id list if the current CHANGE MASTER
is mentioning IGNORE_SERVER_IDS= (...)
*/
if (lex_mi->repl_ignore_server_ids_opt == LEX_MASTER_INFO::LEX_MI_ENABLE)
- reset_dynamic(&mi->ignore_server_ids);
- for (uint i= 0; i < lex_mi->repl_ignore_server_ids.elements; i++)
{
- ulong s_id;
- get_dynamic(&lex_mi->repl_ignore_server_ids, (uchar*) &s_id, i);
- if (s_id == global_system_variables.server_id && replicate_same_server_id)
+ /* Check if the list contains replicate_same_server_id */
+ for (uint i= 0; i < lex_mi->repl_ignore_server_ids.elements; i ++)
{
- my_error(ER_SLAVE_IGNORE_SERVER_IDS, MYF(0), static_cast<int>(s_id));
- ret= TRUE;
- goto err;
- }
- else
- {
- if (bsearch((const ulong *) &s_id,
- mi->ignore_server_ids.buffer,
- mi->ignore_server_ids.elements, sizeof(ulong),
- (int (*) (const void*, const void*))
- change_master_server_id_cmp) == NULL)
- insert_dynamic(&mi->ignore_server_ids, (uchar*) &s_id);
+ ulong s_id;
+ get_dynamic(&lex_mi->repl_ignore_server_ids, (uchar*) &s_id, i);
+ if (s_id == global_system_variables.server_id && replicate_same_server_id)
+ {
+ my_error(ER_SLAVE_IGNORE_SERVER_IDS, MYF(0), static_cast<int>(s_id));
+ ret= TRUE;
+ goto err;
+ }
}
+
+ /* All ok. Update the old server ids with the new ones. */
+ update_change_master_ids(&lex_mi->repl_ignore_server_ids,
+ &mi->ignore_server_ids);
}
- sort_dynamic(&mi->ignore_server_ids, (qsort_cmp) change_master_server_id_cmp);
if (lex_mi->ssl != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
mi->ssl= (lex_mi->ssl == LEX_MASTER_INFO::LEX_MI_ENABLE);
@@ -3437,6 +3446,27 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
lex_mi->relay_log_name || lex_mi->relay_log_pos)
mi->using_gtid= Master_info::USE_GTID_NO;
+ do_ids= ((lex_mi->repl_do_domain_ids_opt ==
+ LEX_MASTER_INFO::LEX_MI_ENABLE) ?
+ &lex_mi->repl_do_domain_ids : NULL);
+
+ ignore_ids= ((lex_mi->repl_ignore_domain_ids_opt ==
+ LEX_MASTER_INFO::LEX_MI_ENABLE) ?
+ &lex_mi->repl_ignore_domain_ids : NULL);
+
+ /*
+ Note: mi->using_gtid stores the previous state in case no MASTER_USE_GTID
+ is specified.
+ */
+ if (mi->domain_id_filter.update_ids(do_ids, ignore_ids, mi->using_gtid))
+ {
+ my_error(ER_MASTER_INFO, MYF(0),
+ (int) lex_mi->connection_name.length,
+ lex_mi->connection_name.str);
+ ret= TRUE;
+ goto err;
+ }
+
/*
If user did specify neither host nor port nor any log name nor any log
pos, i.e. he specified only user/password/master_connect_retry, he probably
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b374a9a2bef..986305a5420 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1103,6 +1103,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token DISTINCT /* SQL-2003-R */
%token DIV_SYM
%token DOUBLE_SYM /* SQL-2003-R */
+%token DO_DOMAIN_IDS_SYM
%token DO_SYM
%token DROP /* SQL-2003-R */
%token DUAL_SYM
@@ -1190,6 +1191,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token IDENTIFIED_SYM
%token IDENT_QUOTED
%token IF_SYM
+%token IGNORE_DOMAIN_IDS_SYM
%token IGNORE_SYM
%token IGNORE_SERVER_IDS_SYM
%token IMPORT
@@ -2228,6 +2230,14 @@ master_def:
{
Lex->mi.repl_ignore_server_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
}
+ | DO_DOMAIN_IDS_SYM EQ '(' do_domain_id_list ')'
+ {
+ Lex->mi.repl_do_domain_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
+ }
+ | IGNORE_DOMAIN_IDS_SYM EQ '(' ignore_domain_id_list ')'
+ {
+ Lex->mi.repl_ignore_domain_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
+ }
|
master_file_def
;
@@ -2244,6 +2254,30 @@ ignore_server_id:
insert_dynamic(&Lex->mi.repl_ignore_server_ids, (uchar*) &($1));
}
+do_domain_id_list:
+ /* Empty */
+ | do_domain_id
+ | do_domain_id_list ',' do_domain_id
+ ;
+
+do_domain_id:
+ ulong_num
+ {
+ insert_dynamic(&Lex->mi.repl_do_domain_ids, (uchar*) &($1));
+ }
+
+ignore_domain_id_list:
+ /* Empty */
+ | ignore_domain_id
+ | ignore_domain_id_list ',' ignore_domain_id
+ ;
+
+ignore_domain_id:
+ ulong_num
+ {
+ insert_dynamic(&Lex->mi.repl_ignore_domain_ids, (uchar*) &($1));
+ }
+
master_file_def:
MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys
{