Bug #45082 mysql crash because of a long semaphore wait
Submitted: 26 May 2009 3:52 Modified: 16 Jun 2009 8:10
Reporter: ren xijun Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.41-log OS:Linux (Linux 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22 08:32:28 EDT 2007 x86_64)
Assigned to: CPU Architecture:Any
Tags: crash, MySQL, Semaphore, wait

[26 May 2009 3:52] ren xijun
Description:
OS:Linux localhost.localdomain 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22 08:32:28 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
Mysql version: 5.0.41-log

about one or two weeks our mysql server will to restart, and mysql print many long semaphore wait to error logs like:
InnoDB: Warning: a long semaphore wait:
--Thread 1246849344 has waited at lock0lock.c line 3642 for 783.00 seconds the semaphore:
Mutex at 0x2aaab53cf2b8 created file srv0srv.c line 872, lock var 1
waiters flag 1
InnoDB: Warning: a long semaphore wait:
--Thread 1242057024 has waited at trx0trx.c line 715 for 780.00 seconds the semaphore:
Mutex at 0x2aaab53cf2b8 created file srv0srv.c line 872, lock var 1
waiters flag 1
InnoDB: Warning: a long semaphore wait:
--Thread 1317669184 has waited at trx0trx.c line 371 for 780.00 seconds the semaphore:
Mutex at 0x2aaab53cf2b8 created file srv0srv.c line 872, lock var 1
waiters flag 1
InnoDB: ###### Starts InnoDB Monitor for 30 secs to print diagnostic info:
InnoDB: Pending preads 0, pwrites 0
InnoDB: ###### Diagnostic info printed to the standard error stream
InnoDB: Error: semaphore wait has lasted > 600 seconds
InnoDB: We intentionally crash the server, because it appears to be hung.
090524 19:16:55InnoDB: Assertion failure in thread 1147169088 in file srv0srv.c line 2093
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.0/en/forcing-recovery.html
InnoDB: about forcing recovery.
090524 19:16:55 - mysqld got signal 11;
This could be because you hit a bug. It is also possible that this binary
r one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=134217728
read_buffer_size=2093056
max_used_connections=826
max_connections=1050
threads_connected=637
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 19480463 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=(nil)
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0x13c, backtrace may not be correct.
Bogus stack limit or frame pointer, fp=0x13c, stack_bottom=0x44610000, thread_stack=262144, aborting backtrace.
The manual page at http://www.mysql.com/doc/en/Crashing.html contains
information that should help you find out what is causing the crash.

Number of processes running now: 0
090524 19:17:01  mysqld restarted
090524 19:17:11  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
090524 19:17:13  InnoDB: Starting log scan based on checkpoint at

How to repeat:
sorry can not repeat.
[26 May 2009 5:53] Sveta Smirnova
Thank you for the report.

But version 5.0.41 is old and many bugs were fixed since. Please upgrade to current version 5.0.81, try with it and if problem still exists try to find circumstances which lead to this problem. InnoDB monitor can help (http://dev.mysql.com/doc/refman/5.0/en/innodb-monitors.html)
[16 Jun 2009 8:01] ren xijun
Now I found this issue, there have many quartz and crontab to execute at the same time, so there are many transactions, at this time if the OS had not enough memory , then the OS will swap some memory to Disk, but MySQL don't know this, and there a global mutex (kernel_mutex) (MySQL think this mutex should be in memory) been swap to Disk, so cause mysql crash.
[16 Jun 2009 8:10] Sveta Smirnova
Thank you for the feedback.

Closed as "Not a Bug" because last comment.