Commit f8dadbdf authored by Monty's avatar Monty

Ensure that we have LOG_log locked when relay_log.close is called

If open of the relay log failed, we got an assert in MYSQL_BIN_LOG::close
This only affected DEBUG systems
parent 228479a2
...@@ -122,11 +122,14 @@ int init_relay_log_info(Relay_log_info* rli, ...@@ -122,11 +122,14 @@ int init_relay_log_info(Relay_log_info* rli,
int info_fd; int info_fd;
const char* msg = 0; const char* msg = 0;
int error = 0; int error = 0;
mysql_mutex_t *log_lock;
DBUG_ENTER("init_relay_log_info"); DBUG_ENTER("init_relay_log_info");
DBUG_ASSERT(!rli->no_storage); // Don't init if there is no storage DBUG_ASSERT(!rli->no_storage); // Don't init if there is no storage
if (rli->inited) // Set if this function called if (rli->inited) // Set if this function called
DBUG_RETURN(0); DBUG_RETURN(0);
log_lock= rli->relay_log.get_log_lock();
fn_format(fname, info_fname, mysql_data_home, "", 4+32); fn_format(fname, info_fname, mysql_data_home, "", 4+32);
mysql_mutex_lock(&rli->data_lock); mysql_mutex_lock(&rli->data_lock);
info_fd = rli->info_fd; info_fd = rli->info_fd;
...@@ -208,7 +211,6 @@ a file name for --relay-log-index option", opt_relaylog_index_name); ...@@ -208,7 +211,6 @@ a file name for --relay-log-index option", opt_relaylog_index_name);
Master_info* mi= rli->mi; Master_info* mi= rli->mi;
char buf_relay_logname[FN_REFLEN], buf_relaylog_index_name_buff[FN_REFLEN]; char buf_relay_logname[FN_REFLEN], buf_relaylog_index_name_buff[FN_REFLEN];
char *buf_relaylog_index_name= opt_relaylog_index_name; char *buf_relaylog_index_name= opt_relaylog_index_name;
mysql_mutex_t *log_lock;
create_logfile_name_with_suffix(buf_relay_logname, create_logfile_name_with_suffix(buf_relay_logname,
sizeof(buf_relay_logname), sizeof(buf_relay_logname),
...@@ -228,7 +230,6 @@ a file name for --relay-log-index option", opt_relaylog_index_name); ...@@ -228,7 +230,6 @@ a file name for --relay-log-index option", opt_relaylog_index_name);
note, that if open() fails, we'll still have index file open note, that if open() fails, we'll still have index file open
but a destructor will take care of that but a destructor will take care of that
*/ */
log_lock= rli->relay_log.get_log_lock();
mysql_mutex_lock(log_lock); mysql_mutex_lock(log_lock);
if (rli->relay_log.open_index_file(buf_relaylog_index_name, ln, TRUE) || if (rli->relay_log.open_index_file(buf_relaylog_index_name, ln, TRUE) ||
rli->relay_log.open(ln, LOG_BIN, 0, 0, SEQ_READ_APPEND, rli->relay_log.open(ln, LOG_BIN, 0, 0, SEQ_READ_APPEND,
...@@ -306,7 +307,9 @@ Failed to open the existing relay log info file '%s' (errno %d)", ...@@ -306,7 +307,9 @@ Failed to open the existing relay log info file '%s' (errno %d)",
if (info_fd >= 0) if (info_fd >= 0)
mysql_file_close(info_fd, MYF(0)); mysql_file_close(info_fd, MYF(0));
rli->info_fd= -1; rli->info_fd= -1;
mysql_mutex_lock(log_lock);
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT); rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
mysql_mutex_unlock(log_lock);
mysql_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -437,8 +440,12 @@ Failed to open the existing relay log info file '%s' (errno %d)", ...@@ -437,8 +440,12 @@ Failed to open the existing relay log info file '%s' (errno %d)",
if (info_fd >= 0) if (info_fd >= 0)
mysql_file_close(info_fd, MYF(0)); mysql_file_close(info_fd, MYF(0));
rli->info_fd= -1; rli->info_fd= -1;
mysql_mutex_lock(log_lock);
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT); rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
mysql_mutex_unlock(log_lock);
mysql_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
......
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