From b7d4c76a54876f5e2aac4d30e171db2cff91dd04 Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Thu, 24 Jul 2008 14:28:21 +0200 Subject: [PATCH 1/3] Bug#37027 expire_logs_days and missing binlogs cause a crash ! If the server failed to expired log files during start up it could crash. sql/log.cc: Added predicate to protect againt cases when current_thd might be NULL. --- sql/log.cc | 142 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 97 insertions(+), 45 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 9e112e46c65..5a1cfe46686 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1193,6 +1193,7 @@ int MYSQL_LOG::purge_logs(const char *to_log, int error; bool exit_loop= 0; LOG_INFO log_info; + THD *thd= current_thd; DBUG_ENTER("purge_logs"); DBUG_PRINT("info",("to_log= %s",to_log)); @@ -1218,10 +1219,13 @@ int MYSQL_LOG::purge_logs(const char *to_log, /* It's not fatal if we can't stat a log file that does not exist; If we could not stat, we won't delete. - */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), - log_info.log_file_name); + */ + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + } sql_print_information("Failed to execute my_stat on file '%s'", log_info.log_file_name); my_errno= 0; @@ -1231,13 +1235,24 @@ int MYSQL_LOG::purge_logs(const char *to_log, /* Other than ENOENT are fatal */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_BINLOG_PURGE_FATAL_ERR, - "a problem with getting info on being purged %s; " - "consider examining correspondence " - "of your binlog index file " - "to the actual binlog files", - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with getting info on being purged %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + } + else + { + sql_print_information("Failed to delete log file '%s'; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + } error= LOG_INFO_FATAL; goto err; } @@ -1254,22 +1269,36 @@ int MYSQL_LOG::purge_logs(const char *to_log, { if (my_errno == ENOENT) { - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + } sql_print_information("Failed to delete file '%s'", log_info.log_file_name); my_errno= 0; } else { - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_BINLOG_PURGE_FATAL_ERR, - "a problem with deleting %s; " - "consider examining correspondence " - "of your binlog index file " - "to the actual binlog files", - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with deleting %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + } + else + { + sql_print_information("Failed to delete file '%s'; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + } error= LOG_INFO_FATAL; goto err; } @@ -1316,7 +1345,8 @@ int MYSQL_LOG::purge_logs_before_date(time_t purge_time) int error; LOG_INFO log_info; MY_STAT stat_area; - + THD *thd= current_thd; + DBUG_ENTER("purge_logs_before_date"); pthread_mutex_lock(&LOCK_index); @@ -1338,12 +1368,15 @@ int MYSQL_LOG::purge_logs_before_date(time_t purge_time) { /* It's not fatal if we can't stat a log file that does not exist. - */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), - log_info.log_file_name); - sql_print_information("Failed to execute my_stat on file '%s'", - log_info.log_file_name); + */ + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + } + sql_print_information("Failed to execute my_stat on file '%s'", + log_info.log_file_name); my_errno= 0; } else @@ -1351,13 +1384,21 @@ int MYSQL_LOG::purge_logs_before_date(time_t purge_time) /* Other than ENOENT are fatal */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_BINLOG_PURGE_FATAL_ERR, - "a problem with getting info on being purged %s; " - "consider examining correspondence " - "of your binlog index file " - "to the actual binlog files", - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with getting info on being purged %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + } + else + { + sql_print_information("Failed to delete log file '%s'", + log_info.log_file_name); + } error= LOG_INFO_FATAL; goto err; } @@ -1371,22 +1412,33 @@ int MYSQL_LOG::purge_logs_before_date(time_t purge_time) if (my_errno == ENOENT) { /* It's not fatal even if we can't delete a log file */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + } sql_print_information("Failed to delete file '%s'", log_info.log_file_name); my_errno= 0; } else { - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_BINLOG_PURGE_FATAL_ERR, - "a problem with deleting %s; " - "consider examining correspondence " - "of your binlog index file " - "to the actual binlog files", - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with deleting %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + } + else + { + sql_print_information("Failed to delete log file '%s'", + log_info.log_file_name); + } error= LOG_INFO_FATAL; goto err; } From 8544ee54e2242dd5edf5d53b99f88ab4b15c1f71 Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Mon, 21 Jul 2008 16:41:17 +0200 Subject: [PATCH 2/3] Corrected merge misstake. --- sql/log.cc | 111 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 36 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 0466fe3c948..a56be801d2b 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -3070,7 +3070,7 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log, int ret = 0; bool exit_loop= 0; LOG_INFO log_info; - THD *thd =current_thd; + THD *thd= current_thd; DBUG_ENTER("purge_logs"); DBUG_PRINT("info",("to_log= %s",to_log)); @@ -3097,9 +3097,12 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log, It's not fatal if we can't stat a log file that does not exist; If we could not stat, we won't delete. */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + } sql_print_information("Failed to execute my_stat on file '%s'", log_info.log_file_name); my_errno= 0; @@ -3109,13 +3112,24 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log, /* Other than ENOENT are fatal */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_BINLOG_PURGE_FATAL_ERR, - "a problem with getting info on being purged %s; " - "consider examining correspondence " - "of your binlog index file " - "to the actual binlog files", - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with getting info on being purged %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + } + else + { + sql_print_information("Failed to delete log file '%s'; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + } error= LOG_INFO_FATAL; goto err; } @@ -3132,9 +3146,12 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log, { if (my_errno == ENOENT) { - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + } sql_print_information("Failed to delete file '%s'", log_info.log_file_name); my_errno= 0; @@ -3217,7 +3234,7 @@ int MYSQL_BIN_LOG::purge_logs_before_date(time_t purge_time) int error; LOG_INFO log_info; MY_STAT stat_area; - + THD *thd= current_thd; DBUG_ENTER("purge_logs_before_date"); pthread_mutex_lock(&LOCK_index); @@ -3239,10 +3256,13 @@ int MYSQL_BIN_LOG::purge_logs_before_date(time_t purge_time) { /* It's not fatal if we can't stat a log file that does not exist. - */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), - log_info.log_file_name); + */ + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + } sql_print_information("Failed to execute my_stat on file '%s'", log_info.log_file_name); my_errno= 0; @@ -3252,13 +3272,21 @@ int MYSQL_BIN_LOG::purge_logs_before_date(time_t purge_time) /* Other than ENOENT are fatal */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_BINLOG_PURGE_FATAL_ERR, - "a problem with getting info on being purged %s; " - "consider examining correspondence " - "of your binlog index file " - "to the actual binlog files", - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with getting info on being purged %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + } + else + { + sql_print_information("Failed to delete log file '%s'", + log_info.log_file_name); + } error= LOG_INFO_FATAL; goto err; } @@ -3272,22 +3300,33 @@ int MYSQL_BIN_LOG::purge_logs_before_date(time_t purge_time) if (my_errno == ENOENT) { /* It's not fatal even if we can't delete a log file */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + } sql_print_information("Failed to delete file '%s'", log_info.log_file_name); my_errno= 0; } else { - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_BINLOG_PURGE_FATAL_ERR, - "a problem with deleting %s; " - "consider examining correspondence " - "of your binlog index file " - "to the actual binlog files", - log_info.log_file_name); + if (thd) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with deleting %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + } + else + { + sql_print_information("Failed to delete log file '%s'", + log_info.log_file_name); + } error= LOG_INFO_FATAL; goto err; } From 6334196bd785ad53a3962785fcb0535f12e1c9ba Mon Sep 17 00:00:00 2001 From: Sven Sandberg Date: Mon, 21 Jul 2008 21:05:06 +0200 Subject: [PATCH 3/3] BUG#38269: pushbuild gives valgrind error in ha_statistic_increment for rpl_temporary This does not fix the bug. It only disables the failing test. mysql-test/suite/rpl/t/disabled.def: disable rpl_temporary --- mysql-test/suite/rpl/t/disabled.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def index 094919c81b5..43a379dbe03 100644 --- a/mysql-test/suite/rpl/t/disabled.def +++ b/mysql-test/suite/rpl/t/disabled.def @@ -12,4 +12,4 @@ rpl_redirect : Failure is sporadic and and the test is superfluous (mats) rpl_innodb_bug28430 : Failure on Solaris Bug #36793 - +rpl_temporary : BUG#38269 2008-07-21 Sven valgrind error in pushbuild