Bug #43488 | Crash in Table::fetchForUpdate (update conflict) when using LIMIT query | ||
---|---|---|---|
Submitted: | 8 Mar 2009 21:22 | Modified: | 15 May 2009 17:03 |
Reporter: | John Embretsen | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Falcon storage engine | Severity: | S1 (Critical) |
Version: | 6.0.11-bzr | OS: | Any |
Assigned to: | Lars-Erik Bjørk | CPU Architecture: | Any |
Tags: | F_LIMIT, stress_tx |
[8 Mar 2009 21:22]
John Embretsen
[8 Mar 2009 21:40]
John Embretsen
On a related note, Bug#43447 (Crash when executing SELECT ... LIMIT n FOR UPDATE query) occurred when running the same test against InnoDB. That problem seemed to be caused by the MRR optimizer feature (workaround was to disable MRR). However, that does not seem to be related to this bug (crash occurs regardless of MRR options).
[9 Mar 2009 8:07]
Kevin Lewis
An update conflict is a very common in Falcon when using consistent_read. This exception is normally caught. But in this call stack which uses IndexWalker::getValidatedRecord, it caused a crash.
[9 Mar 2009 9:18]
Olav Sandstå
One comment to the code: This SQLError is thrown just three lines after the assert that is hit in bug#41357. In that bug we get into this part of the switch statement due to operating on a deleted transaction object. Thus, it might that after fixing bug#41357 we will never end up in this situation again where the SQLError is thrown and not caught. bug#41357 is most likely to occur in situations where we have multiple concurrent threads - just as in this test case.
[9 Mar 2009 9:47]
Ann Harrison
It's quite likely that there should be a catch for update conflict in IndexWalker - Jim wrote it and he has yet to internalize that a select can get update conflicts. (Nor have I for that matter).
[10 Mar 2009 8:31]
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/68732 3059 lars-erik.bjork@sun.com 2009-03-10 This is a patch for Bug #43488 Crash in Table::fetchForUpdate (update conflict) when using LIMIT query This crash was due to missing exception handling when calling fetchForUpdate when fetching records through the IndexWalker. The exception handling introduced in this patch is split in two parts. The first part does the necessary cleanup in IndexWalker::getValidatedRecord and re-throws the exception. The exception is re-caught in StorageDatabase::nextIndexed, where we return the correct error. I have not included any test files for this patch, because it is not easily reproducible without a larger framework as described in the bug report. Modified file 'storage/falcon/IndexWalker.cpp' ---------------------------------------------- Added try - catch logic, doing the necessary cleanup in the case of an exception. This implementation is based on the similar cases in StorageDatabase.cpp. After the cleanup has been done, we re-throw the exception, so that we can return the appropriate error in StorageDatabase::nextIndexed Modified file 'storage/falcon/StorageDatabase.cpp' -------------------------------------------------- Recatch the exception and return the appropriate error. modified: storage/falcon/IndexWalker.cpp storage/falcon/StorageDatabase.cpp
[10 Mar 2009 10:11]
John Embretsen
I can confirm that with the committed patch applied I no longer see the crash with the same stress test, while it crashes without the patch. Most likely the update conlicts result in the following error: Error 1020 Record has changed since last read in table 't1' which I do observe sometimes when executing the SELECT ... LIMIT ... FOR UPDATE queries. WorkLog#3715 http://forge.mysql.com/worklog/task.php?id=3715 indicates that this is the type of error the client sees when there is an update conflict. Patch OK to push from my perspective :)
[10 Mar 2009 23:04]
Kevin Lewis
Code is OK to push with the changes I suggested.
[16 Mar 2009 9:04]
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/69265 3060 lars-erik.bjork@sun.com 2009-03-16 Small changes to patch for Bug #43488 Crash in Table::fetchForUpdate (update conflict) when using LIMIT query, based on Kevin's review comments modified: storage/falcon/IndexWalker.cpp
[2 Apr 2009 17:39]
Bugs System
Pushed into 6.0.11-alpha (revid:hky@sun.com-20090402144811-yc5kp8g0rjnhz7vy) (version source revid:lars-erik.bjork@sun.com-20090316090642-uwkwrdmeaa8bmgmm) (merge vers: 6.0.11-alpha) (pib:6)
[15 May 2009 17:03]
MC Brown
A note has been added to the 6.0.11 changelog: Executing a LIMIT ... FOR UPDATE statement on a Falcon table when using transactions with concurrent threads could cause a crash because the record information cannot be accessed correctly.