[Commits] Rev 3903: MDEV-6593: domain_id based replication filters in lp:~maria-captains/maria/10.0-galera-6593

Nirbhay Choubey nirbhay at mariadb.com
Tue Nov 18 05:19:52 EET 2014


At lp:~maria-captains/maria/10.0-galera-6593

------------------------------------------------------------
revno: 3903
revision-id: nirbhay at mariadb.com-20141118031943-pjmobku49ypewkkg
parent: nirbhay at mariadb.com-20141107024939-jpfdcqfy7ht200hk
committer: Nirbhay Choubey <nirbhay at mariadb.com>
branch nick: 10.0-galera-6593
timestamp: Mon 2014-11-17 22:19:43 -0500
message:
  MDEV-6593: domain_id based replication filters
  
  More tests.
-------------- next part --------------
=== modified file 'mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result'
--- a/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result	2014-10-10 23:06:40 +0000
+++ b/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result	2014-11-18 03:19:43 +0000
@@ -12,6 +12,9 @@
 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
@@ -46,6 +49,9 @@
 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) : 
@@ -81,6 +87,9 @@
 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
@@ -138,6 +147,9 @@
 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
@@ -208,6 +220,192 @@
 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

=== modified file 'mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test'
--- a/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test	2014-10-10 23:06:40 +0000
+++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test	2014-11-18 03:19:43 +0000
@@ -16,7 +16,10 @@
 
 call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*");
 
-##### Case 0 : IGNORE_DOMAIN_IDS=() before and after slave io thread crash.
+--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
@@ -58,7 +61,9 @@
 sync_with_master;
 SELECT * FROM t1;
 
-##### Case 1 : IGNORE_DOMAIN_IDS=(1) before and after slave io thread crash.
+--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);
@@ -100,8 +105,9 @@
 sync_with_master;
 SELECT * FROM t1;
 
-##### Case 2 : Initially IGNORE_DOMAIN_IDS=(), after io thread crash slave is
-# restarted with IGNORE_DOMAIN_IDS=(1).
+--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);
@@ -126,7 +132,7 @@
 START TRANSACTION;
 INSERT INTO t1 VALUES(6);
 INSERT INTO t1 VALUES(7);
-COMMIT; # IO thread should crash here.
+COMMIT; # IO thread gets killed here.
 
 START TRANSACTION;
 INSERT INTO t1 VALUES(8);
@@ -168,8 +174,9 @@
 
 SELECT * FROM t1;
 
-##### Case 3 : Initially IGNORE_DOMAIN_IDS=(1), after io thread crash slave is
-# restarted with IGNORE_DOMAIN_IDS=().
+--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);
@@ -196,7 +203,7 @@
 START TRANSACTION;
 INSERT INTO t1 VALUES(12);
 INSERT INTO t1 VALUES(13);
-COMMIT; # IO thread should crash here.
+COMMIT; # IO thread gets killed here.
 
 START TRANSACTION;
 INSERT INTO t1 VALUES(14);
@@ -237,6 +244,146 @@
 
 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;

=== modified file 'sql/rpl_mi.h'
--- a/sql/rpl_mi.h	2014-11-07 02:49:39 +0000
+++ b/sql/rpl_mi.h	2014-11-18 03:19:43 +0000
@@ -215,6 +215,13 @@
   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;

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2014-11-07 02:49:39 +0000
+++ b/sql/slave.cc	2014-11-18 03:19:43 +0000
@@ -3792,6 +3792,7 @@
   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();
@@ -5603,6 +5604,12 @@
 
   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,
@@ -5683,8 +5690,33 @@
 
   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)
@@ -5695,11 +5727,7 @@
             Query_log_event::peek_is_commit_rollback(buf, event_len,
                                                      checksum_alg))))))
     {
-      DBUG_EXECUTE_IF("kill_slave_io_before_commit",
-                      {
-                        error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE;
-                        goto err;
-                      };);
+      /* Reset the domain_id_filter flag. */
       mi->domain_id_filter.reset_filter();
     }
 



More information about the commits mailing list