Bug #42861 Assigning invalid directories to --slave-load-tmpdir crashes the slave

Compiling with debug and assigning an invalid directory to --slave-load-tmpdir
was crashing the slave due to the following assertion DBUG_ASSERT(! is_set() ||
can_overwrite_status). This assertion assumes that a thread can change its
state once (i.e. ok,error, etc) before aborting, cleaning/resuming or completing
its execution unless the overwrite flag (i.e. can_overwrite_status) is true.

The Append_block_log_event::do_apply_event which is responsible for creating
temporary file(s) was not cleaning the thread state. Thus a failure while
trying to create a file in an invalid temporary directory was causing the crash.

To fix the problem we check if the temporary directory is valid before starting
the SQL Thread and reset the thread state before creating a file in
Append_block_log_event::do_apply_event.
This commit is contained in:
Alfranio Correia 2009-03-18 10:31:17 +00:00
commit b97083dfc7
10 changed files with 160 additions and 3 deletions

View file

@ -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)
{