List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:October 18 2010 11:31am
Subject:bzr push into mysql-5.5-bugteam branch (tor.didriksen:3246 to 3247) Bug#52172
View as plain text  
 3247 Tor Didriksen	2010-10-18 [merge]
      Bug#52172 test binlog.binlog_index needs --skip-core-file to avoid leaving core files
      
      For crash testing: kill the server without generating core file.
      
      include/my_dbug.h
        Use kill(getpid(), SIGKILL) which cannot be caught by signal handlers.
        All DBUG_XXX macros should be no-ops in optimized mode, do that for DBUG_ABORT as well.
      sql/handler.cc
        Kill server without generating core.
      sql/log.cc
        Kill server without generating core.

    modified:
      include/my_dbug.h
      sql/handler.cc
      sql/log.cc
 3246 Li-Bing.Song@stripped	2010-10-16 [merge]
      Manual merge

    added:
      mysql-test/extra/rpl_tests/rpl_stop_slave.test
      mysql-test/suite/rpl/r/rpl_stop_slave.result
      mysql-test/suite/rpl/t/rpl_stop_slave.test
    modified:
      sql/slave.cc
      sql/sql_parse.cc
=== modified file 'include/my_dbug.h'
--- a/include/my_dbug.h	2010-07-15 11:16:06 +0000
+++ b/include/my_dbug.h	2010-10-18 11:27:52 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -13,8 +13,18 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#ifndef _dbug_h
-#define _dbug_h
+#ifndef MY_DBUG_INCLUDED
+#define MY_DBUG_INCLUDED
+
+#ifndef __WIN__
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <signal.h>
+#endif  /* not __WIN__ */
 
 #ifdef  __cplusplus
 extern "C" {
@@ -111,6 +121,20 @@ extern  const char* _db_get_func_(void);
 #define DBUG_CRASH_VOID_RETURN \
   DBUG_CHECK_CRASH (_db_get_func_(), "_crash_return")
 
+/*
+  Make the program fail, without creating a core file.
+  abort() will send SIGABRT which (most likely) generates core.
+  Use SIGKILL instead, which cannot be caught.
+  We also pause the current thread, until the signal is actually delivered.
+  An alternative would be to use _exit(EXIT_FAILURE),
+  but then valgrind would report lots of memory leaks.
+ */
+#ifdef __WIN__
+#define DBUG_SUICIDE() DBUG_ABORT()
+#else
+#define DBUG_SUICIDE() (_db_flush_(), kill(getpid(), SIGKILL), pause())
+#endif
+
 #else                                           /* No debugger */
 
 #define DBUG_ENTER(a1)
@@ -139,10 +163,11 @@ extern  const char* _db_get_func_(void);
 #define DBUG_EXPLAIN_INITIAL(buf,len)
 #define DEBUGGER_OFF                    do { } while(0)
 #define DEBUGGER_ON                     do { } while(0)
-#define DBUG_ABORT()                    abort()
+#define DBUG_ABORT()                    do { } while(0)
 #define DBUG_CRASH_ENTER(func)
 #define DBUG_CRASH_RETURN(val)          do { return(val); } while(0)
 #define DBUG_CRASH_VOID_RETURN          do { return; } while(0)
+#define DBUG_SUICIDE()                  do { } while(0)
 
 #endif
 
@@ -164,4 +189,5 @@ void debug_sync_point(const char* lock_n
 #ifdef	__cplusplus
 }
 #endif
-#endif
+
+#endif /* MY_DBUG_INCLUDED */

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2010-10-06 14:34:28 +0000
+++ b/sql/handler.cc	2010-10-18 11:27:52 +0000
@@ -1156,7 +1156,7 @@ int ha_commit_trans(THD *thd, bool all)
     uint rw_ha_count;
     bool rw_trans;
 
-    DBUG_EXECUTE_IF("crash_commit_before", DBUG_ABORT(););
+    DBUG_EXECUTE_IF("crash_commit_before", DBUG_SUICIDE(););
 
     /* Close all cursors that can not survive COMMIT */
     if (is_real_trans)                          /* not a statement commit */
@@ -1208,7 +1208,7 @@ int ha_commit_trans(THD *thd, bool all)
         }
         status_var_increment(thd->status_var.ha_prepare_count);
       }
-      DBUG_EXECUTE_IF("crash_commit_after_prepare", DBUG_ABORT(););
+      DBUG_EXECUTE_IF("crash_commit_after_prepare", DBUG_SUICIDE(););
       if (error || (is_real_trans && xid &&
                     (error= !(cookie= tc_log->log_xid(thd, xid)))))
       {
@@ -1216,13 +1216,13 @@ int ha_commit_trans(THD *thd, bool all)
         error= 1;
         goto end;
       }
-      DBUG_EXECUTE_IF("crash_commit_after_log", DBUG_ABORT(););
+      DBUG_EXECUTE_IF("crash_commit_after_log", DBUG_SUICIDE(););
     }
     error=ha_commit_one_phase(thd, all) ? (cookie ? 2 : 1) : 0;
-    DBUG_EXECUTE_IF("crash_commit_before_unlog", DBUG_ABORT(););
+    DBUG_EXECUTE_IF("crash_commit_before_unlog", DBUG_SUICIDE(););
     if (cookie)
       tc_log->unlog(cookie, xid);
-    DBUG_EXECUTE_IF("crash_commit_after", DBUG_ABORT(););
+    DBUG_EXECUTE_IF("crash_commit_after", DBUG_SUICIDE(););
     RUN_HOOK(transaction, after_commit, (thd, FALSE));
 end:
     if (rw_trans)

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-09-29 14:26:32 +0000
+++ b/sql/log.cc	2010-10-18 11:27:52 +0000
@@ -2849,7 +2849,7 @@ bool MYSQL_BIN_LOG::open(const char *log
     sql_print_error("MSYQL_BIN_LOG::open failed to sync the index file.");
     DBUG_RETURN(1);
   }
-  DBUG_EXECUTE_IF("crash_create_non_critical_before_update_index", DBUG_ABORT(););
+  DBUG_EXECUTE_IF("crash_create_non_critical_before_update_index", DBUG_SUICIDE(););
 #endif
 
   write_error= 0;
@@ -2946,7 +2946,7 @@ bool MYSQL_BIN_LOG::open(const char *log
     if (write_file_name_to_index_file)
     {
 #ifdef HAVE_REPLICATION
-      DBUG_EXECUTE_IF("crash_create_critical_before_update_index", DBUG_ABORT(););
+      DBUG_EXECUTE_IF("crash_create_critical_before_update_index", DBUG_SUICIDE(););
 #endif
 
       DBUG_ASSERT(my_b_inited(&index_file) != 0);
@@ -2965,7 +2965,7 @@ bool MYSQL_BIN_LOG::open(const char *log
         goto err;
 
 #ifdef HAVE_REPLICATION
-      DBUG_EXECUTE_IF("crash_create_after_update_index", DBUG_ABORT(););
+      DBUG_EXECUTE_IF("crash_create_after_update_index", DBUG_SUICIDE(););
 #endif
     }
   }
@@ -3428,7 +3428,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay
   /* Store where we are in the new file for the execution thread */
   flush_relay_log_info(rli);
 
-  DBUG_EXECUTE_IF("crash_before_purge_logs", DBUG_ABORT(););
+  DBUG_EXECUTE_IF("crash_before_purge_logs", DBUG_SUICIDE(););
 
   mysql_mutex_lock(&rli->log_space_lock);
   rli->relay_log.purge_logs(to_purge_if_included, included,
@@ -3556,7 +3556,7 @@ int MYSQL_BIN_LOG::purge_logs(const char
       break;
   }
 
-  DBUG_EXECUTE_IF("crash_purge_before_update_index", DBUG_ABORT(););
+  DBUG_EXECUTE_IF("crash_purge_before_update_index", DBUG_SUICIDE(););
 
   if ((error= sync_purge_index_file()))
   {
@@ -3571,7 +3571,7 @@ int MYSQL_BIN_LOG::purge_logs(const char
     goto err;
   }
 
-  DBUG_EXECUTE_IF("crash_purge_critical_after_update_index", DBUG_ABORT(););
+  DBUG_EXECUTE_IF("crash_purge_critical_after_update_index", DBUG_SUICIDE(););
 
 err:
   /* Read each entry from purge_index_file and delete the file. */
@@ -3581,7 +3581,7 @@ err:
                     " that would be purged.");
   close_purge_index_file();
 
-  DBUG_EXECUTE_IF("crash_purge_non_critical_after_update_index", DBUG_ABORT(););
+  DBUG_EXECUTE_IF("crash_purge_non_critical_after_update_index", DBUG_SUICIDE(););
 
   if (need_mutex)
     mysql_mutex_unlock(&LOCK_index);
@@ -5177,7 +5177,7 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_C
                           DBUG_PRINT("info", ("error writing binlog cache: %d",
                                                write_error));
                         DBUG_PRINT("info", ("crashing before writing xid"));
-                        DBUG_ABORT();
+                        DBUG_SUICIDE();
                       });
 
       if ((write_error= write_cache(cache, false, false)))
@@ -5192,7 +5192,7 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_C
       bool synced= 0;
       if (flush_and_sync(&synced))
         goto err;
-      DBUG_EXECUTE_IF("half_binlogged_transaction", DBUG_ABORT(););
+      DBUG_EXECUTE_IF("half_binlogged_transaction", DBUG_SUICIDE(););
       if (cache->error)				// Error on read
       {
         sql_print_error(ER(ER_ERROR_ON_READ), cache->file_name, errno);


Attachment: [text/bzr-bundle] bzr/tor.didriksen@oracle.com-20101018112752-kpynpio8prphfyaa.bundle
Thread
bzr push into mysql-5.5-bugteam branch (tor.didriksen:3246 to 3247) Bug#52172Tor Didriksen18 Oct