Hi Alfranio,
Nice work, two considerations:
1) Please set proper slave error code and message if this problem
occurs, so that user can know what's going wrong with SHOW SLAVE STATUS
and the error log.
2) Please add a test to check if slave SQL thread stops and the error
code/message are properly set when such problem ocures
Alfranio Correia wrote:
> #At
> file:///home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-42861/mysql-5.1-bugteam/
> based on revid:msvensson@stripped
>
> 2798 Alfranio Correia 2009-02-14
> BUG#42861 Assigning invalid directories to --slave-load-tmpdir crashes the
> slave
>
> Compiling with debug and assinging 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 throw one error before stoping its
> execution unless the
> overwrite flag (i.e. can_overwrite_status) is true. The cleanup function
> however was failing and an
> error was being thrown by my_dir and the replication thread was not aborting
> the execution.
>
> To fix the problem we propagate the error from the cleanup function until it
> reaches a point in which
> the replication code can report the error and stop the execution.
> modified:
> sql/log_event.cc
>
> === modified file 'sql/log_event.cc'
> --- a/sql/log_event.cc 2009-02-04 11:08:27 +0000
> +++ b/sql/log_event.cc 2009-02-14 21:26:23 +0000
> @@ -375,15 +375,16 @@ static char *slave_load_file_stem(char *
> Delete all temporary files used for SQL_LOAD.
> */
>
> -static void cleanup_load_tmpdir()
> +static int cleanup_load_tmpdir()
> {
> MY_DIR *dirp;
> FILEINFO *file;
> uint i;
> char fname[FN_REFLEN], prefbuf[31], *p;
> + int error= 0;
>
> if (!(dirp=my_dir(slave_load_tmpdir,MYF(MY_WME))))
> - return;
> + return 1;
>
> /*
> When we are deleting temporary files, we should only remove
> @@ -404,11 +405,14 @@ static void cleanup_load_tmpdir()
> if (is_prefix(file->name, prefbuf))
> {
> fn_format(fname,file->name,slave_load_tmpdir,"",MY_UNPACK_FILENAME);
> - my_delete(fname, MYF(0));
> + if ((error= my_delete(fname, MYF(0))))
> + break;
> }
> }
>
> my_dirend(dirp);
> +
> + return (error);
> }
> #endif
>
> @@ -3379,7 +3383,10 @@ int Start_log_event_v3::do_apply_event(R
> if (created)
> {
> close_temporary_tables(thd);
> - cleanup_load_tmpdir();
> + if (cleanup_load_tmpdir())
> + {
> + DBUG_RETURN(1);
> + }
> }
> else
> {
>
>