mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
1fa1c7a8ce
This patch corrects a bug involving a LOAD DATA INFILE operation on a transactional table. It corrects a problem in the error handler moving the transactional table check and autocommit_or_rollback operation to the end of the error handler. An additional test case was added to detect this condition. mysql-test/r/rpl_loaddata.result: BUG#17233 : LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed This patch adds the results for the additional test for properly handling the duplicate key error on LOAD DATA INFILE. mysql-test/t/rpl_loaddata.test: BUG#17233 : LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed This patch adds an additional test to rpl_loaddata for handling the duplicate key error on LOAD DATA INFILE. sql/sql_load.cc: BUG#17233 : LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed This patch moves the check for a transactional table and rollback in the error handler for mysql_load(). The patch moves the transactional table check to the end of the error handler matching the implementation for other similar operations (see sql_insert).
166 lines
4.9 KiB
Text
166 lines
4.9 KiB
Text
# See if replication of a "LOAD DATA in an autoincrement column"
|
|
# Honours autoincrement values
|
|
# i.e. if the master and slave have the same sequence
|
|
#
|
|
# check replication of load data for temporary tables with additional
|
|
# parameters
|
|
#
|
|
# check if duplicate entries trigger an error (they should unless IGNORE or
|
|
# REPLACE was used on the master) (bug 571).
|
|
#
|
|
# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and
|
|
# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986)
|
|
|
|
source include/master-slave.inc;
|
|
source include/have_innodb.inc;
|
|
|
|
connection slave;
|
|
reset master;
|
|
connection master;
|
|
|
|
create table t1(a int not null auto_increment, b int, primary key(a) );
|
|
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
|
|
|
|
create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60));
|
|
load data infile '../std_data_ln/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;
|
|
|
|
save_master_pos;
|
|
connection slave;
|
|
sync_with_master;
|
|
|
|
select * from t1;
|
|
select * from t3;
|
|
# We want to be sure that LOAD DATA is in the slave's binlog.
|
|
# But we can't simply read this binlog, because as the slave has not been
|
|
# restarted for this test, the file_id is uncertain (would cause test
|
|
# failures). So instead, we test if the binlog looks long enough to
|
|
# contain LOAD DATA. Since 5.0.3 we assume that binlog of 1292 is ok.
|
|
# If LOAD DATA was not logged, the binlog would be shorter.
|
|
show master status;
|
|
|
|
connection master;
|
|
|
|
drop table t1;
|
|
drop table t2;
|
|
drop table t3;
|
|
create table t1(a int, b int, unique(b));
|
|
|
|
save_master_pos;
|
|
connection slave;
|
|
sync_with_master;
|
|
|
|
# See if slave stops when there's a duplicate entry for key error in LOAD DATA
|
|
|
|
insert into t1 values(1,10);
|
|
|
|
connection master;
|
|
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
|
|
|
|
save_master_pos;
|
|
connection slave;
|
|
# The SQL slave thread should be stopped now.
|
|
wait_for_slave_to_stop;
|
|
|
|
# Skip the bad event and see if error is cleared in SHOW SLAVE STATUS by START
|
|
# SLAVE, even though we are not executing any event (as sql_slave_skip_counter
|
|
# takes us directly to the end of the relay log).
|
|
|
|
set global sql_slave_skip_counter=1;
|
|
start slave;
|
|
sync_with_master;
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
|
--replace_column 1 # 8 # 9 # 23 # 33 #
|
|
show slave status;
|
|
|
|
# Trigger error again to test CHANGE MASTER
|
|
|
|
connection master;
|
|
set sql_log_bin=0;
|
|
delete from t1;
|
|
set sql_log_bin=1;
|
|
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
|
|
save_master_pos;
|
|
connection slave;
|
|
# The SQL slave thread should be stopped now.
|
|
# Exec_Master_Log_Pos should point to the start of Execute event
|
|
# for last load data.
|
|
wait_for_slave_to_stop;
|
|
|
|
# CHANGE MASTER and see if error is cleared in SHOW SLAVE STATUS.
|
|
stop slave;
|
|
change master to master_user='test';
|
|
change master to master_user='root';
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
|
--replace_column 1 # 8 # 9 # 23 # 33 #
|
|
show slave status;
|
|
|
|
# Trigger error again to test RESET SLAVE
|
|
|
|
set global sql_slave_skip_counter=1;
|
|
start slave;
|
|
sync_with_master;
|
|
connection master;
|
|
set sql_log_bin=0;
|
|
delete from t1;
|
|
set sql_log_bin=1;
|
|
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
|
|
save_master_pos;
|
|
connection slave;
|
|
# The SQL slave thread should be stopped now.
|
|
wait_for_slave_to_stop;
|
|
|
|
# RESET SLAVE and see if error is cleared in SHOW SLAVE STATUS.
|
|
stop slave;
|
|
reset slave;
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
|
--replace_column 1 # 8 # 9 # 23 # 33 #
|
|
show slave status;
|
|
|
|
# Finally, see if logging is done ok on master for a failing LOAD DATA INFILE
|
|
|
|
connection master;
|
|
reset master;
|
|
create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
|
|
unique(day)) engine=MyISAM; # no transactions
|
|
--error 1062
|
|
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields
|
|
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
|
|
'\n##\n' starting by '>' ignore 1 lines;
|
|
select * from t2;
|
|
save_master_pos;
|
|
connection slave;
|
|
start slave;
|
|
sync_with_master;
|
|
select * from t2;
|
|
|
|
# verify that if no error on slave, this is an error
|
|
|
|
alter table t2 drop key day;
|
|
connection master;
|
|
delete from t2;
|
|
--error 1062
|
|
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields
|
|
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
|
|
'\n##\n' starting by '>' ignore 1 lines;
|
|
connection slave;
|
|
wait_for_slave_to_stop;
|
|
drop table t2;
|
|
connection master;
|
|
drop table t2;
|
|
drop table t1;
|
|
|
|
# BUG#17233 LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed
|
|
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB;
|
|
|
|
--error 1062
|
|
LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1;
|
|
|
|
--disable warnings
|
|
DROP TABLE IF EXISTS t1;
|
|
--enable warnings
|
|
|
|
sync_with_master;
|
|
# End of 4.1 tests
|