auto-merge
This commit is contained in:
commit
7c63b4ba5a
@ -5,6 +5,15 @@ reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
create table t1(a int not null auto_increment, b int, primary key(a));
|
||||
create table t2(a int not null auto_increment, b int, primary key(a)) engine=innodb;
|
||||
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
|
||||
start transaction;
|
||||
insert into t2(b) values (1);
|
||||
insert into t2(b) values (2);
|
||||
load data infile '../../std_data/rpl_loaddata.dat' into table t2;
|
||||
load data infile '../../std_data/rpl_loaddata.dat' into table t2;
|
||||
commit;
|
||||
Comparing tables master:test.t1 and slave:test.t1
|
||||
Comparing tables master:test.t2 and slave:test.t2
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
|
53
mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result
Normal file
53
mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result
Normal file
@ -0,0 +1,53 @@
|
||||
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;
|
||||
create table t1(a int not null auto_increment, b int, primary key(a)) engine=innodb;
|
||||
start transaction;
|
||||
insert into t1(b) values (1);
|
||||
insert into t1(b) values (2);
|
||||
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
|
||||
commit;
|
||||
show slave status;
|
||||
Slave_IO_State #
|
||||
Master_Host 127.0.0.1
|
||||
Master_User root
|
||||
Master_Port MASTER_MYPORT
|
||||
Connect_Retry 1
|
||||
Master_Log_File master-bin.000001
|
||||
Read_Master_Log_Pos #
|
||||
Relay_Log_File #
|
||||
Relay_Log_Pos #
|
||||
Relay_Master_Log_File master-bin.000001
|
||||
Slave_IO_Running Yes
|
||||
Slave_SQL_Running No
|
||||
Replicate_Do_DB
|
||||
Replicate_Ignore_DB
|
||||
Replicate_Do_Table
|
||||
Replicate_Ignore_Table
|
||||
Replicate_Wild_Do_Table
|
||||
Replicate_Wild_Ignore_Table
|
||||
Last_Errno 9
|
||||
Last_Error Error in Begin_load_query event: write to '../../tmp/SQL_LOAD.data' failed
|
||||
Skip_Counter 0
|
||||
Exec_Master_Log_Pos #
|
||||
Relay_Log_Space #
|
||||
Until_Condition None
|
||||
Until_Log_File
|
||||
Until_Log_Pos 0
|
||||
Master_SSL_Allowed No
|
||||
Master_SSL_CA_File
|
||||
Master_SSL_CA_Path
|
||||
Master_SSL_Cert
|
||||
Master_SSL_Cipher
|
||||
Master_SSL_Key
|
||||
Seconds_Behind_Master #
|
||||
Master_SSL_Verify_Server_Cert No
|
||||
Last_IO_Errno #
|
||||
Last_IO_Error #
|
||||
Last_SQL_Errno 9
|
||||
Last_SQL_Error Error in Begin_load_query event: write to '../../tmp/SQL_LOAD.data' failed
|
||||
drop table t1;
|
||||
drop table t1;
|
@ -0,0 +1,6 @@
|
||||
CHANGE MASTER TO MASTER_USER='root',
|
||||
MASTER_CONNECT_RETRY=1,
|
||||
MASTER_HOST='127.0.0.1',
|
||||
MASTER_PORT=MASTER_MYPORT;
|
||||
START SLAVE;
|
||||
Unable to use slave's temporary directory ../../../error - Can't read dir of '../../../error' (Errcode: 2)
|
@ -3,10 +3,11 @@
|
||||
# event while the "--secure-file-priv" option is set.
|
||||
#
|
||||
# The test is divided in two steps:
|
||||
# 1 - Creates a table and populates it through "LOAD DATA INFILE".
|
||||
# 1 - Creates tables and populates them through "LOAD DATA INFILE".
|
||||
# 2 - Compares the master and slave.
|
||||
##########################################################################
|
||||
source include/master-slave.inc;
|
||||
--source include/have_innodb.inc
|
||||
--source include/master-slave.inc
|
||||
|
||||
##########################################################################
|
||||
# Loading data
|
||||
@ -14,8 +15,17 @@ source include/master-slave.inc;
|
||||
connection master;
|
||||
|
||||
create table t1(a int not null auto_increment, b int, primary key(a));
|
||||
create table t2(a int not null auto_increment, b int, primary key(a)) engine=innodb;
|
||||
|
||||
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
|
||||
|
||||
start transaction;
|
||||
insert into t2(b) values (1);
|
||||
insert into t2(b) values (2);
|
||||
load data infile '../../std_data/rpl_loaddata.dat' into table t2;
|
||||
load data infile '../../std_data/rpl_loaddata.dat' into table t2;
|
||||
commit;
|
||||
|
||||
##########################################################################
|
||||
# Checking Consistency
|
||||
##########################################################################
|
||||
@ -25,11 +35,16 @@ let $diff_table_1=master:test.t1;
|
||||
let $diff_table_2=slave:test.t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
let $diff_table_1=master:test.t2;
|
||||
let $diff_table_2=slave:test.t2;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
##########################################################################
|
||||
# Clean up
|
||||
##########################################################################
|
||||
connection master;
|
||||
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
|
||||
sync_slave_with_master;
|
||||
|
@ -0,0 +1 @@
|
||||
--loose-debug=d,remove_slave_load_file_before_write
|
49
mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test
Normal file
49
mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test
Normal file
@ -0,0 +1,49 @@
|
||||
##########################################################################
|
||||
# This test verifies if the slave fails gracefully when the temporary
|
||||
# file used to load data is removed while it is about to be used it.
|
||||
# Similar errors are caught if the temporary directory is removed.
|
||||
#
|
||||
# Steps:
|
||||
# 1 - Creates a table and populates it through "LOAD DATA INFILE".
|
||||
# 2 - Catches error.
|
||||
##########################################################################
|
||||
--source include/have_binlog_format_mixed_or_statement.inc
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_debug.inc
|
||||
--source include/master-slave.inc
|
||||
--source include/not_embedded.inc
|
||||
|
||||
##########################################################################
|
||||
# Loading data
|
||||
##########################################################################
|
||||
connection master;
|
||||
|
||||
create table t1(a int not null auto_increment, b int, primary key(a)) engine=innodb;
|
||||
|
||||
start transaction;
|
||||
insert into t1(b) values (1);
|
||||
insert into t1(b) values (2);
|
||||
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
|
||||
commit;
|
||||
|
||||
##########################################################################
|
||||
# Catch Error
|
||||
##########################################################################
|
||||
connection slave;
|
||||
source include/wait_for_slave_sql_to_stop.inc;
|
||||
|
||||
--replace_result $MASTER_MYPORT MASTER_MYPORT
|
||||
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
|
||||
--replace_regex /SQL_LOAD-[0-9]-[0-9]-[0-9]*/SQL_LOAD/
|
||||
query_vertical show slave status;
|
||||
|
||||
##########################################################################
|
||||
# Clean up
|
||||
##########################################################################
|
||||
connection master;
|
||||
|
||||
drop table t1;
|
||||
|
||||
connection slave;
|
||||
|
||||
drop table t1;
|
@ -0,0 +1 @@
|
||||
--slave-load-tmpdir=../../../error
|
24
mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test
Normal file
24
mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test
Normal file
@ -0,0 +1,24 @@
|
||||
##########################################################################
|
||||
# This test verifies if the start slave fails gracefuly when an
|
||||
# invalid directory is used to set --slave-load-tmpdir.
|
||||
##########################################################################
|
||||
--source include/have_log_bin.inc
|
||||
--source include/not_embedded.inc
|
||||
|
||||
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
|
||||
connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,);
|
||||
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
|
||||
connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,);
|
||||
|
||||
connection slave;
|
||||
|
||||
--replace_result $MASTER_MYPORT MASTER_MYPORT
|
||||
eval CHANGE MASTER TO MASTER_USER='root',
|
||||
MASTER_CONNECT_RETRY=1,
|
||||
MASTER_HOST='127.0.0.1',
|
||||
MASTER_PORT=$MASTER_MYPORT;
|
||||
START SLAVE;
|
||||
|
||||
source include/wait_for_slave_sql_to_stop.inc;
|
||||
let $error=query_get_value("show slave status", Last_SQL_Error, 1);
|
||||
echo $error;
|
@ -382,7 +382,7 @@ static void cleanup_load_tmpdir()
|
||||
uint i;
|
||||
char fname[FN_REFLEN], prefbuf[31], *p;
|
||||
|
||||
if (!(dirp=my_dir(slave_load_tmpdir,MYF(MY_WME))))
|
||||
if (!(dirp=my_dir(slave_load_tmpdir,MYF(0))))
|
||||
return;
|
||||
|
||||
/*
|
||||
@ -6175,6 +6175,12 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli)
|
||||
thd_proc_info(thd, proc_info);
|
||||
if (get_create_or_append())
|
||||
{
|
||||
/*
|
||||
Usually lex_start() is called by mysql_parse(), but we need it here
|
||||
as the present method does not call mysql_parse().
|
||||
*/
|
||||
lex_start(thd);
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
my_delete(fname, MYF(0)); // old copy may exist already
|
||||
if ((fd= my_create(fname, CREATE_MODE,
|
||||
O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
|
||||
@ -6194,6 +6200,10 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli)
|
||||
get_type_str(), fname);
|
||||
goto err;
|
||||
}
|
||||
|
||||
DBUG_EXECUTE_IF("remove_slave_load_file_before_write",
|
||||
my_close(fd,MYF(0)); fd= -1; my_delete(fname, MYF(0)););
|
||||
|
||||
if (my_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP)))
|
||||
{
|
||||
rli->report(ERROR_LEVEL, my_errno,
|
||||
|
43
sql/slave.cc
43
sql/slave.cc
@ -2632,6 +2632,41 @@ err:
|
||||
DBUG_RETURN(0); // Can't return anything here
|
||||
}
|
||||
|
||||
/*
|
||||
Check the temporary directory used by commands like
|
||||
LOAD DATA INFILE.
|
||||
*/
|
||||
static
|
||||
int check_temp_dir(char* tmp_dir, char *tmp_file)
|
||||
{
|
||||
int fd;
|
||||
MY_DIR *dirp;
|
||||
|
||||
DBUG_ENTER("check_temp_dir");
|
||||
|
||||
/*
|
||||
Check if the directory exists.
|
||||
*/
|
||||
if (!(dirp=my_dir(tmp_dir,MYF(MY_WME))))
|
||||
DBUG_RETURN(1);
|
||||
my_dirend(dirp);
|
||||
|
||||
/*
|
||||
Check permissions to create a file.
|
||||
*/
|
||||
if ((fd= my_create(tmp_file, CREATE_MODE,
|
||||
O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
|
||||
MYF(MY_WME))) < 0)
|
||||
DBUG_RETURN(1);
|
||||
|
||||
/*
|
||||
Clean up.
|
||||
*/
|
||||
my_close(fd, MYF(0));
|
||||
my_delete(tmp_file, MYF(0));
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
/**
|
||||
Slave SQL thread entry point.
|
||||
@ -2763,6 +2798,14 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME,
|
||||
llstr(rli->group_master_log_pos,llbuff),rli->group_relay_log_name,
|
||||
llstr(rli->group_relay_log_pos,llbuff1));
|
||||
|
||||
if (check_temp_dir(slave_load_tmpdir, rli->slave_patternload_file))
|
||||
{
|
||||
rli->report(ERROR_LEVEL, thd->main_da.sql_errno(),
|
||||
"Unable to use slave's temporary directory %s - %s",
|
||||
slave_load_tmpdir, thd->main_da.message());
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* execute init_slave variable */
|
||||
if (sys_init_slave.value_length)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user