summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <dli@dev3-76.dev.cn.tlan>2006-10-13 12:48:05 +0800
committerunknown <dli@dev3-76.dev.cn.tlan>2006-10-13 12:48:05 +0800
commit3def506b9db15adfecb2d7745f505e4131089692 (patch)
tree20505554637f19fe6fde8813a69d4207b4f66237
parent994ce8f209e1aebcb1fc4874119bebfd3bbd0013 (diff)
downloadmariadb-git-3def506b9db15adfecb2d7745f505e4131089692.tar.gz
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.
-rw-r--r--mysys/my_open.c12
-rw-r--r--sql/log.cc12
-rw-r--r--sql/log.h2
-rw-r--r--sql/share/errmsg.txt3
-rw-r--r--sql/sql_repl.cc1
-rw-r--r--sql/table.cc11
6 files changed, 38 insertions, 3 deletions
diff --git a/mysys/my_open.c b/mysys/my_open.c
index ab2f7c9ff27..a023a5ebe63 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -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))
- my_error(error_message_number, MYF(ME_BELL+ME_WAITTANG),
+ 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);
}
diff --git a/sql/log.cc b/sql/log.cc
index b63ec563baf..7b6724e7a90 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -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)
diff --git a/sql/log.h b/sql/log.h
index 8f75601f02b..7e739f4a9fb 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -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
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index a34e8c152cf..f9fb23c2191 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -6001,4 +6001,5 @@ ER_BAD_LOG_STATEMENT
ger "Sie können 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"
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 52489087b02..c281f00184e 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -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;
}
diff --git a/sql/table.cc b/sql/table.cc
index 5b41ad48696..fb05162061e 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -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));