[Hardy SRU] dash bug causes mysqld_safe to spin at 100% CPU

Bug #675185 reported by Jakob Unterwurzacher
126
This bug affects 18 people
Affects Status Importance Assigned to Milestone
MariaDB
Fix Released
Medium
Kristian Nielsen
Percona Server moved to https://jira.percona.com/projects/PS
Invalid
Medium
Ignacio Nin
5.1
Invalid
Undecided
Ignacio Nin
5.5
Invalid
Medium
Ignacio Nin
dash (Ubuntu)
Invalid
Undecided
Unassigned
mysql-5.1 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Symptoms are: After mysql server upgrades + restarts the old mysqld_safe keeps running and consumes 100% cpu, strace shows:
wait4(4294967295, 0x7fffb3b3d59c, 0, NULL) = -1 ECHILD (No child ...
wait4(4294967295, 0x7fffb3b3d59c, 0, NULL) = -1 ECHILD (No child ...
wait4(4294967295, 0x7fffb3b3d59c, 0, NULL) = -1 ECHILD (No child ...
For more info see the dupes, particularily bug 105457. Does not happen always, for reliable test case see below.

This is a bug (race condition) in dash, partly fixed by http://git.kernel.org/?p=utils/dash/dash.git;a=commit;h=3800d4934391b144fd261a7957aea72ced7d47ea . This fixes the test case and mysqld_safe, but introduces another regression: http://eeek.borgchat.net/lists/dash/msg00268.html (patch for that in the thread)

TEST CASE: Script in the commit message (link above). Allows to reproduce this always, even on Karmic still.

(Proposed fix of using #!/bin/bash instead of #!/bin/sh is not as straigtforward as expected. bash called as sh goes into sh compatibility mode, called as bash it may behave subtle differently)

NOTES: mysqld_safe was replaced by an upstart job in Lucid. But Hardy has support for 3 more years, justifiying a fix.

Tags: patch testcase
Revision history for this message
Jakob Unterwurzacher (jakobunt) wrote :
description: updated
description: updated
tags: added: patch
Revision history for this message
Chuck Short (zulcss) wrote :

Thanks for the patch, can you follow the process outlined by:

https://wiki.ubuntu.com/StableReleaseUpdates

thanks
chuck

Changed in mysql-dfsg-5.0 (Ubuntu):
status: New → Confirmed
Revision history for this message
Jilles Tjoelker (jilles) wrote :

Be sure to verify that the script works with bash's non-POSIX mode as well. A not so well known feature of bash is that it enters POSIX mode when called as "sh". This causes various subtle differences. Therefore, a #!/bin/sh script with /bin/sh -> bash might behave differently from a #!/bin/bash script.

Changed in maria:
status: New → In Progress
assignee: nobody → Kristian Nielsen (knielsen)
importance: Undecided → Medium
Revision history for this message
Martin Pitt (pitti) wrote :

Please get this fixed in natty first (or at least alongside). The patch looks okay as a minimal workaround, so please get it uploaded.

Revision history for this message
Jakob Unterwurzacher (jakobunt) wrote :

Thing is, mysqld_safe isn't used anymore since Lucid as upstart has taken over (the file is still there though).

description: updated
description: updated
Revision history for this message
Kristian Nielsen (knielsen) wrote :

I fixed this for mariadb by adding a patch to the .deb packaging that puts #!/bin/bash in the header of mysqld_safe.

Fix will be available from 5.1.52 and 5.2.4.

Changed in maria:
status: In Progress → Fix Committed
Changed in maria:
milestone: none → 5.1
Revision history for this message
Kristian Nielsen (knielsen) wrote :

Fixed in MariaDB 5.2.4 and 5.1.53

Changed in maria:
status: Fix Committed → Fix Released
Chuck Short (zulcss)
affects: mysql-dfsg-5.0 (Ubuntu) → mysql-5.1 (Ubuntu)
Stewart Smith (stewart)
Changed in percona-server:
importance: Undecided → Medium
tags: added: testcase
Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

I tested the testcase in the commit on Precise and there seem to no issue there
(probably fixed there).

Also, it is not the right approach to change #!/bin/sh to #!/bin/bash since
former invokes POSIX compatibility mode and if dash has problems on any
platform, then that should be fixed rather than changing it in mysqld_safe or
#!/bin/sh needs to pointed elsewhere (or with update-alternatives).

Regarding the init scripts, I see that Percona Server is not packaged with
upstart script (hence vulnerable to this if on a platform with a buggy dash) as
mysql-server-55 does. I will open a separate issue to add that.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

lp:1053183 is the issue for providing upstart scripts with percona-server.

description: updated
Revision history for this message
Gabriel Ramirez (gabriel1109) wrote :

Hello, we apologize for the delayed response, but as Ubuntu has moved on from upstart to systemd, it will not affect newer releases in the same way so we will close this one out

Changed in mysql-5.1 (Ubuntu):
status: Confirmed → Invalid
Changed in dash (Ubuntu):
status: New → Invalid
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-1164

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.