368 lines
11 KiB
Plaintext
368 lines
11 KiB
Plaintext
include/master-slave.inc
|
|
Warnings:
|
|
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
|
|
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
|
|
[connection master]
|
|
call mtr.add_suppression("Can.t find record in .t[12].* Error_code: MY-001032");
|
|
call mtr.add_suppression("Cannot delete or update a parent row: a foreign key constraint fails .* Error_code: MY-001451");
|
|
call mtr.add_suppression("Cannot add or update a child row: a foreign key constraint fails .* Error_code: MY-001452");
|
|
call mtr.add_suppression("Duplicate entry .1. for key .PRIMARY.* Error_code: MY-001062");
|
|
call mtr.add_suppression("The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
|
|
set @saved_slave_rows_search_algorithms= @@global.slave_rows_search_algorithms;
|
|
SET GLOBAL slave_rows_search_algorithms= 'INDEX_SCAN,TABLE_SCAN';
|
|
set @old_slave_exec_mode= @@global.slave_exec_mode;
|
|
set @@global.slave_exec_mode= IDEMPOTENT;
|
|
create table ti1 (b int primary key) engine=XENGINE;
|
|
create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
|
|
engine=XENGINE;
|
|
set foreign_key_checks=1 /* ensure the check */;
|
|
insert into ti1 values (1),(2),(3);
|
|
insert into ti2 set a=2, b=2;
|
|
include/sync_slave_sql_with_master.inc
|
|
select * from ti1 order by b /* must be (1),(2),(3) */;
|
|
b
|
|
1
|
|
2
|
|
3
|
|
insert into ti2 set a=1, b=1;
|
|
select * from ti2 order by b /* must be (1,1) (2,2) */;
|
|
a b
|
|
1 1
|
|
2 2
|
|
set @save_binlog_format= @@session.binlog_format;
|
|
set @@session.binlog_format= 'row';
|
|
delete from ti1 where b=1;
|
|
select * from ti1 order by b /* must be (2),(3) */;
|
|
b
|
|
2
|
|
3
|
|
include/sync_slave_sql_with_master.inc
|
|
select * from ti1 order by b /* must stays as were on master (1),(2),(3) */;
|
|
b
|
|
1
|
|
2
|
|
3
|
|
delete from ti1 where b=3;
|
|
insert into ti2 set a=3, b=3;
|
|
include/sync_slave_sql_with_master.inc
|
|
select * from ti2 order by b /* must be (1,1),(2,2) - not inserted */;
|
|
a b
|
|
1 1
|
|
2 2
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
set global slave_exec_mode='STRICT';
|
|
set global slave_exec_mode='IDEMPOTENT,STRICT';
|
|
ERROR 42000: Variable 'slave_exec_mode' can't be set to the value of 'IDEMPOTENT,STRICT'
|
|
select @@global.slave_exec_mode /* must be STRICT */;
|
|
@@global.slave_exec_mode
|
|
STRICT
|
|
*** foreign keys errors as above now forces to stop
|
|
set foreign_key_checks=0;
|
|
drop table ti2, ti1;
|
|
create table ti1 (b int primary key) engine=XENGINE;
|
|
create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
|
|
engine=XENGINE;
|
|
set foreign_key_checks=1 /* ensure the check */;
|
|
insert into ti1 values (1),(2),(3);
|
|
insert into ti2 set a=2, b=2;
|
|
include/sync_slave_sql_with_master.inc
|
|
select * from ti1 order by b /* must be (1),(2),(3) */;
|
|
b
|
|
1
|
|
2
|
|
3
|
|
*** conspire future problem
|
|
insert into ti2 set a=1, b=1;
|
|
select * from ti2 order by b /* must be (1,1) (2,2) */;
|
|
a b
|
|
1 1
|
|
2 2
|
|
delete from ti1 where b=1 /* offending delete event */;
|
|
select * from ti1 order by b /* must be (2),(3) */;
|
|
b
|
|
2
|
|
3
|
|
*** slave must stop (Trying to delete a referenced foreing key)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1451
|
|
select * from ti1 order by b /* must be (1),(2),(3) - not deleted */;
|
|
b
|
|
1
|
|
2
|
|
3
|
|
set foreign_key_checks= 0;
|
|
delete from ti2 where b=1;
|
|
set foreign_key_checks= 1;
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
include/sync_slave_sql_with_master.inc
|
|
*** conspire the following insert failure
|
|
*** conspire future problem
|
|
delete from ti1 where b=3;
|
|
insert into ti2 set a=3, b=3 /* offending write event */;
|
|
*** slave must stop (Trying to insert an invalid foreign key)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1452
|
|
select * from ti2 order by b /* must be (2,2) */;
|
|
a b
|
|
2 2
|
|
set foreign_key_checks= 0;
|
|
insert into ti1 set b=3;
|
|
set foreign_key_checks= 1;
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
include/sync_slave_sql_with_master.inc
|
|
select * from ti2 order by b /* must be (2,2),(3,3) */;
|
|
a b
|
|
2 2
|
|
3 3
|
|
*** other errors
|
|
*** conspiring query
|
|
insert into ti1 set b=1;
|
|
insert into ti1 set b=1 /* offending write event */;
|
|
*** slave must stop (Trying to insert a dupliacte key)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1062
|
|
set foreign_key_checks= 0;
|
|
delete from ti1 where b=1;
|
|
set foreign_key_checks= 1;
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
CREATE TABLE t1 (a INT PRIMARY KEY);
|
|
CREATE TABLE t2 (a INT);
|
|
INSERT INTO t1 VALUES (-1),(-2),(-3);
|
|
INSERT INTO t2 VALUES (-1),(-2),(-3);
|
|
include/sync_slave_sql_with_master.inc
|
|
DELETE FROM t1 WHERE a = -2;
|
|
DELETE FROM t2 WHERE a = -2;
|
|
DELETE FROM t1 WHERE a = -2;
|
|
*** slave must stop (Key was not found)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1032
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
DELETE FROM t2 WHERE a = -2;
|
|
*** slave must stop (Key was not found)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1032
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
UPDATE t1 SET a = 1 WHERE a = -1;
|
|
UPDATE t2 SET a = 1 WHERE a = -1;
|
|
UPDATE t1 SET a = 1 WHERE a = -1;
|
|
*** slave must stop (Key was not found)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1032
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
UPDATE t2 SET a = 1 WHERE a = -1;
|
|
*** slave must stop (Key was not found)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1032
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
SET @@global.slave_exec_mode= @old_slave_exec_mode;
|
|
drop table t1,t2,ti2,ti1;
|
|
include/sync_slave_sql_with_master.inc
|
|
set @@global.slave_exec_mode= @old_slave_exec_mode;
|
|
include/rpl_reset.inc
|
|
SET GLOBAL slave_rows_search_algorithms= 'INDEX_SCAN,HASH_SCAN';
|
|
set @old_slave_exec_mode= @@global.slave_exec_mode;
|
|
set @@global.slave_exec_mode= IDEMPOTENT;
|
|
create table ti1 (b int primary key) engine=XENGINE;
|
|
create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
|
|
engine=XENGINE;
|
|
set foreign_key_checks=1 /* ensure the check */;
|
|
insert into ti1 values (1),(2),(3);
|
|
insert into ti2 set a=2, b=2;
|
|
include/sync_slave_sql_with_master.inc
|
|
select * from ti1 order by b /* must be (1),(2),(3) */;
|
|
b
|
|
1
|
|
2
|
|
3
|
|
insert into ti2 set a=1, b=1;
|
|
select * from ti2 order by b /* must be (1,1) (2,2) */;
|
|
a b
|
|
1 1
|
|
2 2
|
|
set @save_binlog_format= @@session.binlog_format;
|
|
set @@session.binlog_format= 'row';
|
|
delete from ti1 where b=1;
|
|
select * from ti1 order by b /* must be (2),(3) */;
|
|
b
|
|
2
|
|
3
|
|
include/sync_slave_sql_with_master.inc
|
|
select * from ti1 order by b /* must stays as were on master (1),(2),(3) */;
|
|
b
|
|
1
|
|
2
|
|
3
|
|
delete from ti1 where b=3;
|
|
insert into ti2 set a=3, b=3;
|
|
include/sync_slave_sql_with_master.inc
|
|
select * from ti2 order by b /* must be (1,1),(2,2) - not inserted */;
|
|
a b
|
|
1 1
|
|
2 2
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
set global slave_exec_mode='STRICT';
|
|
set global slave_exec_mode='IDEMPOTENT,STRICT';
|
|
ERROR 42000: Variable 'slave_exec_mode' can't be set to the value of 'IDEMPOTENT,STRICT'
|
|
select @@global.slave_exec_mode /* must be STRICT */;
|
|
@@global.slave_exec_mode
|
|
STRICT
|
|
*** foreign keys errors as above now forces to stop
|
|
set foreign_key_checks=0;
|
|
drop table ti2, ti1;
|
|
create table ti1 (b int primary key) engine=XENGINE;
|
|
create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
|
|
engine=XENGINE;
|
|
set foreign_key_checks=1 /* ensure the check */;
|
|
insert into ti1 values (1),(2),(3);
|
|
insert into ti2 set a=2, b=2;
|
|
include/sync_slave_sql_with_master.inc
|
|
select * from ti1 order by b /* must be (1),(2),(3) */;
|
|
b
|
|
1
|
|
2
|
|
3
|
|
*** conspire future problem
|
|
insert into ti2 set a=1, b=1;
|
|
select * from ti2 order by b /* must be (1,1) (2,2) */;
|
|
a b
|
|
1 1
|
|
2 2
|
|
delete from ti1 where b=1 /* offending delete event */;
|
|
select * from ti1 order by b /* must be (2),(3) */;
|
|
b
|
|
2
|
|
3
|
|
*** slave must stop (Trying to delete a referenced foreing key)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1451
|
|
select * from ti1 order by b /* must be (1),(2),(3) - not deleted */;
|
|
b
|
|
1
|
|
2
|
|
3
|
|
set foreign_key_checks= 0;
|
|
delete from ti2 where b=1;
|
|
set foreign_key_checks= 1;
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
include/sync_slave_sql_with_master.inc
|
|
*** conspire the following insert failure
|
|
*** conspire future problem
|
|
delete from ti1 where b=3;
|
|
insert into ti2 set a=3, b=3 /* offending write event */;
|
|
*** slave must stop (Trying to insert an invalid foreign key)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1452
|
|
select * from ti2 order by b /* must be (2,2) */;
|
|
a b
|
|
2 2
|
|
set foreign_key_checks= 0;
|
|
insert into ti1 set b=3;
|
|
set foreign_key_checks= 1;
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
include/sync_slave_sql_with_master.inc
|
|
select * from ti2 order by b /* must be (2,2),(3,3) */;
|
|
a b
|
|
2 2
|
|
3 3
|
|
*** other errors
|
|
*** conspiring query
|
|
insert into ti1 set b=1;
|
|
insert into ti1 set b=1 /* offending write event */;
|
|
*** slave must stop (Trying to insert a dupliacte key)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1062
|
|
set foreign_key_checks= 0;
|
|
delete from ti1 where b=1;
|
|
set foreign_key_checks= 1;
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
CREATE TABLE t1 (a INT PRIMARY KEY);
|
|
CREATE TABLE t2 (a INT);
|
|
INSERT INTO t1 VALUES (-1),(-2),(-3);
|
|
INSERT INTO t2 VALUES (-1),(-2),(-3);
|
|
include/sync_slave_sql_with_master.inc
|
|
DELETE FROM t1 WHERE a = -2;
|
|
DELETE FROM t2 WHERE a = -2;
|
|
DELETE FROM t1 WHERE a = -2;
|
|
*** slave must stop (Key was not found)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1032
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
DELETE FROM t2 WHERE a = -2;
|
|
*** slave must stop (Key was not found)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1032
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
UPDATE t1 SET a = 1 WHERE a = -1;
|
|
UPDATE t2 SET a = 1 WHERE a = -1;
|
|
UPDATE t1 SET a = 1 WHERE a = -1;
|
|
*** slave must stop (Key was not found)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1032
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
set global slave_exec_mode='STRICT';
|
|
UPDATE t2 SET a = 1 WHERE a = -1;
|
|
*** slave must stop (Key was not found)
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
Last_SQL_Error
|
|
1032
|
|
set global slave_exec_mode='IDEMPOTENT';
|
|
start slave sql_thread;
|
|
include/sync_slave_sql_with_master.inc
|
|
SET @@global.slave_exec_mode= @old_slave_exec_mode;
|
|
drop table t1,t2,ti2,ti1;
|
|
include/sync_slave_sql_with_master.inc
|
|
set @@global.slave_exec_mode= @old_slave_exec_mode;
|
|
set @@global.slave_rows_search_algorithms= @saved_slave_rows_search_algorithms;
|
|
*** end of tests
|
|
include/rpl_end.inc
|