List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:January 30 2012 5:35am
Subject:bzr push into mysql-trunk branch (Dmitry.Shulga:3799 to 3800) Bug#13608371
View as plain text  
 3800 Dmitry Shulga	2012-01-30
      This patch fixes bug#13608371 (formerly known as bug 62311):
      segfault in mysqld during early SIGHUP handling.
      
      If during server start up some signals like SIGHUP are caught before full
      server initialization has been done then server may crash.
      
      The reason for this bug is that there was a race condition between signal
      handler thread and main thread that was doing server initialization.
      For example, if SIGHUP signal was delivered to server and caught by signal
      handler thread before server had completed initialization of Event_scheduler
      then server crashed when try to access to uninitialized event_scheduler
      instance during signal handling.
      
      To avoid such race condition we suspend signal processing before full
      initialization of all server components has been completed successfully.
      It's achieved by waiting for on COND_server_started conditional variable
      until a flag mysqld_server_started is true.
      
      Moreover superfluous call of pthread_sigmask() to set thread signal mask
      was removed since all signal have been already blocked during execution
      of my_init_signal().
      
      Also call of mysql_cond_broadcast(&COND_thread_count) at signal_hand()
      was moved under protection of mutex LOCK_thread_count to provide deterministic
      schedule behaviour.

    modified:
      sql/mysqld.cc
 3799 Christopher Powers	2012-01-28
      Bug#13440472 MANY VALGRIND FAILURES ON DAILY-TRUNK
        
      Added Valgrind suppression case for add_pfs_instr_to_array().

    modified:
      mysql-test/valgrind.supp
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2012-01-26 17:49:01 +0000
+++ b/sql/mysqld.cc	2012-01-30 05:34:32 +0000
@@ -2710,10 +2710,21 @@ pthread_handler_t signal_hand(void *arg 
     should not be any other mysql_cond_signal() calls.
   */
   mysql_mutex_lock(&LOCK_thread_count);
-  mysql_mutex_unlock(&LOCK_thread_count);
   mysql_cond_broadcast(&COND_thread_count);
+  mysql_mutex_unlock(&LOCK_thread_count);
+
+  /*
+    Waiting for until mysqld_server_started != 0
+    to ensure that all server components has been successfully
+    initialized. This step is mandatory since signal processing
+    could be done safely only when all server components
+    has been initialized.
+  */
+  mysql_mutex_lock(&LOCK_server_started);
+  while (!mysqld_server_started)
+    mysql_cond_wait(&COND_server_started, &LOCK_server_started);
+  mysql_mutex_unlock(&LOCK_server_started);
 
-  (void) pthread_sigmask(SIG_BLOCK,&set,NULL);
   for (;;)
   {
     int error;          // Used when debugging

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (Dmitry.Shulga:3799 to 3800) Bug#13608371Dmitry Shulga30 Jan