Voytek:

Found the problem with your signal 11 with strange traces from inside 
LinuxThreads. This was a hard concurrency bug - the problem was that a memory 
reference passed to pthread_create was getting invalidated by the thread that 
pthread_create was launching before pthread_create would right to that value. 
Took me a while to figure this out - I have scrutinized the entire thread 
creation mechanism in LinuxThreads suspecting a bad mmap or munmap somewhere 
before I realized the problem had nothing to do with LinuxThreads internal 
code.

I believe the problem has existed for as long as MySQL has been around - back 
then the machines were just not fast enough to make this condition happen 
frequently enough for someone to be able to create a repeatable case. I have 
fixed it by extending the critical region. Here is the patch:

--- 1.155/sql/mysqld.cc Sat Mar 24 16:02:25 2001
+++ edited/mysqld.cc    Sat Mar 24 23:05:23 2001
@@ -2091,7 +2091,6 @@
       threads.append(thd);
       DBUG_PRINT("info",(("creating thread %d"), thd->thread_id));
       thd->connect_time = time(NULL);
-      (void) pthread_mutex_unlock(&LOCK_thread_count);
       if ((error=pthread_create(&thd->real_id,&connection_attrib,
                                handle_one_connection,
                                (void*) thd)))
@@ -2099,7 +2098,6 @@
        DBUG_PRINT("error",
                   ("Can't create thread to handle request (error %d)",
                    error));
-       (void) pthread_mutex_lock(&LOCK_thread_count);
        thread_count--;
        thd->killed=1;                          // Safety
        (void) pthread_mutex_unlock(&LOCK_thread_count);
@@ -2110,6 +2108,8 @@
        (void) pthread_mutex_unlock(&LOCK_thread_count);
        DBUG_VOID_RETURN;
       }
+
+      (void) pthread_mutex_unlock(&LOCK_thread_count);
     }
   }
   DBUG_PRINT("info",(("Thread %d created"), thd->thread_id));

The fix will be available in 3.23.36.

-- 
MySQL Development Team
   __  ___     ___ ____  __ 
  /  |/  /_ __/ __/ __ \/ /   Sasha Pachev <[EMAIL PROTECTED]>
 / /|_/ / // /\ \/ /_/ / /__  MySQL AB, http://www.mysql.com/
/_/  /_/\_, /___/\___\_\___/  Provo, Utah, USA
       <___/                  

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to