Skip to content

Commit

Permalink
Ensure that we have LOG_log locked when relay_log.close is called
Browse files Browse the repository at this point in the history
If open of the relay log failed, we got an assert in MYSQL_BIN_LOG::close
This only affected DEBUG systems
  • Loading branch information
montywi committed Jul 3, 2017
1 parent 228479a commit f8dadbd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions sql/rpl_rli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,14 @@ int init_relay_log_info(Relay_log_info* rli,
int info_fd;
const char* msg = 0;
int error = 0;
mysql_mutex_t *log_lock;
DBUG_ENTER("init_relay_log_info");
DBUG_ASSERT(!rli->no_storage); // Don't init if there is no storage

if (rli->inited) // Set if this function called
DBUG_RETURN(0);

log_lock= rli->relay_log.get_log_lock();
fn_format(fname, info_fname, mysql_data_home, "", 4+32);
mysql_mutex_lock(&rli->data_lock);
info_fd = rli->info_fd;
Expand Down Expand Up @@ -208,7 +211,6 @@ a file name for --relay-log-index option", opt_relaylog_index_name);
Master_info* mi= rli->mi;
char buf_relay_logname[FN_REFLEN], buf_relaylog_index_name_buff[FN_REFLEN];
char *buf_relaylog_index_name= opt_relaylog_index_name;
mysql_mutex_t *log_lock;

create_logfile_name_with_suffix(buf_relay_logname,
sizeof(buf_relay_logname),
Expand All @@ -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
but a destructor will take care of that
*/
log_lock= rli->relay_log.get_log_lock();
mysql_mutex_lock(log_lock);
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,
Expand Down Expand Up @@ -306,7 +307,9 @@ Failed to open the existing relay log info file '%s' (errno %d)",
if (info_fd >= 0)
mysql_file_close(info_fd, MYF(0));
rli->info_fd= -1;
mysql_mutex_lock(log_lock);
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
mysql_mutex_unlock(log_lock);
mysql_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1);
}
Expand Down Expand Up @@ -437,8 +440,12 @@ Failed to open the existing relay log info file '%s' (errno %d)",
if (info_fd >= 0)
mysql_file_close(info_fd, MYF(0));
rli->info_fd= -1;

mysql_mutex_lock(log_lock);
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
mysql_mutex_unlock(log_lock);
mysql_mutex_unlock(&rli->data_lock);

DBUG_RETURN(1);
}

Expand Down

0 comments on commit f8dadbd

Please sign in to comment.