Commit 3def506b authored by unknown's avatar unknown
Browse files

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
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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);
}

+12 −0
Original line number Diff line number Diff line
@@ -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)
+2 −0
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -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"
+1 −0
Original line number Diff line number Diff line
@@ -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;
  }

Loading