mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
fixed race condition in automatic binlog rotation
remove extension from binary log if the user specifies one to avoid
non-rotatable logs
fixed possible use of unitialized IO_CACHE in debug mode
This commit is contained in:
21
sql/log.cc
21
sql/log.cc
@@ -511,17 +511,19 @@ bool MYSQL_LOG::is_active(const char* log_file_name)
|
||||
return inited && !strcmp(log_file_name, this->log_file_name);
|
||||
}
|
||||
|
||||
void MYSQL_LOG::new_file()
|
||||
void MYSQL_LOG::new_file(bool inside_mutex)
|
||||
{
|
||||
// only rotate open logs that are marked non-rotatable
|
||||
// (binlog with constant name are non-rotatable)
|
||||
if (is_open() && ! no_rotate)
|
||||
{
|
||||
char new_name[FN_REFLEN], *old_name=name;
|
||||
VOID(pthread_mutex_lock(&LOCK_log));
|
||||
if (!inside_mutex)
|
||||
VOID(pthread_mutex_lock(&LOCK_log));
|
||||
if (generate_new_name(new_name, name))
|
||||
{
|
||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||
if (!inside_mutex)
|
||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||
return; // Something went wrong
|
||||
}
|
||||
if (log_type == LOG_BIN)
|
||||
@@ -540,7 +542,8 @@ void MYSQL_LOG::new_file()
|
||||
my_free(old_name,MYF(0));
|
||||
last_time=query_start=0;
|
||||
write_error=0;
|
||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||
if (!inside_mutex)
|
||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,9 +698,9 @@ err:
|
||||
if (file == &log_file)
|
||||
VOID(pthread_cond_broadcast(&COND_binlog_update));
|
||||
}
|
||||
if (should_rotate)
|
||||
new_file(1); // inside mutex
|
||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||
if(should_rotate)
|
||||
new_file();
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -782,11 +785,13 @@ bool MYSQL_LOG::write(Load_log_event* event_info)
|
||||
VOID(pthread_cond_broadcast(&COND_binlog_update));
|
||||
}
|
||||
}
|
||||
|
||||
if(should_rotate)
|
||||
new_file(1); // inside mutex
|
||||
|
||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||
}
|
||||
|
||||
if(should_rotate)
|
||||
new_file();
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user