Commit 3def506b authored by unknown's avatar unknown

ndb - fixed for BUG#15021, binlog_index table become inconsistent if errors...

ndb - fixed for BUG#15021, binlog_index table become inconsistent if errors during purge of binlogs.
if EMFILE error occured while purging binary logs, stop purging logs and report error message to user.


mysys/my_open.c:
  report EMFILE error when opening file failed.
sql/log.cc:
  report EMFILE error when purging logs, and stop purging logs when EMFILE error occured.
sql/log.h:
  added LOG_INFO_EMFILE error number.
sql/share/errmsg.txt:
  added EMFILE error message for purging binary logs.
sql/sql_repl.cc:
  added EMFILE error message.
sql/table.cc:
  report EMFILE error.
parent 994ce8f2
......@@ -167,9 +167,17 @@ File my_register_filename(File fd, const char *FileName, enum file_type
else
my_errno=errno;
DBUG_PRINT("error",("Got error %d on open",my_errno));
if (MyFlags & (MY_FFNF | MY_FAE | MY_WME))
if (MyFlags & (MY_FFNF | MY_FAE | MY_WME)) {
if (my_errno == EMFILE) {
DBUG_PRINT("error",("print err: %d",EE_OUT_OF_FILERESOURCES));
my_error(EE_OUT_OF_FILERESOURCES, MYF(ME_BELL+ME_WAITTANG),
FileName, my_errno);
} else {
DBUG_PRINT("error",("print err: %d",error_message_number));
my_error(error_message_number, MYF(ME_BELL+ME_WAITTANG),
FileName, my_errno);
}
}
return(fd);
}
......
......@@ -2687,6 +2687,7 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
ulonglong *decrease_log_space)
{
int error;
int ret = 0;
bool exit_loop= 0;
LOG_INFO log_info;
DBUG_ENTER("purge_logs");
......@@ -2731,6 +2732,14 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
*decrease_log_space-= file_size;
ha_binlog_index_purge_file(current_thd, log_info.log_file_name);
if (current_thd->query_error) {
DBUG_PRINT("info",("query error: %d", current_thd->query_error));
if (my_errno == EMFILE) {
DBUG_PRINT("info",("my_errno: %d, set ret = LOG_INFO_EMFILE", my_errno));
ret = LOG_INFO_EMFILE;
break;
}
}
if (find_next_log(&log_info, 0) || exit_loop)
break;
......@@ -2741,6 +2750,9 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
the log index file after restart - otherwise, this should be safe
*/
error= update_log_index(&log_info, need_update_threads);
if (error == 0) {
error = ret;
}
err:
if (need_mutex)
......
......@@ -114,6 +114,8 @@ extern TC_LOG_DUMMY tc_log_dummy;
#define LOG_INFO_MEM -6
#define LOG_INFO_FATAL -7
#define LOG_INFO_IN_USE -8
#define LOG_INFO_EMFILE -9
/* bitmap to SQL_LOG::close() */
#define LOG_CLOSE_INDEX 1
......
......@@ -6001,4 +6001,5 @@ ER_BAD_LOG_STATEMENT
ger "Sie knnen eine Logtabelle nicht '%s', wenn Loggen angeschaltet ist"
ER_NON_INSERTABLE_TABLE
eng "The target table %-.100s of the %s is not insertable-into"
ER_BINLOG_PURGE_EMFILE
eng "Too many files opened, please execute the command again"
......@@ -239,6 +239,7 @@ bool purge_error_message(THD* thd, int res)
case LOG_INFO_MEM: errmsg= ER_OUT_OF_RESOURCES; break;
case LOG_INFO_FATAL: errmsg= ER_BINLOG_PURGE_FATAL_ERR; break;
case LOG_INFO_IN_USE: errmsg= ER_LOG_IN_USE; break;
case LOG_INFO_EMFILE: errmsg= ER_BINLOG_PURGE_EMFILE; break;
default: errmsg= ER_LOG_PURGE_UNKNOWN_ERR; break;
}
......
......@@ -1562,6 +1562,17 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
error= 1;
my_errno= ENOENT;
}
else if (ha_err == EMFILE)
{
/*
Too many files opened, use same error message as if the .frm
file can't open
*/
DBUG_PRINT("error", ("open file: %s failed, too many files opened (errno: %d)",
share->normalized_path.str, ha_err));
error= 1;
my_errno= EMFILE;
}
else
{
outparam->file->print_error(ha_err, MYF(0));
......
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