Commit 757a6b43 authored by Michael Widenius's avatar Michael Widenius

Fixed MDEV-4394 Sporadic failures in multi_source tests

Fixed MDEV-4033 Unable to use slave's temporary directory /tmp - Can't create/write to file '/tmp/SQL_LOAD-' (Errcode: 17 "File exists")
- Cache value of check_temp_dir() to avoid race condition
- Set $rpl_server_count to avoid error in show_rpl_debug_info.inc

mysql-test/suite/multi_source/info_logs.test:
  Set $rpl_server_count
mysql-test/suite/multi_source/multisource.test:
  Set $rpl_server_count
mysql-test/suite/multi_source/relaylog_events.test:
  Set $rpl_server_count
mysql-test/suite/multi_source/reset_slave.test:
  Set $rpl_server_count
mysql-test/suite/multi_source/simple.test:
  Set $rpl_server_count
mysql-test/suite/multi_source/skip_counter.test:
  Set $rpl_server_count
mysql-test/suite/multi_source/status_vars.test:
  Set $rpl_server_count
sql/slave.cc:
  Cache value of check_temp_dir() to avoid race condition
parent f57ecb77
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# #
--source include/not_embedded.inc --source include/not_embedded.inc
--let $rpl_server_count= 0
--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
--source include/not_embedded.inc --source include/not_embedded.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--let $rpl_server_count= 0
--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# #
--source include/not_embedded.inc --source include/not_embedded.inc
--let $rpl_server_count= 0
--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# #
--source include/not_embedded.inc --source include/not_embedded.inc
--let $rpl_server_count= 0
--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# #
--source include/not_embedded.inc --source include/not_embedded.inc
--let $rpl_server_count= 0
--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) --connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# on the 1st master # on the 1st master
--source include/not_embedded.inc --source include/not_embedded.inc
--let $rpl_server_count= 0
--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) --connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# #
--source include/not_embedded.inc --source include/not_embedded.inc
--let $rpl_server_count= 0
--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
......
...@@ -3526,17 +3526,34 @@ log space"); ...@@ -3526,17 +3526,34 @@ log space");
/* /*
Check the temporary directory used by commands like Check the temporary directory used by commands like
LOAD DATA INFILE. LOAD DATA INFILE.
As the directory never changes during a mysqld run, we only
test this once and cache the result. This also resolve a race condition
when this can be run by multiple threads at the same time.
*/ */
static bool check_temp_dir_run= 0;
static int check_temp_dir_result= 0;
static static
int check_temp_dir(char* tmp_file) int check_temp_dir(char* tmp_file)
{ {
int fd; File fd;
int result= 1; // Assume failure
MY_DIR *dirp; MY_DIR *dirp;
char tmp_dir[FN_REFLEN]; char tmp_dir[FN_REFLEN];
size_t tmp_dir_size; size_t tmp_dir_size;
DBUG_ENTER("check_temp_dir"); DBUG_ENTER("check_temp_dir");
mysql_mutex_lock(&LOCK_thread_count);
if (check_temp_dir_run)
{
result= check_temp_dir_result;
goto end;
}
check_temp_dir_run= 1;
/* /*
Get the directory from the temporary file. Get the directory from the temporary file.
*/ */
...@@ -3546,27 +3563,33 @@ int check_temp_dir(char* tmp_file) ...@@ -3546,27 +3563,33 @@ int check_temp_dir(char* tmp_file)
Check if the directory exists. Check if the directory exists.
*/ */
if (!(dirp=my_dir(tmp_dir,MYF(MY_WME)))) if (!(dirp=my_dir(tmp_dir,MYF(MY_WME))))
DBUG_RETURN(1); goto end;
my_dirend(dirp); my_dirend(dirp);
/* /*
Check permissions to create a file. Check permissions to create a file. We use O_TRUNC to ensure that
things works even if we happen to have and old file laying around.
*/ */
if ((fd= mysql_file_create(key_file_misc, if ((fd= mysql_file_create(key_file_misc,
tmp_file, CREATE_MODE, tmp_file, CREATE_MODE,
O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, O_WRONLY | O_BINARY | O_TRUNC | O_NOFOLLOW,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
DBUG_RETURN(1); goto end;
result= 0; // Directory name ok
/* /*
Clean up. Clean up.
*/ */
mysql_file_close(fd, MYF(0)); mysql_file_close(fd, MYF(0));
mysql_file_delete(key_file_misc, tmp_file, MYF(0)); mysql_file_delete(key_file_misc, tmp_file, MYF(0));
DBUG_RETURN(0); end:
check_temp_dir_result= result;
mysql_mutex_unlock(&LOCK_thread_count);
DBUG_RETURN(result);
} }
/** /**
Slave SQL thread entry point. Slave SQL thread entry point.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment