--- a/sql/sql_repl.cc 2009-02-14 09:56:09.000000000 +0900 +++ b/sql/sql_repl.cc 2009-04-09 22:45:34.000000000 +0900 @@ -975,6 +975,29 @@ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SLAVE_WAS_NOT_RUNNING, ER(ER_SLAVE_WAS_NOT_RUNNING)); } + + /* + Flush these files in order to make sure files are ready for backup + after STOP SLAVE command. + */ + if(mi) { + thd_proc_info(thd, "Flushing master.info and relay logs"); + flush_io_cache(&mi->file); + if(mi->fd > 0) + my_sync(mi->fd,MYF(0)); + IO_CACHE *c = mi->rli.relay_log.get_log_file(); + if(c) + flush_io_cache(c); + if(mi->rli.info_fd > 0) + my_sync(mi->rli.info_fd,MYF(0)); + pthread_mutex_t *log_lock= mi->rli.relay_log.get_log_lock(); + if(log_lock) { + pthread_mutex_lock(log_lock); + mi->rli.relay_log.flush_and_sync(); + pthread_mutex_unlock(log_lock); + } + } + unlock_slave_threads(mi); thd_proc_info(thd, 0);