Hi, Jeb
Attached file is commit for WL#3754 updated by your suggestions. Please
review.
p.s. commit email didn't sent again so will try fix it.
--
Serge Kozlov, QA Developer
MySQL AB, Moscow, Russia, www.mysql.com
Office:
Are you MySQL certified? www.mysql.com/certification
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2008/03/16 23:57:52+03:00 skozlov@stripped
# WL#3754
#
# mysql-test/include/circular_rpl_for_4_hosts_init.inc
# 2008/03/16 23:57:48+03:00 skozlov@stripped +130 -0
# The primitive for 4 hosts circular replication
#
# mysql-test/include/circular_rpl_for_4_hosts_init.inc
# 2008/03/16 23:57:48+03:00 skozlov@stripped +0 -0
#
# mysql-test/include/circular_rpl_for_4_hosts_sync.inc
# 2008/03/16 23:57:48+03:00 skozlov@stripped +23 -0
# The primitive for sync for 4 hosts circular replication
#
# mysql-test/include/circular_rpl_for_4_hosts_sync.inc
# 2008/03/16 23:57:48+03:00 skozlov@stripped +0 -0
#
# mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result
# 2008/03/16 23:57:49+03:00 skozlov@stripped +363 -0
# Result file
#
# mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result
# 2008/03/16 23:57:49+03:00 skozlov@stripped +0 -0
#
# mysql-test/suite/rpl/t/rpl_circular_for_4_hosts-master.opt
# 2008/03/16 23:57:49+03:00 skozlov@stripped +1 -0
# Options file
#
# mysql-test/suite/rpl/t/rpl_circular_for_4_hosts-master.opt
# 2008/03/16 23:57:49+03:00 skozlov@stripped +0 -0
#
# mysql-test/suite/rpl/t/rpl_circular_for_4_hosts-slave.opt
# 2008/03/16 23:57:49+03:00 skozlov@stripped +1 -0
# Options file
#
# mysql-test/suite/rpl/t/rpl_circular_for_4_hosts-slave.opt
# 2008/03/16 23:57:49+03:00 skozlov@stripped +0 -0
#
# mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
# 2008/03/16 23:57:49+03:00 skozlov@stripped +229 -0
# The test case
#
# mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
# 2008/03/16 23:57:49+03:00 skozlov@stripped +0 -0
#
diff -Nru a/mysql-test/include/circular_rpl_for_4_hosts_init.inc
b/mysql-test/include/circular_rpl_for_4_hosts_init.inc
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/include/circular_rpl_for_4_hosts_init.inc 2008-03-17 00:29:17 +03:00
@@ -0,0 +1,130 @@
+#############################################################
+#
+# Author: Serge Kozlov <skozlov@stripped>
+# Date: 03/11/2008
+# Purpose: Set up circular replication based on schema
+# A->B->C->D->A
+#
+# Notes:
+# 1. --slave-num=3 must be added to *-master.opt file
+# 2. Even the test uses new names for servers but file names
+# of log files are still old:
+# master_a -> master.[log|err]
+# master_b -> slave.[log|err]
+# master_c -> slave1.[log|err]
+# master_d -> slave2.[log|err]
+#
+#############################################################
+--source include/master-slave.inc
+
+#
+# Set up circular ring by schema A->B->C-D->A
+#
+
+--connection slave
+STOP SLAVE;
+RESET SLAVE;
+
+# master a
+--connection master
+disconnect master;
+connect (master_a,127.0.0.1,root,,test,$MASTER_MYPORT,);
+RESET MASTER;
+--disable_warnings
+STOP SLAVE;
+--enable_warnings
+RESET SLAVE;
+SET auto_increment_increment = 4;
+SET auto_increment_offset = 1;
+let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
+
+# master b
+--connection slave
+disconnect slave;
+connect (master_b,127.0.0.1,root,,test,$SLAVE_MYPORT,);
+RESET MASTER;
+RESET SLAVE;
+--replace_result $MASTER_MYPORT MASTER_A_PORT $_binlog_file MASTER_A_LOG_FILE
+--eval CHANGE MASTER TO
master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root',MASTER_LOG_FILE='$_binlog_file'
+SET auto_increment_increment = 4;
+SET auto_increment_offset = 2;
+let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
+
+# master c
+--connection slave1
+disconnect slave1;
+connect (master_c,127.0.0.1,root,,test,$SLAVE_MYPORT1,);
+RESET MASTER;
+--disable_warnings
+STOP SLAVE;
+--enable_warnings
+RESET SLAVE;
+--replace_result $SLAVE_MYPORT MASTER_B_PORT $_binlog_file MASTER_B_LOG_FILE
+--eval CHANGE MASTER TO
master_host='127.0.0.1',master_port=$SLAVE_MYPORT,master_user='root',MASTER_LOG_FILE='$_binlog_file'
+SET auto_increment_increment = 4;
+SET auto_increment_offset = 3;
+let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
+
+# master d
+connect (master_d,127.0.0.1,root,,test,$SLAVE_MYPORT2,);
+RESET MASTER;
+--disable_warnings
+STOP SLAVE;
+--enable_warnings
+RESET SLAVE;
+--replace_result $SLAVE_MYPORT1 MASTER_C_PORT $_binlog_file MASTER_C_LOG_FILE
+--eval CHANGE MASTER TO
master_host='127.0.0.1',master_port=$SLAVE_MYPORT1,master_user='root',MASTER_LOG_FILE='$_binlog_file'
+SET auto_increment_increment = 4;
+SET auto_increment_offset = 4;
+let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
+
+# master a
+--connection master_a
+--replace_result $SLAVE_MYPORT2 MASTER_D_PORT $_binlog_file MASTER_D_LOG_FILE
+--eval CHANGE MASTER TO
master_host='127.0.0.1',master_port=$SLAVE_MYPORT2,master_user='root',MASTER_LOG_FILE='$_binlog_file'
+
+
+
+# Check server_ids: they should be different
+--connection master_a
+let $_id_a= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
+SHOW VARIABLES LIKE 'auto_increment_%';
+--connection master_b
+let $_id_b= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
+SHOW VARIABLES LIKE 'auto_increment_%';
+--connection master_c
+let $_id_c= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
+SHOW VARIABLES LIKE 'auto_increment_%';
+--connection master_d
+let $_id_d= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
+SHOW VARIABLES LIKE 'auto_increment_%';
+--connection master_a
+let $_compared_ids= (($_id_a <> $_id_b) AND ($_id_a <> $_id_c) AND ($_id_a
<> $_id_d) AND ($_id_b <> $_id_c) AND ($_id_b <> $_id_d) AND ($_id_c
<> $_id_d)) AS a;
+let $_compared_ids_result= query_get_value(SELECT $_compared_ids, a, 1);
+--echo $_compared_ids_result
+
+# Start ring
+--connection master_a
+connect(slave,127.0.0.1,root,,test,$MASTER_MYPORT);
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+disconnect slave;
+
+--connection master_b
+connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT1);
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+disconnect slave;
+
+--connection master_c
+connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+disconnect slave;
+
+--connection master_d
+connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT2);
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+disconnect slave;
+
diff -Nru a/mysql-test/include/circular_rpl_for_4_hosts_sync.inc
b/mysql-test/include/circular_rpl_for_4_hosts_sync.inc
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/include/circular_rpl_for_4_hosts_sync.inc 2008-03-17 00:29:17 +03:00
@@ -0,0 +1,23 @@
+#############################################################
+#
+# Author: Serge Kozlov <skozlov@stripped>
+# Date: 03/11/2008
+# Purpose: Sync all hosts for circular replication based on
+# schema A->B->C->D->A
+#
+# Notes: see include/circular_rpl_for_4_hosts_init.inc
+#
+#############################################################
+
+# Make the full loop of sync
+--connection master_a
+--disable_query_log
+--sync_slave_with_master master_b
+--sync_slave_with_master master_c
+--sync_slave_with_master master_d
+--sync_slave_with_master master_a
+--sync_slave_with_master master_b
+--sync_slave_with_master master_c
+--save_master_pos
+--connection master_a
+--enable_query_log
diff -Nru a/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result
b/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result 2008-03-17 00:29:17 +03:00
@@ -0,0 +1,363 @@
+*** Set up circular ring by schema A->B->C-D->A ***
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+STOP SLAVE;
+RESET SLAVE;
+RESET MASTER;
+STOP SLAVE;
+RESET SLAVE;
+SET auto_increment_increment = 4;
+SET auto_increment_offset = 1;
+RESET MASTER;
+RESET SLAVE;
+CHANGE MASTER TO
master_host='127.0.0.1',master_port=MASTER_A_PORT,master_user='root',MASTER_LOG_FILE='MASTER_A_LOG_FILE';
+SET auto_increment_increment = 4;
+SET auto_increment_offset = 2;
+RESET MASTER;
+STOP SLAVE;
+RESET SLAVE;
+CHANGE MASTER TO
master_host='127.0.0.1',master_port=MASTER_B_PORT,master_user='root',MASTER_LOG_FILE='MASTER_B_LOG_FILE';
+SET auto_increment_increment = 4;
+SET auto_increment_offset = 3;
+RESET MASTER;
+STOP SLAVE;
+RESET SLAVE;
+CHANGE MASTER TO
master_host='127.0.0.1',master_port=MASTER_C_PORT,master_user='root',MASTER_LOG_FILE='MASTER_C_LOG_FILE';
+SET auto_increment_increment = 4;
+SET auto_increment_offset = 4;
+CHANGE MASTER TO
master_host='127.0.0.1',master_port=MASTER_D_PORT,master_user='root',MASTER_LOG_FILE='MASTER_D_LOG_FILE';
+SHOW VARIABLES LIKE 'auto_increment_%';
+Variable_name Value
+auto_increment_increment 4
+auto_increment_offset 1
+SHOW VARIABLES LIKE 'auto_increment_%';
+Variable_name Value
+auto_increment_increment 4
+auto_increment_offset 2
+SHOW VARIABLES LIKE 'auto_increment_%';
+Variable_name Value
+auto_increment_increment 4
+auto_increment_offset 3
+SHOW VARIABLES LIKE 'auto_increment_%';
+Variable_name Value
+auto_increment_increment 4
+auto_increment_offset 4
+1
+START SLAVE;
+START SLAVE;
+START SLAVE;
+START SLAVE;
+
+*** Preparing data ***
+CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b VARCHAR(20), PRIMARY KEY(a))
ENGINE=MyISAM;
+
+*** Testing schema A->B->C->D->A ***
+
+INSERT INTO t1(b) VALUES('A');
+INSERT INTO t1(b) VALUES('B');
+INSERT INTO t1(b) VALUES('C');
+INSERT INTO t1(b) VALUES('D');
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+Master A a b
+Master A 1 A
+Master A 2 B
+Master A 3 C
+Master A 4 D
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+Master B a b
+Master B 1 A
+Master B 2 B
+Master B 3 C
+Master B 4 D
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+Master C a b
+Master C 1 A
+Master C 2 B
+Master C 3 C
+Master C 4 D
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+Master D a b
+Master D 1 A
+Master D 2 B
+Master D 3 C
+Master D 4 D
+
+*** Testing schema A->B->D->A if C has failure ***
+
+* Do failure for C and then make new connection B->D *
+STOP SLAVE;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
+START SLAVE;
+INSERT INTO t1 VALUES(6, 'C');
+INSERT INTO t1(b) VALUES('B');
+INSERT INTO t1(b) VALUES('A');
+INSERT INTO t1(b) VALUES('D');
+
+* Data on servers (C failed) *
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+Master A a b
+Master A 1 A
+Master A 2 B
+Master A 3 C
+Master A 4 D
+Master A 5 A
+Master A 8 D
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+Master B a b
+Master B 1 A
+Master B 2 B
+Master B 3 C
+Master B 4 D
+Master B 5 A
+Master B 6 B
+Master B 8 D
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+Master C a b
+Master C 1 A
+Master C 2 B
+Master C 3 C
+Master C 4 D
+Master C 6 C
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+Master D a b
+Master D 1 A
+Master D 2 B
+Master D 3 C
+Master D 4 D
+Master D 8 D
+
+* Reconfigure replication to schema A->B->C->A *
+STOP SLAVE;
+STOP SLAVE;
+CHANGE MASTER TO
master_host='127.0.0.1',master_port=MASTER_B_PORT,master_user='root',master_log_file='LOG_FILE',master_log_pos=LOG_POS;
+START SLAVE;
+
+* Check data inserted before failure *
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+Master A a b
+Master A 1 A
+Master A 2 B
+Master A 3 C
+Master A 4 D
+Master A 5 A
+Master A 6 B
+Master A 8 D
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+Master B a b
+Master B 1 A
+Master B 2 B
+Master B 3 C
+Master B 4 D
+Master B 5 A
+Master B 6 B
+Master B 8 D
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+Master C a b
+Master C 1 A
+Master C 2 B
+Master C 3 C
+Master C 4 D
+Master C 6 C
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+Master D a b
+Master D 1 A
+Master D 2 B
+Master D 3 C
+Master D 4 D
+Master D 5 A
+Master D 6 B
+Master D 8 D
+
+* Check data inserted after failure *
+INSERT INTO t1(b) VALUES('A');
+INSERT INTO t1(b) VALUES('B');
+INSERT INTO t1(b) VALUES('D');
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+Master A a b
+Master A 1 A
+Master A 2 B
+Master A 3 C
+Master A 4 D
+Master A 5 A
+Master A 6 B
+Master A 8 D
+Master A 9 A
+Master A 10 B
+Master A 12 D
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+Master B a b
+Master B 1 A
+Master B 2 B
+Master B 3 C
+Master B 4 D
+Master B 5 A
+Master B 6 B
+Master B 8 D
+Master B 9 A
+Master B 10 B
+Master B 12 D
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+Master C a b
+Master C 1 A
+Master C 2 B
+Master C 3 C
+Master C 4 D
+Master C 6 C
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+Master D a b
+Master D 1 A
+Master D 2 B
+Master D 3 C
+Master D 4 D
+Master D 5 A
+Master D 6 B
+Master D 8 D
+Master D 9 A
+Master D 10 B
+Master D 12 D
+
+*** Testing restoring scheme A->B->C->D->A after failure ***
+
+* Remove wrong event from C and restore B->C->D *
+STOP SLAVE;
+DELETE FROM t1 WHERE a = 6;
+START SLAVE;
+RESET MASTER;
+RESET SLAVE;
+CHANGE MASTER TO
master_host='127.0.0.1',master_port=MASTER_C_PORT,master_user='root',master_log_file='LOG_FILE',master_log_pos=LOG_POS;
+START SLAVE;
+
+* Check data inserted before restoring schema A->B->C->D->A *
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+Master A a b
+Master A 1 A
+Master A 2 B
+Master A 3 C
+Master A 4 D
+Master A 5 A
+Master A 6 B
+Master A 8 D
+Master A 9 A
+Master A 10 B
+Master A 12 D
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+Master B a b
+Master B 1 A
+Master B 2 B
+Master B 3 C
+Master B 4 D
+Master B 5 A
+Master B 6 B
+Master B 8 D
+Master B 9 A
+Master B 10 B
+Master B 12 D
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+Master C a b
+Master C 1 A
+Master C 2 B
+Master C 3 C
+Master C 4 D
+Master C 5 A
+Master C 6 B
+Master C 8 D
+Master C 9 A
+Master C 10 B
+Master C 12 D
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+Master D a b
+Master D 1 A
+Master D 2 B
+Master D 3 C
+Master D 4 D
+Master D 5 A
+Master D 6 B
+Master D 8 D
+Master D 9 A
+Master D 10 B
+Master D 12 D
+
+* Check data inserted after restoring schema A->B->C->D->A *
+INSERT INTO t1(b) VALUES('A');
+INSERT INTO t1(b) VALUES('B');
+INSERT INTO t1(b) VALUES('C');
+INSERT INTO t1(b) VALUES('D');
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+Master A a b
+Master A 1 A
+Master A 2 B
+Master A 3 C
+Master A 4 D
+Master A 5 A
+Master A 6 B
+Master A 8 D
+Master A 9 A
+Master A 10 B
+Master A 12 D
+Master A 13 A
+Master A 14 B
+Master A 15 C
+Master A 16 D
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+Master B a b
+Master B 1 A
+Master B 2 B
+Master B 3 C
+Master B 4 D
+Master B 5 A
+Master B 6 B
+Master B 8 D
+Master B 9 A
+Master B 10 B
+Master B 12 D
+Master B 13 A
+Master B 14 B
+Master B 15 C
+Master B 16 D
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+Master C a b
+Master C 1 A
+Master C 2 B
+Master C 3 C
+Master C 4 D
+Master C 5 A
+Master C 6 B
+Master C 8 D
+Master C 9 A
+Master C 10 B
+Master C 12 D
+Master C 13 A
+Master C 14 B
+Master C 15 C
+Master C 16 D
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+Master D a b
+Master D 1 A
+Master D 2 B
+Master D 3 C
+Master D 4 D
+Master D 5 A
+Master D 6 B
+Master D 8 D
+Master D 9 A
+Master D 10 B
+Master D 12 D
+Master D 13 A
+Master D 14 B
+Master D 15 C
+Master D 16 D
+
+*** Clean up ***
+DROP TABLE t1;
+STOP SLAVE;
+RESET SLAVE;
+STOP SLAVE;
+RESET SLAVE;
+STOP SLAVE;
+RESET SLAVE;
+STOP SLAVE;
+RESET SLAVE;
diff -Nru a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts-master.opt
b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts-master.opt
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts-master.opt 2008-03-17 00:29:17
+03:00
@@ -0,0 +1 @@
+--slave-num=3 --log-slave-updates
diff -Nru a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts-slave.opt
b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts-slave.opt
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts-slave.opt 2008-03-17 00:29:17 +03:00
@@ -0,0 +1 @@
+--log-slave-updates
diff -Nru a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test 2008-03-17 00:29:17 +03:00
@@ -0,0 +1,229 @@
+#############################################################
+# Author: Serge Kozlov <skozlov@stripped>
+# Date: 03/12/2008
+# Purpose: Testing circular replication based on schema
+# A->B->C->D->A with using AUTO_INCREMENT_INCREMENT,
+# AUTO_INCREMENT_OFFSET variables and failover
+#############################################################
+
+# Set up circular ring and new names for servers
+--echo *** Set up circular ring by schema A->B->C-D->A ***
+--source include/circular_rpl_for_4_hosts_init.inc
+--echo
+
+# Preparing data.
+--echo *** Preparing data ***
+--connection master_a
+CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b VARCHAR(20), PRIMARY KEY(a))
ENGINE=MyISAM;
+--source include/circular_rpl_for_4_hosts_sync.inc
+--connection master_d
+--echo
+
+#
+# Testing
+#
+
+--echo *** Testing schema A->B->C->D->A ***
+--echo
+# insert data via all hosts
+--connection master_a
+INSERT INTO t1(b) VALUES('A');
+--sync_slave_with_master master_b
+INSERT INTO t1(b) VALUES('B');
+--sync_slave_with_master master_c
+INSERT INTO t1(b) VALUES('C');
+--sync_slave_with_master master_d
+INSERT INTO t1(b) VALUES('D');
+
+--source include/circular_rpl_for_4_hosts_sync.inc
+
+--connection master_a
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+--connection master_b
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+--connection master_c
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+--connection master_d
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+--echo
+
+--echo *** Testing schema A->B->D->A if C has failure ***
+--echo
+--echo * Do failure for C and then make new connection B->D *
+# Do not replicate next event from C
+--connection master_d
+connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT2);
+STOP SLAVE;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+disconnect slave;
+--connection master_c
+INSERT INTO t1 VALUES(6, 'C');
+--save_master_pos
+--connection master_b
+INSERT INTO t1(b) VALUES('B');
+# Wait while C will stop.
+--connection master_c
+--let $slave_param= Slave_SQL_Running
+--let $slave_param_value= No
+--source include/wait_for_slave_param.inc
+--connection master_a
+INSERT INTO t1(b) VALUES('A');
+--connection master_d
+INSERT INTO t1(b) VALUES('D');
+
+
+# Sync all servers except C
+--connection master_b
+let $wait_condition= SELECT COUNT(*)=3 FROM t1 WHERE a > 4;
+--source include/wait_condition.inc
+
+--echo
+--echo * Data on servers (C failed) *
+# Masters C,D shouldn't have correct data
+--connection master_a
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+--connection master_b
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+--connection master_c
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+--connection master_d
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+--echo
+
+--echo * Reconfigure replication to schema A->B->C->A *
+# Exclude Master C
+--connection master_c
+STOP SLAVE;
+--let $pos_c= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+--let $file_c= query_get_value(SHOW SLAVE STATUS, Master_Log_File, 1)
+--connection master_d
+STOP SLAVE;
+--replace_result $SLAVE_MYPORT MASTER_B_PORT $file_c LOG_FILE $pos_c LOG_POS
+--eval CHANGE MASTER TO
master_host='127.0.0.1',master_port=$SLAVE_MYPORT,master_user='root',master_log_file='$file_c',master_log_pos=$pos_c
+connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT2);
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+disconnect slave;
+--connection master_b
+--sync_slave_with_master master_d
+--echo
+
+--echo * Check data inserted before failure *
+--connection master_a
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+--connection master_b
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+--connection master_c
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+--connection master_d
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+--echo
+
+--echo * Check data inserted after failure *
+--connection master_a
+INSERT INTO t1(b) VALUES('A');
+--connection master_b
+INSERT INTO t1(b) VALUES('B');
+--connection master_d
+INSERT INTO t1(b) VALUES('D');
+--connection master_a
+
+--sync_slave_with_master master_b
+--sync_slave_with_master master_d
+--sync_slave_with_master master_a
+--sync_slave_with_master master_b
+
+--connection master_a
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+--connection master_b
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+--connection master_c
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+--connection master_d
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+--connection master_a
+
+--echo
+
+--echo *** Testing restoring scheme A->B->C->D->A after failure ***
+--echo
+# Master D will ignore a next event from C so that event will not be
+# distributed to other servers
+--echo * Remove wrong event from C and restore B->C->D *
+--connection master_d
+STOP SLAVE;
+--wait_for_slave_to_stop
+--connection master_c
+DELETE FROM t1 WHERE a = 6;
+START SLAVE;
+--connection master_b
+--sync_slave_with_master master_c
+RESET MASTER;
+--let $file_d= query_get_value(SHOW MASTER STATUS, File, 1)
+--let $pos_d= query_get_value(SHOW MASTER STATUS, Position, 1)
+--connection master_d
+RESET SLAVE;
+--replace_result $SLAVE_MYPORT1 MASTER_C_PORT $file_d LOG_FILE $pos_d LOG_POS
+--eval CHANGE MASTER TO
master_host='127.0.0.1',master_port=$SLAVE_MYPORT1,master_user='root',master_log_file='$file_d',master_log_pos=$pos_d
+START SLAVE;
+--connection master_c
+--sync_slave_with_master master_d
+--source include/circular_rpl_for_4_hosts_sync.inc
+
+--echo
+--echo * Check data inserted before restoring schema A->B->C->D->A *
+--connection master_a
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+--sync_slave_with_master master_b
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+--sync_slave_with_master master_c
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+--sync_slave_with_master master_d
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+--sync_slave_with_master master_a
+--echo
+
+--echo * Check data inserted after restoring schema A->B->C->D->A *
+--connection master_a
+INSERT INTO t1(b) VALUES('A');
+--connection master_b
+INSERT INTO t1(b) VALUES('B');
+--connection master_c
+INSERT INTO t1(b) VALUES('C');
+--connection master_d
+INSERT INTO t1(b) VALUES('D');
+--connection master_a
+
+--source include/circular_rpl_for_4_hosts_sync.inc
+
+--connection master_a
+SELECT 'Master A',a,b FROM t1 ORDER BY a,b;
+--connection master_b
+SELECT 'Master B',a,b FROM t1 ORDER BY a,b;
+--connection master_c
+SELECT 'Master C',a,b FROM t1 ORDER BY a,b;
+--connection master_d
+SELECT 'Master D',a,b FROM t1 ORDER BY a,b;
+--connection master_a
+
+--echo
+# Clean up
+--echo *** Clean up ***
+--connection master_a
+DROP TABLE t1;
+--source include/circular_rpl_for_4_hosts_sync.inc
+
+--connection master_a
+STOP SLAVE;
+RESET SLAVE;
+--connection master_b
+STOP SLAVE;
+RESET SLAVE;
+--connection master_c
+STOP SLAVE;
+RESET SLAVE;
+--connection master_d
+STOP SLAVE;
+RESET SLAVE;