Bug #39552 | Falcon hangs when system memory is exhausted | ||
---|---|---|---|
Submitted: | 20 Sep 2008 5:10 | Modified: | 15 May 2009 17:03 |
Reporter: | Allan Packer | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Falcon storage engine | Severity: | S2 (Serious) |
Version: | 6.0.7 | OS: | Any |
Assigned to: | Olav Sandstå | CPU Architecture: | Any |
Tags: | F_ERROR HANDLING, falcon, hang |
[20 Sep 2008 5:10]
Allan Packer
[9 Oct 2008 17:01]
MySQL Verification Team
Thank you for the bug report. Could you please try with latest source?. I can't repeat instead I got the below error message: mysql 6.0 > insert into tu (col1) select col1 from tu; ERROR 1296 (HY000): Got error 305 'record memory is exhausted' from Falcon mysql 6.0 >
[10 Nov 2008 0:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[10 Nov 2008 5:50]
Kevin Lewis
If the system is fully out of memory, MemMgr::memoryIsExhausted() uses a SQLError object to display this out-of-memory message. There are 4 JString fields as members of the SQLError class. The SQLError object must allocate more memory for these JString objects. However, in this bug report, it is highly unlikely that this second alloc would have failed. The first allocation was a larger piece of memory for the DeferredIndex object. The second was much smaller for these JStrings. In fact, this call stack shows that the second call to MemMgr::alloc did not even try to allocate any memory. MemMgr::alloc uses a Mutex in the Sync() constructor instead of a SyncObject because Mutexes are faster than SyncObjects and this does not need shared locks. This call stack waits indefinitely trying to get an exclusive lock on this Mutex for the second time by the same thread. We had this problem once before on Linux. That was for a changeset I made for Bug#34890 (falcon_bug_22150.test fails on Pushbuild). After the main changeset was pushed where SyncObject::mutex was held longer to avoid a missed signal, we found a stall on Linux only because the mutex.lock() in SyncObject::stalled() was now a recursive lock by the same thread. The comment for removing that extra mutex.lock() was; "Do not allow recursive locking of mutexes since it is not supported by pthreads." Actually it is supported by pthreads if the mutex type is PTHREAD_MUTEX_RECURSIVE, but Falcon does not use that. Unlike Linux pthreads, Windows allows recursive locks for CRITICAL_SECTIONs which is what is used for a Mutex. In addition, the more complex SyncObject also allows recursion. The following lines do not allow multiple locks by the same thread under #ifdef _PTHREADS or #ifdef SOLARIS_MT storage\falcon\Mutex.cpp(79): int ret = pthread_mutex_lock (&mutex); storage\falcon\Mutex.cpp(84): int ret = mutex_lock (&mutex); So there are two ways to fix this problem. 1) Allow recursive locks for the Falcon Mutex class. 2) Do not allow MemMgr::memoryIsExhausted() to use a SQLError class which contains JStrings, or anything else that may need to allocate memory. I am sssigning this to Olav since if the solution should be number 1, we will need to make mutex_lock() recursive on Solaris.
[3 Apr 2009 10:19]
Olav Sandstå
This is caused by the same issue as in bug#40155. The main difference is that in this case the mysqld process is hanging while in Bug#40155 it ended in a crash situation. A patch for Bug#40155 has been made and committed that should also fix this issue. Setting the status for the bug to patch queued.
[3 Apr 2009 10:22]
Olav Sandstå
Patch is merged into mysql-6.0.
[15 May 2009 17:03]
MC Brown
A note has been added to the 6.0.11 changelog: When using Falcon and the system runs out of all memory and swap space, mysqld could hang while attempting to write an error message.