Magento – Select Release_lock(?) error while reindexing – magento 1.9

databaseindexingmagento-1.9

I have a strange error with a reindex process in a Magento 1.9 installation. The trace shows a "MySQL Server Gone Away" error when trying to reindex in the web interface and via ssh. The error occurs after only 20 seconds, it might therefore not be related to a mysql timing issue (as specified in other answers on the same topic).

Those errors already occured in the past but I was able to solve the problem. I post an answer on this topic here. It worked several time but doesn't work anymore.

Looking at the trace I see that the error occured with the query SELECT RELEASE_LOCK(?). The lock name looks rather strange.

I tried numerous solutions on the web but none worked. If anyone can share some direction to solve this issue, he is welcome.

2016-03-15T19:20:44+00:00 DEBUG (7): Exception message:   SQLSTATE[HY000]: General error: 2006 MySQL server has gone away, query    was: SELECT RELEASE_LOCK(?);
Trace: #0 <path>/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 <path>/app/code/core/Zend/Db/Statement.php(311): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 <path>/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 <path>/app/code/local/Zend/Db/Adapter/Pdo/Abstract.php(239): Zend_Db_Adapter_Abstract->query('SELECT RELEASE_...', Array)
#4 <path>/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('SELECT RELEASE_...', Array)
#5 <path>/app/code/core/Mage/Index/Model/Resource/Helper/Mysql4.php(72): Varien_Db_Adapter_Pdo_Mysql->query('SELECT RELEASE_...', Array)
#6 <path>/app/code/core/Mage/Index/Model/Lock/Storage/Db.php(84): Mage_Index_Model_Resource_Helper_Mysql4->releaseLock('database...')
#7 <path>/app/code/core/Mage/Index/Model/Lock.php(208): Mage_Index_Model_Lock_Storage_Db->releaseLock('index_process_2')
#8 <path>/app/code/core/Mage/Index/Model/Lock.php(181): Mage_Index_Model_Lock->_releaseLockDb('index_process_2')
#9 <path>/app/code/core/Mage/Index/Model/Process.php(469): Mage_Index_Model_Lock->releaseLock('index_process_2', NULL)
#10 <path>/app/code/core/Mage/Index/Model/Process.php(223): Mage_Index_Model_Process->unlock()
#11 <path>/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process->reindexAll()
#12 <path>/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php(127): Mage_Index_Model_Process->reindexEverything()
#13 <path>/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Index_Adminhtml_ProcessController->reindexProcessAction()
#14 <path>/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('reindexProcess')
#15 <path>/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#16 <path>/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#17 <path>/app/Mage.php(684): Mage_Core_Model_App-   >run(Array)
#18 <path>/index.php(86): Mage::run('', 'store')
#19 {main}

Best Answer

Check <magento_root>/var folder, it should have 777 recursive permissions

In addition to this, try deleting any files in <magento_root>/var/locks folder