Magento Fatal Error – Fix Uncaught PDOException with SQLSTATE[23000] Integrity Constraint Violation

fatal errormagento-1.9

I last logged in 2 days ago and everything is fine but I went to my site today and my admin page is showing:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '6307b08438f5cf42baa54f7af5abe85e' for key 'PRIMARY'' in /home/wwwshopm/public_html/store/lib/Zend/Db/Statement/Pdo.php:228 Stack trace: #0 /home/wwwshopm/public_html/store/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array) #1 /home/wwwshopm/public_html/store/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) #2 /home/wwwshopm/public_html/store/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array) #3 /home/wwwshopm/public_html/store/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array) #4 /home/wwwshopm/public_html/store/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO mg...', Array) #5 /home/wwwshopm/public_html/store/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTOmg…', Array) #6 /home/wwwshopm/public_html/st in /home/wwwshopm/public_html/store/lib/Zend/Db/Statement/Pdo.php on line 235

I have 4 store views, all except one are showing fine. The final store view which isn't working is showing the exact same code but with:

Duplicate entry '21a999787fc3e2ffa14eafc17a834408' for key 'PRIMARY'

Anyone have any ideas on how I can resolve this problem?

EDIT: I checked Pdo.php and this is the section the error refers to:

{
    try {
        if ($params !== null) {
            return $this->_stmt->execute($params);
        } else {
            return $this->_stmt->execute();
        }
    } catch (PDOException $e) {
        #require_once 'Zend/Db/Statement/Exception.php';
        $message = sprintf('%s, query was: %s', $e->getMessage(), $this->_stmt->queryString);
        throw new Zend_Db_Statement_Exception($message, (int) $e->getCode(), $e);
    }
}

Best Answer

Another store view just crashed and revealed the solution my DB table: mg_core_session crashed. I repaired the table and its all working again.

Related Topic