Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 3
[solved] Database deadlocks and serialization failures—fix inside
 
ictconnection
Jr. Member
 
Total Posts:  17
Joined:  2010-11-20
 

Hello,

Would someone be so kind to past the content of the new app/code/core/Mage/Sales/Model/Abstract.php file.
I am on windows, so patching is not possible.

Regards,

Martijn

 
Magento Community Magento Community
Magento Community
Magento Community
 
Shaughn
Member
 
Avatar
Total Posts:  44
Joined:  2010-06-29
South Africa
 
Anton Makarenko - 22 May 2012 01:34 PM

ShopGuy - 10 February 2009 01:28 PM
In order to fix this error replace the _execute() in lib/Zend/Db/Statement/Pdo.php. What it does is retries the query.
...
Also, to replace a bug in Zend that can cause an infinite loop replace raw_query() in lib/Varien/Db/Adapter/Mysqli.php with the following:

The only thing changed is the above is $tries is moved outside the loop so it is not reset on every loop and it ensures an exception is thrown after 10 tries.

This is a workaround, a very dangerous one.

A true solution is to design application in such a way, that collisions will not occur at the first place.

I have found a problem in sales model that caused deadlocks during orders placement. The issue was that it tried to write into sales_flat_order_grid table within transaction right after insert into sales_flat_order table. With concurrent queries it caused locking collisions. While making DB adapter “retry” query could mitigate the problem a bit, the real solution is to move stuff of sales_flat_order_grid out of the transaction.

The patch is attached. It applies for Magento CE v1.4.1.0 / EE 1.8.0.0 and above.

I had the same problem but i only ever got the error during checkout while either “Catalog URL Rewrites” index or “Product Flat Data” index was being re-indexed.

This may suggest why most of you got the error on some occasions and not all the time.

I have applied the patch provided by Anton Makarenko and it seems to have resolved the issue, currently tested on EE 1.12.0.2. I have opened up a support ticket just to confirm this patch can be used.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vanquish
Jr. Member
 
Total Posts:  24
Joined:  2012-07-01
 

This problem also occurs outside of the sales order process and is a fundamental issue with high volume transaction and processing environments. Obviously it is not ideal but the retry fix on _execute works, it is a core code base issue and unlikely to be resolved any time soon.

 
Magento Community Magento Community
Magento Community
Magento Community
 
flimmit
Jr. Member
 
Avatar
Total Posts:  5
Joined:  2007-12-20
Vienna
 

We can confirm that since this patch no more deadlock occured. We integrated this patch at one of our customers with peaks of 500 orders per hour. Before we had several deadlocks. Now they are zero!

 
Magento Community Magento Community
Magento Community
Magento Community
 
derak_kilgo
Jr. Member
 
Total Posts:  1
Joined:  2012-06-11
 

Is there an issue in the bug tracker for this issue/patch?

 
Magento Community Magento Community
Magento Community
Magento Community
 
lauracorra
Jr. Member
 
Total Posts:  1
Joined:  2012-07-02
 

Has this issue been resolved in Magento 1.13?

 
Magento Community Magento Community
Magento Community
Magento Community
 
cmuench
Jr. Member
 
Avatar
Total Posts:  15
Joined:  2009-10-27
Mainz
 

In EE 1.13 it’s fixed. In 1.12 not!

/**
     * Processing object after save data
     * Updates relevant grid table records.
     *
     * @return Mage_Core_Model_Abstract
     */
    public function afterCommitCallback()
    
{
        
if (!$this->getForceUpdateGridRecords()) {
            $this
->_getResource()->updateGridRecords($this->getId());
        
}
        
return parent::afterCommitCallback();
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
netalico
Jr. Member
 
Total Posts:  3
Joined:  2011-06-08
 

Does anyone have that patch from Anton Makarenko?

 
Magento Community Magento Community
Magento Community
Magento Community
 
campsaver
Jr. Member
 
Total Posts:  28
Joined:  2010-05-04
Logan, Utah USA
 
netalico - 06 November 2013 08:07 AM

Does anyone have that patch from Anton Makarenko?

the patch is on the previous page, the first page of the thread as an inbedded download.

 
Magento Community Magento Community
Magento Community
Magento Community
 
randomresult
Jr. Member
 
Total Posts:  2
Joined:  2007-12-06
 

When trying to download sales_grid.zip - i come to the main Page of Magento.
Can someone provide me the zip file?

Would be great!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Flipmedia
Member
 
Avatar
Total Posts:  43
Joined:  2009-09-24
 

As anyone a copy of Anton Makarenko patch? Thanks

Anton Makarenko - 22 May 2012 01:34 PM

ShopGuy - 10 February 2009 01:28 PM
In order to fix this error replace the _execute() in lib/Zend/Db/Statement/Pdo.php. What it does is retries the query.
...
Also, to replace a bug in Zend that can cause an infinite loop replace raw_query() in lib/Varien/Db/Adapter/Mysqli.php with the following:

The only thing changed is the above is $tries is moved outside the loop so it is not reset on every loop and it ensures an exception is thrown after 10 tries.

This is a workaround, a very dangerous one.

A true solution is to design application in such a way, that collisions will not occur at the first place.

I have found a problem in sales model that caused deadlocks during orders placement. The issue was that it tried to write into sales_flat_order_grid table within transaction right after insert into sales_flat_order table. With concurrent queries it caused locking collisions. While making DB adapter “retry” query could mitigate the problem a bit, the real solution is to move stuff of sales_flat_order_grid out of the transaction.

The patch is attached. It applies for Magento CE v1.4.1.0 / EE 1.8.0.0 and above. (EE users, please contact support for officially supported patch version)

 
Magento Community Magento Community
Magento Community
Magento Community
 
msheehan
Jr. Member
 
Total Posts:  1
Joined:  2012-07-06
 

I am also finding the embedded link to the Anton Makarenko patch no longer works - would love to hear from someone who can provide this again or if the link is fixed!

 
Magento Community Magento Community
Magento Community
Magento Community
 
netalico
Jr. Member
 
Total Posts:  3
Joined:  2011-06-08
 

I’m not sure if its the exact patch that Anton created, but here’s a core extension file I found that modifies the save order grid behavior to match the behavior in Magento 1.8: https://gist.github.com/ltcdnunez/4129581

 
Magento Community Magento Community
Magento Community
Magento Community
 
Flipmedia
Member
 
Avatar
Total Posts:  43
Joined:  2009-09-24
 
netalico - 03 December 2013 01:38 PM

I’m not sure if its the exact patch that Anton created, but here’s a core extension file I found that modifies the save order grid behavior to match the behavior in Magento 1.8: https://gist.github.com/ltcdnunez/4129581

Hi, I have reviewed this against our 1.6.0.2 core and the overwrite would rename the method “_afterSave” to become “afterCommitCallback”.

Can you confirm which version you are patching with this file and has it resolved the deadlock issue.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
netalico
Jr. Member
 
Total Posts:  3
Joined:  2011-06-08
 
Flipmedia - 03 December 2013 03:01 PM

netalico - 03 December 2013 01:38 PM
I’m not sure if its the exact patch that Anton created, but here’s a core extension file I found that modifies the save order grid behavior to match the behavior in Magento 1.8: https://gist.github.com/ltcdnunez/4129581

Hi, I have reviewed this against our 1.6.0.2 core and the overwrite would rename the method “_afterSave” to become “afterCommitCallback”.

Can you confirm which version you are patching with this file and has it resolved the deadlock issue.

Thanks

I’m patching 1.7 and it does rename those methods for 1.7.

As far as I can tell after a week in production and testing it has resolved the deadlock issues.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 3