List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:January 7 2013 4:14pm
Subject:bzr push into mysql-5.6 branch (tor.didriksen:4848 to 4849) Bug#16016493
View as plain text  
 4849 Tor Didriksen	2013-01-07
      Bug#16016493 TRYING TO LOCK UNITIALIZED MUTEX IN GCOV RUN
      
      During shutdown we may force-close threads using close_connection()
      If we are using one_thread_per_connection, those threads may
      enter into the pool of spare posix threads, and do
      block_on_new_connection(). Those threads may exit that queue
      too late in the end-game: global resources have been deleted when they
      continue to execute.
     @ sql/mysqld.cc
        Move ERR_remove_state up to before we block, waiting for new connection.
        (the problem was the yaSSL::errorsInstance singleton, 
        it might be instantiated by many threads)
     @ sql/sql_class.cc
        Do not grab the global LOCK_prepared_stmt_count mutex in Statement_map DTOR.

    modified:
      sql/mysqld.cc
      sql/sql_class.cc
 4848 Satya Bodapati	2013-01-07 [merge]
      Null Merge mysql-5.5 to mysql-5.6

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2013-01-02 13:22:08 +0000
+++ b/sql/mysqld.cc	2013-01-07 15:47:23 +0000
@@ -2673,6 +2673,21 @@ bool one_thread_per_connection_end(THD *
   */
   DBUG_EXECUTE_IF("sleep_after_lock_thread_count_before_delete_thd", sleep(5););
   remove_global_thread(thd);
+  if (kill_blocked_pthreads_flag)
+  {
+    // Do not block if we are about to shut down
+    block_pthread= false;
+  }
+
+  // Clean up errors now, before possibly waiting for a new connection.
+#ifndef EMBEDDED_LIBRARY
+  ERR_remove_state(0);
+#endif
+
+  /*
+    Using global resources (like mutexes) is unsafe once we have released
+    the mutex here: the server may be shutting down.
+   */
   mysql_mutex_unlock(&LOCK_thread_count);
   delete thd;
 
@@ -2686,9 +2701,6 @@ bool one_thread_per_connection_end(THD *
   DBUG_PRINT("signal", ("Broadcasting COND_thread_count"));
   DBUG_LEAVE;                                   // Must match DBUG_ENTER()
   my_thread_end();
-#ifndef EMBEDDED_LIBRARY
-  ERR_remove_state(0);
-#endif
   mysql_cond_broadcast(&COND_thread_count);
 
   pthread_exit(0);

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2013-01-02 07:54:14 +0000
+++ b/sql/sql_class.cc	2013-01-07 15:47:23 +0000
@@ -3554,11 +3554,11 @@ void Statement_map::reset()
 
 Statement_map::~Statement_map()
 {
-  /* Must go first, hash_free will reset st_hash.records */
-  mysql_mutex_lock(&LOCK_prepared_stmt_count);
-  DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
-  prepared_stmt_count-= st_hash.records;
-  mysql_mutex_unlock(&LOCK_prepared_stmt_count);
+  /*
+    We do not want to grab the global LOCK_prepared_stmt_count mutex here.
+    reset() should already have been called to maintain prepared_stmt_count.
+   */
+  DBUG_ASSERT(st_hash.records == 0);
 
   my_hash_free(&names_hash);
   my_hash_free(&st_hash);

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.6 branch (tor.didriksen:4848 to 4849) Bug#16016493Tor Didriksen5 Feb