1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-02 09:41:40 +03:00

Merge skozlov@bk-internal.mysql.com:/home/bk/mysql-5.1-new-rpl

into  mysql.com:/home/ksm/mysql/WL3754/commit-mysql-5.1-new-rpl
This commit is contained in:
unknown
2008-04-25 00:47:36 +04:00
11 changed files with 1199 additions and 0 deletions

View File

@@ -0,0 +1,298 @@
*** 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(100), c INT NOT NULL, PRIMARY KEY(a)) ENGINE=MyISAM;
CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT, b VARCHAR(100), c INT NOT NULL, PRIMARY KEY(a)) ENGINE=InnoDB;
*** Testing schema A->B->C->D->A ***
INSERT INTO t1(b,c) VALUES('A',1);
INSERT INTO t1(b,c) VALUES('B',1);
INSERT INTO t1(b,c) VALUES('C',1);
INSERT INTO t1(b,c) VALUES('D',1);
SELECT 'Master A',a,b FROM t1 WHERE c = 1 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 WHERE c = 1 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 WHERE c = 1 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 WHERE c = 1 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',2);
INSERT INTO t1(b,c) VALUES('B',2);
INSERT INTO t1(b,c) VALUES('A',2);
INSERT INTO t1(b,c) VALUES('D',2);
* Data on servers (C failed) *
SELECT 'Master A',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
Master A a b
Master A 5 A
Master A 8 D
SELECT 'Master B',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
Master B a b
Master B 5 A
Master B 6 B
Master B 8 D
SELECT 'Master C',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
Master C a b
Master C 6 C
SELECT 'Master D',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
Master D a b
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 WHERE c = 2 ORDER BY a,b;
Master A a b
Master A 5 A
Master A 6 B
Master A 8 D
SELECT 'Master B',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
Master B a b
Master B 5 A
Master B 6 B
Master B 8 D
SELECT 'Master C',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
Master C a b
Master C 6 C
SELECT 'Master D',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
Master D a b
Master D 5 A
Master D 6 B
Master D 8 D
* Check data inserted after failure *
INSERT INTO t1(b,c) VALUES('A',3);
INSERT INTO t1(b,c) VALUES('B',3);
INSERT INTO t1(b,c) VALUES('D',3);
SELECT 'Master A',a,b FROM t1 WHERE c = 3 ORDER BY a,b;
Master A a b
Master A 9 A
Master A 10 B
Master A 12 D
SELECT 'Master B',a,b FROM t1 WHERE c = 3 ORDER BY a,b;
Master B a b
Master B 9 A
Master B 10 B
Master B 12 D
SELECT 'Master C',a,b FROM t1 WHERE c = 3 ORDER BY a,b;
Master C a b
SELECT 'Master D',a,b FROM t1 WHERE c = 3 ORDER BY a,b;
Master D a b
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 WHERE c IN (2,3) ORDER BY a,b;
Master A a b
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 WHERE c IN (2,3) ORDER BY a,b;
Master B a b
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 WHERE c IN (2,3) ORDER BY a,b;
Master C a b
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 WHERE c IN (2,3) ORDER BY a,b;
Master D a b
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,c) VALUES('A',4);
INSERT INTO t1(b,c) VALUES('B',4);
INSERT INTO t1(b,c) VALUES('C',4);
INSERT INTO t1(b,c) VALUES('D',4);
SELECT 'Master A',a,b FROM t1 WHERE c = 4 ORDER BY a,b;
Master A a b
Master A 13 A
Master A 14 B
Master A 15 C
Master A 16 D
SELECT 'Master B',a,b FROM t1 WHERE c = 4 ORDER BY a,b;
Master B a b
Master B 13 A
Master B 14 B
Master B 15 C
Master B 16 D
SELECT 'Master C',a,b FROM t1 WHERE c = 4 ORDER BY a,b;
Master C a b
Master C 13 A
Master C 14 B
Master C 15 C
Master C 16 D
SELECT 'Master D',a,b FROM t1 WHERE c = 4 ORDER BY a,b;
Master D a b
Master D 13 A
Master D 14 B
Master D 15 C
Master D 16 D
* Transactions with commits *
BEGIN;
BEGIN;
SELECT 'Master A',b,COUNT(*) FROM t2 WHERE c = 1 GROUP BY b ORDER BY b;
Master A b COUNT(*)
Master A A 100
Master A B 100
Master A C 100
Master A D 100
SELECT 'Master B',b,COUNT(*) FROM t2 WHERE c = 1 GROUP BY b ORDER BY b;
Master B b COUNT(*)
Master B A 100
Master B B 100
Master B C 100
Master B D 100
SELECT 'Master C',b,COUNT(*) FROM t2 WHERE c = 1 GROUP BY b ORDER BY b;
Master C b COUNT(*)
Master C A 100
Master C B 100
Master C C 100
Master C D 100
SELECT 'Master D',b,COUNT(*) FROM t2 WHERE c = 1 GROUP BY b ORDER BY b;
Master D b COUNT(*)
Master D A 100
Master D B 100
Master D C 100
Master D D 100
* Transactions with rollbacks *
BEGIN;
BEGIN;
SELECT 'Master A',b,COUNT(*) FROM t2 WHERE c = 2 GROUP BY b ORDER BY b;
Master A b COUNT(*)
Master A B 100
Master A D 100
SELECT 'Master B',b,COUNT(*) FROM t2 WHERE c = 2 GROUP BY b ORDER BY b;
Master B b COUNT(*)
Master B B 100
Master B D 100
SELECT 'Master C',b,COUNT(*) FROM t2 WHERE c = 2 GROUP BY b ORDER BY b;
Master C b COUNT(*)
Master C B 100
Master C D 100
SELECT 'Master D',b,COUNT(*) FROM t2 WHERE c = 2 GROUP BY b ORDER BY b;
Master D b COUNT(*)
Master D B 100
Master D D 100
*** Clean up ***
DROP TABLE t1,t2;
STOP SLAVE;
RESET SLAVE;
STOP SLAVE;
RESET SLAVE;
STOP SLAVE;
RESET SLAVE;
STOP SLAVE;
RESET SLAVE;

View File

@@ -0,0 +1 @@
--slave-num=3 --log-slave-updates --innodb

View File

@@ -0,0 +1 @@
--log-slave-updates --innodb

View File

@@ -0,0 +1,328 @@
#############################################################
# Author: Serge Kozlov <skozlov@mysql.com>
# 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
#############################################################
--source include/have_innodb.inc
# 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(100), c INT NOT NULL, PRIMARY KEY(a)) ENGINE=MyISAM;
CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT, b VARCHAR(100), c INT NOT NULL, PRIMARY KEY(a)) ENGINE=InnoDB;
--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,c) VALUES('A',1);
--sync_slave_with_master master_b
INSERT INTO t1(b,c) VALUES('B',1);
--sync_slave_with_master master_c
INSERT INTO t1(b,c) VALUES('C',1);
--sync_slave_with_master master_d
INSERT INTO t1(b,c) VALUES('D',1);
--source include/circular_rpl_for_4_hosts_sync.inc
--connection master_a
SELECT 'Master A',a,b FROM t1 WHERE c = 1 ORDER BY a,b;
--connection master_b
SELECT 'Master B',a,b FROM t1 WHERE c = 1 ORDER BY a,b;
--connection master_c
SELECT 'Master C',a,b FROM t1 WHERE c = 1 ORDER BY a,b;
--connection master_d
SELECT 'Master D',a,b FROM t1 WHERE c = 1 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',2);
--save_master_pos
--connection master_b
INSERT INTO t1(b,c) VALUES('B',2);
# 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,c) VALUES('A',2);
--connection master_d
INSERT INTO t1(b,c) VALUES('D',2);
# 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 WHERE c = 2 ORDER BY a,b;
--connection master_b
SELECT 'Master B',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
--connection master_c
SELECT 'Master C',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
--connection master_d
SELECT 'Master D',a,b FROM t1 WHERE c = 2 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 WHERE c = 2 ORDER BY a,b;
--connection master_b
SELECT 'Master B',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
--connection master_c
SELECT 'Master C',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
--connection master_d
SELECT 'Master D',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
--echo
--echo * Check data inserted after failure *
--connection master_a
INSERT INTO t1(b,c) VALUES('A',3);
--connection master_b
INSERT INTO t1(b,c) VALUES('B',3);
--connection master_d
INSERT INTO t1(b,c) VALUES('D',3);
--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 WHERE c = 3 ORDER BY a,b;
--connection master_b
SELECT 'Master B',a,b FROM t1 WHERE c = 3 ORDER BY a,b;
--connection master_c
SELECT 'Master C',a,b FROM t1 WHERE c = 3 ORDER BY a,b;
--connection master_d
SELECT 'Master D',a,b FROM t1 WHERE c = 3 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 WHERE c IN (2,3) ORDER BY a,b;
--sync_slave_with_master master_b
SELECT 'Master B',a,b FROM t1 WHERE c IN (2,3) ORDER BY a,b;
--sync_slave_with_master master_c
SELECT 'Master C',a,b FROM t1 WHERE c IN (2,3) ORDER BY a,b;
--sync_slave_with_master master_d
SELECT 'Master D',a,b FROM t1 WHERE c IN (2,3) 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,c) VALUES('A',4);
--connection master_b
INSERT INTO t1(b,c) VALUES('B',4);
--connection master_c
INSERT INTO t1(b,c) VALUES('C',4);
--connection master_d
INSERT INTO t1(b,c) VALUES('D',4);
--connection master_a
--source include/circular_rpl_for_4_hosts_sync.inc
--connection master_a
SELECT 'Master A',a,b FROM t1 WHERE c = 4 ORDER BY a,b;
--connection master_b
SELECT 'Master B',a,b FROM t1 WHERE c = 4 ORDER BY a,b;
--connection master_c
SELECT 'Master C',a,b FROM t1 WHERE c = 4 ORDER BY a,b;
--connection master_d
SELECT 'Master D',a,b FROM t1 WHERE c = 4 ORDER BY a,b;
--connection master_a
--echo
--echo * Transactions with commits *
# Testing mixing of transactions and regular inserts
--connection master_a
BEGIN;
--connection master_c
BEGIN;
let $counter= 100;
--connection master_a
--disable_query_log
while ($counter) {
--connection master_a
INSERT INTO t2(b,c) VALUES('A',1);
--connection master_b
INSERT INTO t2(b,c) VALUES('B',1);
--connection master_c
INSERT INTO t2(b,c) VALUES('C',1);
--connection master_d
INSERT INTO t2(b,c) VALUES('D',1);
dec $counter;
}
--connection master_a
COMMIT;
--connection master_c
COMMIT;
--connection master_a
--enable_query_log
--let $wait_condition= SELECT COUNT(*)=400 FROM t2 WHERE c = 1
--connection master_a
--source include/wait_condition.inc
--connection master_b
--source include/wait_condition.inc
--connection master_c
--source include/wait_condition.inc
--connection master_d
--source include/wait_condition.inc
--connection master_a
SELECT 'Master A',b,COUNT(*) FROM t2 WHERE c = 1 GROUP BY b ORDER BY b;
--connection master_b
SELECT 'Master B',b,COUNT(*) FROM t2 WHERE c = 1 GROUP BY b ORDER BY b;
--connection master_c
SELECT 'Master C',b,COUNT(*) FROM t2 WHERE c = 1 GROUP BY b ORDER BY b;
--connection master_d
SELECT 'Master D',b,COUNT(*) FROM t2 WHERE c = 1 GROUP BY b ORDER BY b;
--connection master_a
--echo
--echo * Transactions with rollbacks *
# Testing mixing of transactions with rollback and regular inserts
--connection master_a
BEGIN;
--connection master_c
BEGIN;
let $counter= 100;
--connection master_a
--disable_query_log
while ($counter) {
--connection master_a
INSERT INTO t2(b,c) VALUES('A',2);
--connection master_b
INSERT INTO t2(b,c) VALUES('B',2);
--connection master_c
INSERT INTO t2(b,c) VALUES('C',2);
--connection master_d
INSERT INTO t2(b,c) VALUES('D',2);
dec $counter;
}
--connection master_a
ROLLBACK;
--connection master_c
ROLLBACK;
--connection master_a
--enable_query_log
--let $wait_condition= SELECT COUNT(*)=200 FROM t2 WHERE c = 2
--connection master_a
--source include/wait_condition.inc
--connection master_b
--source include/wait_condition.inc
--connection master_c
--source include/wait_condition.inc
--connection master_d
--source include/wait_condition.inc
--connection master_a
SELECT 'Master A',b,COUNT(*) FROM t2 WHERE c = 2 GROUP BY b ORDER BY b;
--connection master_b
SELECT 'Master B',b,COUNT(*) FROM t2 WHERE c = 2 GROUP BY b ORDER BY b;
--connection master_c
SELECT 'Master C',b,COUNT(*) FROM t2 WHERE c = 2 GROUP BY b ORDER BY b;
--connection master_d
SELECT 'Master D',b,COUNT(*) FROM t2 WHERE c = 2 GROUP BY b ORDER BY b;
--connection master_a
--echo
# Clean up
--echo *** Clean up ***
--connection master_a
DROP TABLE t1,t2;
--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;