Skip to content

Commit bbdec04

Browse files
committed
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
1 parent 6891c48 commit bbdec04

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6576,7 +6576,7 @@ int main(int argc, char **argv)
65766576
key_map_full.set_all();
65776577

65786578
logger.init_base();
6579-
logger.set_handlers(LOG_FILE, LOG_NONE, LOG_NONE);
6579+
logger.set_handlers(LOG_NONE, LOG_NONE);
65806580
mysql_mutex_init(key_LOCK_error_log, &LOCK_error_log,
65816581
MY_MUTEX_INIT_FAST);
65826582

sql/log.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,13 +1561,9 @@ bool Log_to_csv_event_handler::init()
15611561
return 0;
15621562
}
15631563

1564-
int LOGGER::set_handlers(ulonglong error_log_printer,
1565-
ulonglong slow_log_printer,
1564+
int LOGGER::set_handlers(ulonglong slow_log_printer,
15661565
ulonglong general_log_printer)
15671566
{
1568-
/* error log table is not supported yet */
1569-
DBUG_ASSERT(error_log_printer < LOG_TABLE);
1570-
15711567
lock_exclusive();
15721568

15731569
if ((slow_log_printer & LOG_TABLE || general_log_printer & LOG_TABLE) &&
@@ -1580,7 +1576,6 @@ int LOGGER::set_handlers(ulonglong error_log_printer,
15801576
"Falling back to the old-fashioned logs");
15811577
}
15821578

1583-
init_error_log(error_log_printer);
15841579
init_slow_log(slow_log_printer);
15851580
init_general_log(general_log_printer);
15861581

sql/log.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,7 @@ class LOGGER
11031103
const char *query, size_t query_length);
11041104

11051105
/* we use this function to setup all enabled log event handlers */
1106-
int set_handlers(ulonglong error_log_printer,
1107-
ulonglong slow_log_printer,
1106+
int set_handlers(ulonglong slow_log_printer,
11081107
ulonglong general_log_printer);
11091108
void init_error_log(ulonglong error_log_printer);
11101109
void init_slow_log(ulonglong slow_log_printer);

sql/mysqld.cc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,7 +3607,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
36073607
sql_print_information("Got signal %d to shutdown mysqld",sig);
36083608
#endif
36093609
/* switch to the old log message processing */
3610-
logger.set_handlers(LOG_FILE, global_system_variables.sql_log_slow ? LOG_FILE:LOG_NONE,
3610+
logger.set_handlers(global_system_variables.sql_log_slow ? LOG_FILE:LOG_NONE,
36113611
opt_log ? LOG_FILE:LOG_NONE);
36123612
DBUG_PRINT("info",("Got signal: %d abort_loop: %d",sig,abort_loop));
36133613
if (!abort_loop)
@@ -3642,15 +3642,13 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
36423642
/* reenable logs after the options were reloaded */
36433643
if (log_output_options & LOG_NONE)
36443644
{
3645-
logger.set_handlers(LOG_FILE,
3646-
global_system_variables.sql_log_slow ?
3645+
logger.set_handlers(global_system_variables.sql_log_slow ?
36473646
LOG_TABLE : LOG_NONE,
36483647
opt_log ? LOG_TABLE : LOG_NONE);
36493648
}
36503649
else
36513650
{
3652-
logger.set_handlers(LOG_FILE,
3653-
global_system_variables.sql_log_slow ?
3651+
logger.set_handlers(global_system_variables.sql_log_slow ?
36543652
log_output_options : LOG_NONE,
36553653
opt_log ? log_output_options : LOG_NONE);
36563654
}
@@ -5571,7 +5569,7 @@ static int init_server_components()
55715569
sql_print_warning("There were other values specified to "
55725570
"log-output besides NONE. Disabling slow "
55735571
"and general logs anyway.");
5574-
logger.set_handlers(LOG_FILE, LOG_NONE, LOG_NONE);
5572+
logger.set_handlers(LOG_NONE, LOG_NONE);
55755573
}
55765574
else
55775575
{
@@ -5587,8 +5585,7 @@ static int init_server_components()
55875585
/* purecov: end */
55885586
}
55895587

5590-
logger.set_handlers(LOG_FILE,
5591-
global_system_variables.sql_log_slow ?
5588+
logger.set_handlers(global_system_variables.sql_log_slow ?
55925589
log_output_options:LOG_NONE,
55935590
opt_log ? log_output_options:LOG_NONE);
55945591
}

0 commit comments

Comments
 (0)