MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:July 27 2007 1:39pm
Subject:bk commit into 5.1 tree (anozdrin:1.2561) BUG#28030
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of alik. When alik does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-07-27 17:39:01+04:00, anozdrin@ibm. +4 -0
  Fix for BUG#28030: test im_instance_conf fails with an assert.
  
  The problem was a race condition on shutdown -- when IM got shutdown
  request while a guarded mysqld is starting. In this case the Guardian
  thread tried to stop the mysqld, but might fail if the mysqld hadn't
  created pid-file so far. When this happened, the mysqld-monitor thread
  didn't stop, so the assert in Thread_registry happened.
  
  The fix is to make several attempts to stop mysqld if it is active.

  server-tools/instance-manager/guardian.cc@stripped, 2007-07-27 17:38:59+04:00, anozdrin@ibm. +30 -1
    Try to stop mysqld several times if it is still active.

  server-tools/instance-manager/instance.cc@stripped, 2007-07-27 17:38:59+04:00, anozdrin@ibm. +5 -3
    Make Instance::kill_mysqld() to return operation status.

  server-tools/instance-manager/instance.h@stripped, 2007-07-27 17:38:59+04:00, anozdrin@ibm. +1 -1
    Make Instance::kill_mysqld() to return operation status.

  server-tools/instance-manager/thread_registry.cc@stripped, 2007-07-27 17:38:59+04:00, anozdrin@ibm. +6 -2
    Log unregistered thread ids.

diff -Nrup a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc
--- a/server-tools/instance-manager/guardian.cc	2007-02-23 14:13:48 +03:00
+++ b/server-tools/instance-manager/guardian.cc	2007-07-27 17:38:59 +04:00
@@ -403,6 +403,8 @@ void Guardian::init()
 
 void Guardian::stop_instances()
 {
+  static const int NUM_STOP_ATTEMPTS = 100;
+
   Instance_map::Iterator instances_it(instance_map);
   Instance *instance;
 
@@ -438,7 +440,34 @@ void Guardian::stop_instances()
 
     /* Request mysqld to stop. */
 
-    instance->kill_mysqld(SIGTERM);
+    bool instance_stopped= FALSE;
+
+    for (int cur_attempt= 0; cur_attempt < NUM_STOP_ATTEMPTS; ++cur_attempt)
+    {
+      if (!instance->kill_mysqld(SIGTERM))
+      {
+        instance_stopped= TRUE;
+        break;
+      }
+
+      if (!instance->is_active())
+      {
+        instance_stopped= TRUE;
+        break;
+      }
+
+      /* Sleep for 0.3 sec and check again. */
+
+      my_sleep(300000);
+    }
+
+    /*
+      Abort if we failed to stop mysqld instance. That should not happen,
+      but if it happened, we don't know what to do and prefer to have clear
+      failure with coredump.
+    */
+
+    DBUG_ASSERT(instance_stopped);
 
     instance->unlock();
   }
diff -Nrup a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc
--- a/server-tools/instance-manager/instance.cc	2007-07-23 17:05:48 +04:00
+++ b/server-tools/instance-manager/instance.cc	2007-07-27 17:38:59 +04:00
@@ -771,7 +771,7 @@ bool Instance::stop_mysqld()
     These operations should also be used in Guardian to manage instances.
 */
 
-void Instance::kill_mysqld(int signum)
+bool Instance::kill_mysqld(int signum)
 {
   pid_t mysqld_pid= options.load_pid();
 
@@ -780,7 +780,7 @@ void Instance::kill_mysqld(int signum)
     log_info("Instance '%s': no pid file to send a signal (%d).",
              (const char *) get_name()->str,
              (int) signum);
-    return;
+    return TRUE;
   }
 
   log_info("Instance '%s': sending %d to %d...",
@@ -792,7 +792,7 @@ void Instance::kill_mysqld(int signum)
   {
     log_info("Instance '%s': kill() failed.",
              (const char *) get_name()->str);
-    return;
+    return TRUE;
   }
 
   /* Kill suceeded */
@@ -804,6 +804,8 @@ void Instance::kill_mysqld(int signum)
     /* After sucessful hard kill the pidfile need to be removed */
     options.unlink_pidfile();
   }
+
+  return FALSE;
 }
 
 
diff -Nrup a/server-tools/instance-manager/instance.h b/server-tools/instance-manager/instance.h
--- a/server-tools/instance-manager/instance.h	2007-01-03 00:18:05 +03:00
+++ b/server-tools/instance-manager/instance.h	2007-07-27 17:38:59 +04:00
@@ -104,7 +104,7 @@ public:
 
   bool start_mysqld();
   bool stop_mysqld();
-  void kill_mysqld(int signo);
+  bool kill_mysqld(int signo);
 
   void lock();
   void unlock();
diff -Nrup a/server-tools/instance-manager/thread_registry.cc b/server-tools/instance-manager/thread_registry.cc
--- a/server-tools/instance-manager/thread_registry.cc	2007-07-25 13:31:44 +04:00
+++ b/server-tools/instance-manager/thread_registry.cc	2007-07-27 17:38:59 +04:00
@@ -64,8 +64,12 @@ Thread_registry::~Thread_registry()
   /* Check that no one uses the repository. */
   pthread_mutex_lock(&LOCK_thread_registry);
 
-  if (head.next != &head)
-    log_error("Not all threads died properly\n");
+  for (Thread_info *ti= head.next; ti != &head; ti= ti->next)
+  {
+    log_error("Thread_registry: unregistered thread: %lu.",
+              (unsigned long) ti->thread_id);
+  }
+
   /* All threads must unregister */
   DBUG_ASSERT(head.next == &head);
 
Thread
bk commit into 5.1 tree (anozdrin:1.2561) BUG#28030Alexander Nozdrin27 Jul