Bug #27970 Fix for bug 24507 makes mysql_install_db fail
Submitted: 20 Apr 2007 2:31 Modified: 26 Aug 2007 13:31
Reporter: Arjen Lentz Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.36 OS:Linux
Assigned to: Jani Tolonen CPU Architecture:Any
Tags: bfsm_2007_05_03, regression

[20 Apr 2007 2:31] Arjen Lentz
Description:
upgraded to MySQL 5.0.36 and installs on servers started to hang.
The problem is the fix for http://bugs.mysql.com/bug.php?id=24507.
When you hardcode my_thr_init.c to disable the bug fix, everything works.
I disabled it with: #undef NPTL_PTHREAD_EXIT_BUG

Before disabling it, I got this error:
Error in my_thread_global_end(): 1 threads didn't exit
From running: /usr/bin/mysql_install_db --rpm --user=mysql

On my build server:
getconf GNU_LIBPTHREAD_VERSION --> NPTL 2.3.6
uname -a -->
Linux xxxx 2.6.18.5-gg3-mixed64-32 #1 SMP Tue Jan 9 17:08:45 PST 2007 x86_64 GNU/Linux

On my production server
uname -a -->
Linux xxxx 2.6.11-smp-203.1 #1 [4001144] SMP Tue Oct 24 17:25:20 PDT 2006 x86_64 unknown

This bug fix is enabled by the following. Are you sure that the check is correct? Does it enable the bug fix for more systems than needed?
/*
BUG#24507: Race conditions inside current NPTL pthread_exit() implementation.

If macro NPTL_PTHREAD_EXIT_HACK is defined then a hack described in the bug
report will be implemented inside my_thread_global_init() in my_thr_init.c.

This amounts to spawning a dummy thread which does nothing but executes
pthread_exit(0).

This bug is fixed in version 2.5 of glibc library.

TODO: Remove this code when fixed versions of glibc6 are in common use.
*/

#if defined(TARGET_OS_LINUX) && defined(HAVE_NPTL) && \
defined(__GLIBC__) && ( __GLIBC__ < 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ < 5 )
#define NPTL_PTHREAD_EXIT_BUG 1
#endif

How to repeat:
see description
[23 Apr 2007 20:09] Sveta Smirnova
Thank you for the report.

I can not repeat described behaviour on available machine with NPTL 2.5

Please, provide output of getconf GNU_LIBC_VERSION.
[24 Apr 2007 4:15] Arjen Lentz
sveta:

$ getconf GNU_LIBC_VERSION
glibc 2.3.6
[23 May 2007 0:49] Arjen Lentz
Mark writes:
===
When I run unmodified 5.0.37, the thread that uses the function signal_hand() does not exit and my_thr_end_global prints a warning message about this.
===

Perhaps this helps.
[23 May 2007 1:02] Arjen Lentz
Sorry - addendum to previous comment from Mark:
===
> When I run unmodified 5.0.37, the thread that uses the function signal_hand()
> does not exit and my_thr_end_global prints a warning message about this.

This behavior occurs when this is run: /usr/bin/mysql_install_db --rpm --user=mysql
===
[23 May 2007 1:47] Arjen Lentz
The failure sequence is:
1) server run with bootstrap flag, opt_bootstrap is set
2) when opt_bootstrap is set, unireg_abort is called
3) unireg_abort calls wait_for_signal_thread_to_end
4) wait_for_signal_thread_to_end calls pthread_kill(signal_thread, SIGTERM)
5) pthread_kill fails (returns 1 --> EPERM)
6) wait_for_signal_thread_to_end returns

At this point, the signal thread, which runs signal_hand(), is still running.
Linux man page does not mention EPERM as an error value for pthread_kill.
[30 May 2007 20:35] Sveta Smirnova
Bug #28790 was marked as duplicate of this one
[30 Jul 2007 23:30] Arjen Lentz
What's the status of this 5.0 regression bug?
thanks
[16 Aug 2007 14:27] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/32641

ChangeSet@1.2494, 2007-08-16 17:25:48+03:00, jani@hynda.mysql.fi +3 -0
  Fix for Bug#27970 "Fix for bug 24507 makes mysql_install_db fail"
[21 Aug 2007 14:49] Michael Widenius
Note about this patch:

As we are not able to repeat this problem on our systems, we can't guarantee that the patch will work in all cases as we don't understand why pthread_kill() would on some systems return a not documented error code.

This patch should however provide a solution for the following case:
- We do runtime detection of the threaded library, instead of compile time.
- We check the value of pthread_kill() and repeat (for a while) if we don't get definitive proof that the thread has exited.

Hopefully this will also fix the problem on the problematic system.
[26 Aug 2007 9:43] Bugs System
Pushed into 5.0.48
[26 Aug 2007 9:44] Bugs System
Pushed into 5.1.23-beta
[26 Aug 2007 13:31] Jani Tolonen
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html