diff options
author | Sergei Golubchik <serg@mariadb.org> | 2022-04-12 13:07:20 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2022-04-12 13:07:20 +0200 |
commit | bbdec04d59ceeda7d1792c8250f6b10989cb239a (patch) | |
tree | bd7d971804d31de965679d9c1d4e723d027f4ea6 | |
parent | 6891c4874a70685e6f6661fad2369d26007003c7 (diff) | |
download | mariadb-git-bbdec04d59ceeda7d1792c8250f6b10989cb239a.tar.gz |
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
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 2 | ||||
-rw-r--r-- | sql/log.cc | 7 | ||||
-rw-r--r-- | sql/log.h | 3 | ||||
-rw-r--r-- | sql/mysqld.cc | 13 |
4 files changed, 8 insertions, 17 deletions
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 41461d6ece1..f745c6ba163 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -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); diff --git a/sql/log.cc b/sql/log.cc index 61cc922adb9..f6f3879e66d 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -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); diff --git a/sql/log.h b/sql/log.h index d923356f8d9..59d4bf8c130 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1103,8 +1103,7 @@ public: 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); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 10e6214128a..522dcf06ac2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -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); } |