Commit bbdec04d authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-24317 Data race in LOGGER::init_error_log at sql/log.cc:1443 and in...

MDEV-24317 Data race in LOGGER::init_error_log at sql/log.cc:1443 and in LOGGER::error_log_print at sql/log.cc:1181

don't initialize error_log_handler_list in set_handlers()
* error_log_handler_list is initialized to LOG_FILE early, in init_base()
* set_handlers always reinitializes it to LOG_FILE, so it's pointless
* after init_base() concurrent threads start using sql_log_warning,
  so following set_handlers() shouldn't modify error_log_handler_list
  without some protection
parent 6891c487
......@@ -6576,7 +6576,7 @@ int main(int argc, char **argv)
key_map_full.set_all();
logger.init_base();
logger.set_handlers(LOG_FILE, LOG_NONE, LOG_NONE);
logger.set_handlers(LOG_NONE, LOG_NONE);
mysql_mutex_init(key_LOCK_error_log, &LOCK_error_log,
MY_MUTEX_INIT_FAST);
......
......@@ -1561,13 +1561,9 @@ bool Log_to_csv_event_handler::init()
return 0;
}
int LOGGER::set_handlers(ulonglong error_log_printer,
ulonglong slow_log_printer,
int LOGGER::set_handlers(ulonglong slow_log_printer,
ulonglong general_log_printer)
{
/* error log table is not supported yet */
DBUG_ASSERT(error_log_printer < LOG_TABLE);
lock_exclusive();
if ((slow_log_printer & LOG_TABLE || general_log_printer & LOG_TABLE) &&
......@@ -1580,7 +1576,6 @@ int LOGGER::set_handlers(ulonglong error_log_printer,
"Falling back to the old-fashioned logs");
}
init_error_log(error_log_printer);
init_slow_log(slow_log_printer);
init_general_log(general_log_printer);
......
......@@ -1103,8 +1103,7 @@ class LOGGER
const char *query, size_t query_length);
/* we use this function to setup all enabled log event handlers */
int set_handlers(ulonglong error_log_printer,
ulonglong slow_log_printer,
int set_handlers(ulonglong slow_log_printer,
ulonglong general_log_printer);
void init_error_log(ulonglong error_log_printer);
void init_slow_log(ulonglong slow_log_printer);
......
......@@ -3607,7 +3607,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
sql_print_information("Got signal %d to shutdown mysqld",sig);
#endif
/* switch to the old log message processing */
logger.set_handlers(LOG_FILE, global_system_variables.sql_log_slow ? LOG_FILE:LOG_NONE,
logger.set_handlers(global_system_variables.sql_log_slow ? LOG_FILE:LOG_NONE,
opt_log ? LOG_FILE:LOG_NONE);
DBUG_PRINT("info",("Got signal: %d abort_loop: %d",sig,abort_loop));
if (!abort_loop)
......@@ -3642,15 +3642,13 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
/* reenable logs after the options were reloaded */
if (log_output_options & LOG_NONE)
{
logger.set_handlers(LOG_FILE,
global_system_variables.sql_log_slow ?
logger.set_handlers(global_system_variables.sql_log_slow ?
LOG_TABLE : LOG_NONE,
opt_log ? LOG_TABLE : LOG_NONE);
}
else
{
logger.set_handlers(LOG_FILE,
global_system_variables.sql_log_slow ?
logger.set_handlers(global_system_variables.sql_log_slow ?
log_output_options : LOG_NONE,
opt_log ? log_output_options : LOG_NONE);
}
......@@ -5571,7 +5569,7 @@ static int init_server_components()
sql_print_warning("There were other values specified to "
"log-output besides NONE. Disabling slow "
"and general logs anyway.");
logger.set_handlers(LOG_FILE, LOG_NONE, LOG_NONE);
logger.set_handlers(LOG_NONE, LOG_NONE);
}
else
{
......@@ -5587,8 +5585,7 @@ static int init_server_components()
/* purecov: end */
}
logger.set_handlers(LOG_FILE,
global_system_variables.sql_log_slow ?
logger.set_handlers(global_system_variables.sql_log_slow ?
log_output_options:LOG_NONE,
opt_log ? log_output_options:LOG_NONE);
}
......
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