[Commits] Rev 3115: Added new engine message if table was not closed properly (common error with MyISAM and Aria) in lp:maria/5.3

Michael Widenius monty at askmonty.org
Fri Aug 12 11:00:40 EEST 2011


At lp:maria/5.3

------------------------------------------------------------
revno: 3115
revision-id: monty at askmonty.org-20110812080039-18ny2sm2fp1pbdsa
parent: monty at askmonty.org-20110811130154-zg2daqtt722n635x
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.3
timestamp: Fri 2011-08-12 11:00:39 +0300
message:
  Added new engine message if table was not closed properly (common error with MyISAM and Aria)
  Remove special handling of --opt-update-log ;  This is now same as opt_bin_log.
  Don't abort if you log-bin is not set even if other log variables are set.
-------------- next part --------------
=== modified file 'include/my_base.h'
--- a/include/my_base.h	2011-05-18 10:36:12 +0000
+++ b/include/my_base.h	2011-08-12 08:00:39 +0000
@@ -447,7 +447,8 @@ enum ha_base_keytype {
 #define HA_ERR_TOO_MANY_CONCURRENT_TRXS 178 /*Too many active concurrent transactions */
 #define HA_ERR_ABORTED_BY_USER    179
 #define HA_ERR_DISK_FULL          180
-#define HA_ERR_LAST               180    /* Copy of last error nr */
+#define HA_ERR_NOT_CLOSED         181   /* Table must be checked/repaired */
+#define HA_ERR_LAST               181   /* Copy of last error nr */
 
 /* Number of different errors */
 #define HA_ERR_ERRORS            (HA_ERR_LAST - HA_ERR_FIRST + 1)

=== modified file 'mysql-test/suite/maria/r/maria-recover.result'
--- a/mysql-test/suite/maria/r/maria-recover.result	2011-06-09 18:39:31 +0000
+++ b/mysql-test/suite/maria/r/maria-recover.result	2011-08-12 08:00:39 +0000
@@ -26,7 +26,7 @@ select * from t_corrupted2;
 ThursdayMorningsMarket
 ThursdayMorningsMarketb
 Warnings:
-Error   145     t_corrupted2' is marked as crashed and should be repaired
+Error   181     t_corrupted2' was not closed properly and should be checked/repaired
 Error   1194    t_corrupted2' is marked as crashed and should be repaired
 Error   1034    1 client is using or hasn't closed the table properly
 Error   1034    Wrong base information on indexpage at page: 1

=== modified file 'mysql-test/suite/parts/r/partition_recover_myisam.result'
--- a/mysql-test/suite/parts/r/partition_recover_myisam.result	2011-05-02 17:58:45 +0000
+++ b/mysql-test/suite/parts/r/partition_recover_myisam.result	2011-08-12 08:00:39 +0000
@@ -17,7 +17,7 @@ SELECT * FROM t1_will_crash;
 10
 11
 Warnings:
-Error   145     Table 't1_will_crash' is marked as crashed and should be repaired
+Error   181     Table 't1_will_crash' was not closed properly and should be checked/repaired
 Error   1194    Table 't1_will_crash' is marked as crashed and should be repaired
 Error   1034    1 client is using or hasn't closed the table properly
 Error   1034    Size of indexfile is: 1024        Should be: 2048
@@ -47,7 +47,7 @@ SELECT * FROM t1_will_crash;
 10
 11
 Warnings:
-Error   145     Table 't1_will_crash#P#p1' is marked as crashed and should be repaired
+Error   181     Table 't1_will_crash#P#p1' was not closed properly and should be checked/repaired
 Error   1194    Table 't1_will_crash' is marked as crashed and should be repaired
 Error   1034    1 client is using or hasn't closed the table properly
 Error   1034    Size of indexfile is: 1024        Should be: 2048

=== modified file 'mysys/my_handler_errors.h'
--- a/mysys/my_handler_errors.h	2011-05-18 10:36:12 +0000
+++ b/mysys/my_handler_errors.h	2011-08-12 08:00:39 +0000
@@ -65,5 +65,6 @@ static const char *handler_error_message
   "Too many active concurrent transactions",
   "Row is not visible by the current transaction",
   "Operation was interrupted by end user (probably kill command?)",
-  "Disk full"
+  "Disk full",
+  "Table '%s' was not closed properly and should be checked/repaired"
 };

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-06-27 16:07:24 +0000
+++ b/sql/handler.cc	2011-08-12 08:00:39 +0000
@@ -346,6 +346,7 @@ int ha_init_errors(void)
   SETMSG(HA_ERR_AUTOINC_ERANGE,         ER(ER_WARN_DATA_OUT_OF_RANGE));
   SETMSG(HA_ERR_TOO_MANY_CONCURRENT_TRXS, ER(ER_TOO_MANY_CONCURRENT_TRXS));
   SETMSG(HA_ERR_DISK_FULL,              ER(ER_DISK_FULL));
+  SETMSG(HA_ERR_NOT_CLOSED,             "Table '%s' was not closed properly and should be checked/repaired");
 
   /* Register the error messages for use with my_error(). */
   return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST);
@@ -2857,13 +2858,14 @@ void handler::print_error(int error, myf
     textno=ER_NOT_KEYFILE;
     break;
   case HA_ERR_WRONG_IN_RECORD:
+  case HA_ERR_CRASHED_ON_USAGE:
     SET_FATAL_ERROR;
     textno= ER_CRASHED_ON_USAGE;
     break;
-  case HA_ERR_CRASHED_ON_USAGE:
+  case HA_ERR_NOT_CLOSED:
     SET_FATAL_ERROR;
-    textno=ER_CRASHED_ON_USAGE;
-    break;
+    textno= ER_CRASHED_ON_USAGE;
+    break;                                      // Use original error message
   case HA_ERR_NOT_A_TABLE:
     textno= error;
     break;

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2011-05-28 02:11:32 +0000
+++ b/sql/log_event.cc	2011-08-12 08:00:39 +0000
@@ -151,6 +151,8 @@ static const char *HA_ERR(int i)
   case HA_ERR_LOGGING_IMPOSSIBLE: return "HA_ERR_LOGGING_IMPOSSIBLE";
   case HA_ERR_CORRUPT_EVENT: return "HA_ERR_CORRUPT_EVENT";
   case HA_ERR_ROWS_EVENT_APPLY : return "HA_ERR_ROWS_EVENT_APPLY";
+  case HA_ERR_DISK_FULL: return "HA_ERR_DISK_FULL";
+  case HA_ERR_NOT_CLOSED: return "HA_ERR_NOT_CLOSED";
   }
   return 0;
 }

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-07-15 09:16:46 +0000
+++ b/sql/mysqld.cc	2011-08-12 08:00:39 +0000
@@ -521,7 +521,7 @@ static pthread_cond_t COND_thread_cache,
 
 /* Global variables */
 
-bool opt_update_log, opt_bin_log, opt_ignore_builtin_innodb= 0;
+bool opt_bin_log, opt_ignore_builtin_innodb= 0;
 my_bool opt_log, opt_slow_log, debug_assert_if_crashed_table, opt_help= 0;
 my_bool opt_userstat_running;
 ulong log_output_options;
@@ -821,7 +821,7 @@ static my_bool opt_stack_trace;
 static my_bool opt_bootstrap, opt_myisam_log;
 static int cleanup_done;
 static ulong opt_specialflag, opt_myisam_block_size;
-static char *opt_update_logname, *opt_binlog_index_name;
+static char *opt_binlog_index_name;
 static char *opt_tc_heuristic_recover;
 static char *mysql_home_ptr, *pidfile_name_ptr;
 static int defaults_argc;
@@ -4150,88 +4150,24 @@ static int init_server_components()
     unireg_abort(1);
   }
 
-  /* need to configure logging before initializing storage engines */
-  if (opt_update_log)
+  if (!opt_bin_log)
   {
     /*
-      Update log is removed since 5.0. But we still accept the option.
-      The idea is if the user already uses the binlog and the update log,
-      we completely ignore any option/variable related to the update log, like
-      if the update log did not exist. But if the user uses only the update
-      log, then we translate everything into binlog for him (with warnings).
-      Implementation of the above :
-      - If mysqld is started with --log-update and --log-bin,
-      ignore --log-update (print a warning), push a warning when SQL_LOG_UPDATE
-      is used, and turn off --sql-bin-update-same.
-      This will completely ignore SQL_LOG_UPDATE
-      - If mysqld is started with --log-update only,
-      change it to --log-bin (with the filename passed to log-update,
-      plus '-bin') (print a warning), push a warning when SQL_LOG_UPDATE is
-      used, and turn on --sql-bin-update-same.
-      This will translate SQL_LOG_UPDATE to SQL_LOG_BIN.
-
-      Note that we tell the user that --sql-bin-update-same is deprecated and
-      does nothing, and we don't take into account if he used this option or
-      not; but internally we give this variable a value to have the behaviour
-      we want (i.e. have SQL_LOG_UPDATE influence SQL_LOG_BIN or not).
-      As sql-bin-update-same, log-update and log-bin cannot be changed by the
-      user after starting the server (they are not variables), the user will
-      not later interfere with the settings we do here.
+      Give warnings if log-bin is not set and we are using some variables that
+      will have no effect.
+      We don't abort, as MySQL does, to make it easy to start with
+      --skip-log-bin even if these variables are set to other defaults
+      and also to make these options works in similar ways as other not
+      used options.
     */
-    if (opt_bin_log)
-    {
-      opt_sql_bin_update= 0;
-      sql_print_error("The update log is no longer supported by MySQL in \
-version 5.0 and above. It is replaced by the binary log.");
-    }
-    else
-    {
-      opt_sql_bin_update= 1;
-      opt_bin_log= 1;
-      if (opt_update_logname)
-      {
-        /* as opt_bin_log==0, no need to free opt_bin_logname */
-        if (!(opt_bin_logname= my_once_strdup(opt_update_logname, MYF(MY_WME))))
-        {
-          sql_print_error("Out of memory");
-          return EXIT_OUT_OF_MEMORY;
-        }
-        sql_print_error("The update log is no longer supported by MySQL in \
-version 5.0 and above. It is replaced by the binary log. Now starting MySQL \
-with --log-bin='%s' instead.",opt_bin_logname);
-      }
-      else
-        sql_print_error("The update log is no longer supported by MySQL in \
-version 5.0 and above. It is replaced by the binary log. Now starting MySQL \
-with --log-bin instead.");
-    }
-  }
-  if (opt_log_slave_updates && !opt_bin_log)
-  {
-    sql_print_error("You need to use --log-bin to make "
-                    "--log-slave-updates work.");
-    unireg_abort(1);
-  }
-  if (!opt_bin_log)
-  {
+    if (opt_log_slave_updates)
+    sql_print_warning("Ignoring --log-slave-updates as --log-bin is not set.");
     if (opt_binlog_format_id != BINLOG_FORMAT_UNSPEC)
-    {
-      sql_print_error("You need to use --log-bin to make "
-                      "--binlog-format work.");
-      unireg_abort(1);
-    }
-    else
-    {
-      global_system_variables.binlog_format= BINLOG_FORMAT_STMT;
-    }
+      sql_print_warning("Ignoring --binlog-format as --log-bin is not set.");
   }
-  else
-    if (opt_binlog_format_id == BINLOG_FORMAT_UNSPEC)
-      global_system_variables.binlog_format= BINLOG_FORMAT_STMT;
-    else
-    {
-      DBUG_ASSERT(global_system_variables.binlog_format != BINLOG_FORMAT_UNSPEC);
-    }
+  /* Don't leave binlog_format as unspecified (for easier code) */
+  if (opt_binlog_format_id == BINLOG_FORMAT_UNSPEC)
+    global_system_variables.binlog_format= BINLOG_FORMAT_STMT;
 
   /* Check that we have not let the format to unspecified at this point */
   DBUG_ASSERT((uint)global_system_variables.binlog_format <=
@@ -6581,7 +6517,7 @@ each time the SQL thread starts.",
   {"log-update", OPT_UPDATE_LOG,
    "The update log is deprecated since version 5.0, is replaced by the binary "
    "log and this option just turns on --log-bin instead.",
-   &opt_update_logname, &opt_update_logname, 0, GET_STR,
+   &opt_bin_logname, &opt_bin_logname, 0, GET_STR,
    OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"log-warnings", 'W', "Log some not critical warnings to the general log "
    "file.",
@@ -8456,13 +8392,12 @@ static int mysql_init_variables(void)
   myisam_test_invalid_symlink= test_if_data_home_dir;
 #endif
   opt_log= opt_slow_log= 0;
-  opt_update_log= 0;
   log_output_options= find_bit_type(log_output_str, &log_output_typelib);
   opt_bin_log= 0;
   opt_disable_networking= opt_skip_show_db=0;
   opt_skip_name_resolve= 0;
   opt_ignore_builtin_innodb= 0;
-  opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0;
+  opt_logname= opt_binlog_index_name= opt_slow_logname= 0;
   opt_log_basename= 0;
   opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
   opt_secure_auth= 0;
@@ -8875,8 +8810,7 @@ mysqld_get_one_option(int optid,
     break;
   case (int) OPT_UPDATE_LOG:
     WARN_DEPRECATED(NULL, VER_CELOSIA, "--log-update", "--log-bin");
-    opt_update_log=1;
-    break;
+    /* Fall trough */
   case (int) OPT_BIN_LOG:
     opt_bin_log= test(argument != disabled_my_option);
     break;
@@ -8906,10 +8840,6 @@ mysqld_get_one_option(int optid,
     strmake(pidfile_name, argument, sizeof(pidfile_name)-5);
     strmov(fn_ext(pidfile_name),".pid");
 
-    /* The following is depricated so don't set it by default */
-    if (opt_update_logname)
-      opt_update_logname= argument;
-
     /* check for errors */
     if (!opt_bin_logname || !opt_relaylog_index_name || ! opt_logname ||
         ! opt_slow_logname)
@@ -9639,7 +9569,7 @@ static void set_server_version(void)
   if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"))
     end= strmov(end, "-debug");
 #endif
-  if (opt_log || opt_update_log || opt_slow_log || opt_bin_log)
+  if (opt_log || opt_slow_log || opt_bin_log)
     strmov(end, "-log");                        // This may slow down system
 }
 

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-07-01 08:45:45 +0000
+++ b/sql/table.cc	2011-08-12 08:00:39 +0000
@@ -2377,7 +2377,8 @@ int open_table_from_share(THD *thd, TABL
                            HA_OPEN_IGNORE_IF_LOCKED) | ha_open_flags))))
     {
       /* Set a flag if the table is crashed and it can be auto. repaired */
-      share->crashed= ((ha_err == HA_ERR_CRASHED_ON_USAGE) &&
+      share->crashed= ((ha_err == HA_ERR_CRASHED_ON_USAGE ||
+                        ha_err == HA_ERR_NOT_CLOSED) &&
                        outparam->file->auto_repair() &&
                        !(ha_open_flags & HA_OPEN_FOR_REPAIR));
 

=== modified file 'storage/maria/ma_open.c'
--- a/storage/maria/ma_open.c	2011-07-04 14:27:46 +0000
+++ b/storage/maria/ma_open.c	2011-08-12 08:00:39 +0000
@@ -428,8 +428,11 @@ MARIA_HA *maria_open(const char *name, i
                           "changed: %u  open_count: %u  !locking: %d",
                           open_flags, share->state.changed,
                           share->state.open_count, my_disable_locking));
-      my_errno=((share->state.changed & STATE_CRASHED_ON_REPAIR) ?
-                HA_ERR_CRASHED_ON_REPAIR : HA_ERR_CRASHED_ON_USAGE);
+      if (share->state.changed & STATE_CRASHED)
+        my_errno=((share->state.changed & STATE_CRASHED_ON_REPAIR) ?
+                  HA_ERR_CRASHED_ON_REPAIR : HA_ERR_CRASHED_ON_USAGE);
+      else
+        my_errno= HA_ERR_NOT_CLOSED;
       goto err;
     }
     if (share->state.open_count)
@@ -974,6 +977,7 @@ MARIA_HA *maria_open(const char *name, i
   save_errno=my_errno ? my_errno : HA_ERR_END_OF_FILE;
   if ((save_errno == HA_ERR_CRASHED) ||
       (save_errno == HA_ERR_CRASHED_ON_USAGE) ||
+      (save_errno == HA_ERR_NOT_CLOSED) ||
       (save_errno == HA_ERR_CRASHED_ON_REPAIR))
   {
     LEX_STRING tmp_name;

=== modified file 'storage/myisam/mi_open.c'
--- a/storage/myisam/mi_open.c	2010-12-06 23:15:27 +0000
+++ b/storage/myisam/mi_open.c	2011-08-12 08:00:39 +0000
@@ -234,8 +234,11 @@ MI_INFO *mi_open(const char *name, int m
                           "changed: %u  open_count: %u  !locking: %d",
                           open_flags, share->state.changed,
                           share->state.open_count, my_disable_locking));
-      my_errno=((share->state.changed & STATE_CRASHED_ON_REPAIR) ?
-                HA_ERR_CRASHED_ON_REPAIR : HA_ERR_CRASHED_ON_USAGE);
+      if (share->state.changed & STATE_CRASHED)
+        my_errno=((share->state.changed & STATE_CRASHED_ON_REPAIR) ?
+                  HA_ERR_CRASHED_ON_REPAIR : HA_ERR_CRASHED_ON_USAGE);
+      else
+        my_errno= HA_ERR_NOT_CLOSED;
       goto err;
     }
 
@@ -682,6 +685,7 @@ MI_INFO *mi_open(const char *name, int m
   save_errno=my_errno ? my_errno : HA_ERR_END_OF_FILE;
   if ((save_errno == HA_ERR_CRASHED) ||
       (save_errno == HA_ERR_CRASHED_ON_USAGE) ||
+      (save_errno == HA_ERR_NOT_CLOSED) ||
       (save_errno == HA_ERR_CRASHED_ON_REPAIR))
     mi_report_error(save_errno, name);
   switch (errpos) {



More information about the commits mailing list