mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
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
This commit is contained in:
@@ -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);
|
|||||||
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);
|
|||||||
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)",
|
|||||||
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 @@ err:
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user