Skip to content
Permalink
Browse files

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
  • Loading branch information...
montywi committed Jun 4, 2017
1 parent 228479a commit f8dadbdf241a5400a9180f03cab4dbf25206bf7c
Showing with 9 additions and 2 deletions.
  1. +9 −2 sql/rpl_rli.cc
@@ -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;
@@ -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),
@@ -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,
@@ -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);
}
@@ -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);
}

0 comments on commit f8dadbd

Please sign in to comment.
You can’t perform that action at this time.