MDEV-8540 - Crash on server shutdown since 10.0.16

For the purpose of reporting an error to error log, shutdown thread was
attempting to access current_thd->variables.lc_messages->errmsgs->errmsgs.
Whereas current_thd was NULL.

We should log errors according to global lc_messages setting instead of
session setting.
This commit is contained in:
Sergey Vojtovich 2018-06-27 15:34:11 +04:00
parent 937c193188
commit 9d41dd2f39

View File

@ -2499,14 +2499,14 @@ void MYSQL_LOG::close(uint exiting)
if (log_type == LOG_BIN && mysql_file_sync(log_file.file, MYF(MY_WME)) && ! write_error) if (log_type == LOG_BIN && mysql_file_sync(log_file.file, MYF(MY_WME)) && ! write_error)
{ {
write_error= 1; write_error= 1;
sql_print_error(ER_THD_OR_DEFAULT(current_thd, ER_ERROR_ON_WRITE), name, errno); sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), name, errno);
} }
if (!(exiting & LOG_CLOSE_DELAYED_CLOSE) && if (!(exiting & LOG_CLOSE_DELAYED_CLOSE) &&
mysql_file_close(log_file.file, MYF(MY_WME)) && ! write_error) mysql_file_close(log_file.file, MYF(MY_WME)) && ! write_error)
{ {
write_error= 1; write_error= 1;
sql_print_error(ER_THD_OR_DEFAULT(current_thd, ER_ERROR_ON_WRITE), name, errno); sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), name, errno);
} }
} }
@ -2690,7 +2690,7 @@ err:
if (!write_error) if (!write_error)
{ {
write_error= 1; write_error= 1;
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno); sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), name, errno);
} }
mysql_mutex_unlock(&LOCK_log); mysql_mutex_unlock(&LOCK_log);
return TRUE; return TRUE;
@ -2866,7 +2866,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
if (! write_error) if (! write_error)
{ {
write_error= 1; write_error= 1;
sql_print_error(ER(ER_ERROR_ON_WRITE), name, tmp_errno); sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), name, tmp_errno);
} }
} }
} }
@ -6385,7 +6385,7 @@ void MYSQL_BIN_LOG::close(uint exiting)
if (mysql_file_close(index_file.file, MYF(0)) < 0 && ! write_error) if (mysql_file_close(index_file.file, MYF(0)) < 0 && ! write_error)
{ {
write_error= 1; write_error= 1;
sql_print_error(ER(ER_ERROR_ON_WRITE), index_file_name, errno); sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), index_file_name, errno);
} }
} }
log_state= (exiting & LOG_CLOSE_TO_BE_OPENED) ? LOG_TO_BE_OPENED : LOG_CLOSED; log_state= (exiting & LOG_CLOSE_TO_BE_OPENED) ? LOG_TO_BE_OPENED : LOG_CLOSED;