Magento: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

Version: Magento Enterprise 1.8.0.0

Findout the function _execute() from tha page “lib/Zend/Db/Statement/Pdo.php”

Replace this function with below lines


    /**
     * Executes a prepared statement.
     *
     * @param array $params OPTIONAL Values to bind to parameter placeholders.
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */
    public function _execute(array $params = null)
    {
        $tries = 0;
        do {
            $retry = false;
            try {
                if ($params !== null) {
                    return $this->_stmt->execute($params);
                } else {
                    return $this->_stmt->execute();
                }
            } catch (PDOException $e) {
                #require_once 'Zend/Db/Statement/Exception.php';
                if ($tries getMessage()=='SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction') {
                    $retry = true;
                } else {
                    throw new Zend_Db_Statement_Exception($e->getMessage());
                }
                $tries++;
            }
        } while ($retry);
    }

Findout the function raw_query() from the page “lib/Varien/Db/Adapter/Mysqli.php”

Replace this function with below lines


    public function raw_query($sql)
    {
        $tries = 0;
	do {
            $retry = false;
            try {
                $this->clear_result();
                $result = $this->getConnection()->query($sql);
                $this->clear_result();
            }
            catch (Exception $e) {
                if ($e->getMessage()=='SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction') {
                    $retry = true;
                } else {
                    throw $e;
                }
                $tries++;
            }
        } while ($retry);        return $result;
    }

Related Articles

Advertisements
Magento: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

3 thoughts on “Magento: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

  1. on _execute function

    if ($tries getMessage()==’SQLSTATE[40001]: Serializa …

    there is an error in your code,
    here is the right syntaxe !

    if ($e->getMessage()==’SQLSTATE[40001]: Serializa…

    thanks for the fix

    Like

  2. Tomi Mceaddy says:

    This is the perfect post and may be one that should be followed up to see what goes on

    A companion e-mailed this link the other day and I’m eagerly anticipating your next blog post. Proceed on the top quality work.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s