Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Sunday, June 23, 2013

SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded try restarting transaction

When developing on some customer site, we have met this error in the report file “SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction“. We have researched about this issue and we have found people suggests to run this statement via phpMyAdmin “SET innodb_lock_wait_timeout = 120;” or restart mysql service. But sometime, we don’t have permission to run this statement and have hosting admin done it.
 We have found other quick solution to do by modifying the file <Magento root folder>/lib/Zend/Db/Statement/Pdo.php at public function _execute(array &params = null)
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
public function _execute(array $params = null)
{
   /*try {
      if ($params !== null) {
         return $this->_stmt->execute($params);
      } else {
         return $this->_stmt->execute();
      }
   } catch (PDOException $e) {
      #require_once 'Zend/Db/Statement/Exception.php';
      throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);
   }*/
    
   $timeoutMessage = 'SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction';
   $tries = 0;
   do {
      $retry = false;
      try {
         if ($params !== null) {
            return $this->_stmt->execute($params);
         } else {
            return $this->_stmt->execute();
         }
      } catch (PDOException $e) {
         if ($tries < 10 and $e->getMessage()==$timeoutMessage) {
            $retry = true;
         } else {
            throw new Zend_Db_Statement_Exception($e->getMessage());
         }
         $tries++;
      }
   } while ($retry);
}

2 comments:


  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Online Training from India. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
    JavaScript Online Training from India

    ReplyDelete