mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
This is actually an existing problem in the old binlog implementation, and this patch is applicable to old binlog also. The problem is that RESET MASTER can run concurrently with binlog dump threads / connected slaves. This will remove the binlog from under the feet of the reader, which can cause all sorts of strange behaviour. This patch fixes the problem by disallowing to run RESET MASTER when dump threads (or other RESET MASTER or SHOW BINARY LOGS) are running. An error is thrown in this case, user must stop slaves and/or kill dump threads to make the RESET MASTER go through. A slave that connects in the middle of RESET MASTER will wait for it to complete. Fix a lot of test cases to kill any lingering dump threads before doing RESET MASTER, mostly just by sourcing include/kill_binlog_dump_threads.inc. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
145 lines
5.2 KiB
Plaintext
145 lines
5.2 KiB
Plaintext
include/master-slave.inc
|
||
[connection master]
|
||
select last_insert_id();
|
||
last_insert_id()
|
||
0
|
||
create table t1(a int not null auto_increment, b int, primary key(a) );
|
||
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
|
||
select last_insert_id();
|
||
last_insert_id()
|
||
1
|
||
create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60));
|
||
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines;
|
||
create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60));
|
||
insert into t3 select * from t2;
|
||
connection slave;
|
||
select * from t1;
|
||
a b
|
||
1 10
|
||
2 15
|
||
select * from t3;
|
||
day id category name
|
||
2003-02-22 2461 b a a a @ % ' " a
|
||
2003-03-22 2161 c asdf
|
||
2003-03-22 2416 a bbbbb
|
||
connection master;
|
||
drop table t1;
|
||
drop table t2;
|
||
drop table t3;
|
||
create table t1(a int, b int, unique(b));
|
||
connection slave;
|
||
insert into t1 values(1,10);
|
||
connection master;
|
||
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
|
||
connection slave;
|
||
call mtr.add_suppression("Slave SQL.*Error .Duplicate entry .10. for key .b.. on query.* error.* 1062");
|
||
call mtr.add_suppression("Slave SQL.*Query caused different errors on master and slave.*Error on master:.*error code=1062.*Error on slave:.*error.* 0");
|
||
include/wait_for_slave_sql_error_and_skip.inc [errno=1062]
|
||
include/check_slave_no_error.inc
|
||
connection master;
|
||
set sql_log_bin=0;
|
||
delete from t1;
|
||
set sql_log_bin=1;
|
||
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
|
||
connection slave;
|
||
include/wait_for_slave_sql_error.inc [errno=1062]
|
||
include/stop_slave_io.inc
|
||
change master to master_user='test';
|
||
change master to master_user='root';
|
||
include/check_slave_no_error.inc
|
||
set global sql_slave_skip_counter=1;
|
||
start slave;
|
||
connection master;
|
||
set sql_log_bin=0;
|
||
delete from t1;
|
||
set sql_log_bin=1;
|
||
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
|
||
connection slave;
|
||
include/wait_for_slave_sql_error.inc [errno=1062]
|
||
stop slave;
|
||
include/reset_slave.inc
|
||
Warnings:
|
||
Warning 1948 Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-14. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos
|
||
include/check_slave_no_error.inc
|
||
connection master;
|
||
include/kill_binlog_dump_threads.inc
|
||
reset master;
|
||
create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
|
||
unique(day)) engine=MyISAM;
|
||
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
|
||
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
|
||
'\n##\n' starting by '>' ignore 1 lines;
|
||
ERROR 23000: Duplicate entry '2003-03-22' for key 'day'
|
||
select * from t2;
|
||
day id category name
|
||
2003-02-22 2461 b a a a @ % ' " a
|
||
2003-03-22 2161 c asdf
|
||
connection slave;
|
||
start slave;
|
||
select * from t2;
|
||
day id category name
|
||
2003-02-22 2461 b a a a @ % ' " a
|
||
2003-03-22 2161 c asdf
|
||
alter table t2 drop key day;
|
||
connection master;
|
||
delete from t2;
|
||
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
|
||
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
|
||
'\n##\n' starting by '>' ignore 1 lines;
|
||
ERROR 23000: Duplicate entry '2003-03-22' for key 'day'
|
||
connection slave;
|
||
include/wait_for_slave_sql_error.inc [errno=0]
|
||
drop table t1, t2;
|
||
connection master;
|
||
drop table t1, t2;
|
||
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB;
|
||
LOAD DATA INFILE "../../std_data/words.dat" INTO TABLE t1;
|
||
ERROR 23000: Duplicate entry 'Aarhus' for key 'PRIMARY'
|
||
DROP TABLE t1;
|
||
include/rpl_reset.inc
|
||
connection master;
|
||
drop database if exists b48297_db1;
|
||
drop database if exists b42897_db2;
|
||
create database b48297_db1;
|
||
create database b42897_db2;
|
||
use b48297_db1;
|
||
CREATE TABLE t1 (c1 VARCHAR(256)) engine=MyISAM;;
|
||
use b42897_db2;
|
||
### assertion: works with cross-referenced database
|
||
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/std_data/loaddata5.dat' INTO TABLE b48297_db1.t1;
|
||
use b48297_db1;
|
||
### assertion: works with fully qualified name on current database
|
||
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/std_data/loaddata5.dat' INTO TABLE b48297_db1.t1;
|
||
### assertion: works without fully qualified name on current database
|
||
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/std_data/loaddata5.dat' INTO TABLE t1;
|
||
### create connection without default database
|
||
connect conn2,localhost,root,,*NO-ONE*;
|
||
connection conn2;
|
||
### assertion: works without stating the default database
|
||
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/std_data/loaddata5.dat' INTO TABLE b48297_db1.t1;
|
||
disconnect conn2;
|
||
connection master;
|
||
connection slave;
|
||
use b48297_db1;
|
||
include/diff_tables.inc [master:b48297_db1.t1, slave:b48297_db1.t1]
|
||
connection master;
|
||
DROP DATABASE b48297_db1;
|
||
DROP DATABASE b42897_db2;
|
||
connection slave;
|
||
include/rpl_reset.inc
|
||
connection master;
|
||
use test;
|
||
CREATE TABLE t1 (`key` TEXT, `text` TEXT);
|
||
LOAD DATA INFILE '../../std_data/loaddata2.dat' REPLACE INTO TABLE `t1` FIELDS TERMINATED BY ',';
|
||
SELECT * FROM t1;
|
||
key text
|
||
Field A 'Field B'
|
||
Field 1 'Field 2'
|
||
Field 3 'Field 4'
|
||
'Field 5' 'Field 6'
|
||
Field 6 'Field 7'
|
||
connection slave;
|
||
connection master;
|
||
DROP TABLE t1;
|
||
include/rpl_end.inc
|