cancel
Showing results for 
Search instead for 
Did you mean: 

M1EE1.14.3.10-Mage::getSingleton('core/resource')->getConnection('core_read') returns NULL sometimes

M1EE1.14.3.10-Mage::getSingleton('core/resource')->getConnection('core_read') returns NULL sometimes

We have Magento 1 EE 1.14.3.10. In the production, I tried to deploy some of the updates, took a code pull from GIT and cleared the cache. Since then it started throwing this error. No error if Amasty FPC module is disabled. Please note that my question is not about Amasty Module, Front.php in Amasty is using Magento core code and it is failing so please consider it as a Magento related Question.

Fatal error: Uncaught Error: Call to a member function select() on boolean in /var/www/example.com/public/app/code/local/Amasty/Fpc/Model/Fpc/Front.php:996 Stack trace: #0 /var/www/example.com/public/app/code/local/Amasty/Fpc/Model/Fpc/Front.php(107): Amasty_Fpc_Model_Fpc_Front->getDbConfig('web/url/use_sto...') #1 /var/www/example.com/public/app/code/core/Mage/Core/Model/Cache.php(703): Amasty_Fpc_Model_Fpc_Front->__construct() #2 /var/www/example.com/public/app/code/core/Mage/Core/Model/Cache.php(685): Mage_Core_Model_Cache->_getProcessor('Amasty_Fpc_Mode...') #3 /var/www/example.com/public/app/code/core/Mage/Core/Model/App.php(351): Mage_Core_Model_Cache->processRequest() #4 /var/www/example.com/public/app/Mage.php(683): Mage_Core_Model_App->run(Array) #5 /var/www/example.com/public/index.php(100): Mage::run('', 'store') #6 {main} thrown in /var/www/example.com/public/app/code/local/Amasty/Fpc/Model/Fpc/Front.php on line 996

Here is the piece of code in Front.php from where the error is thrown

    $resource = Mage::getSingleton('core/resource');    $adapter = $resource->getConnection('core_read');    $select = $adapter->select()
        ->from($resource->getTableName('core/config_data'), array('path', 'value'))
        ->where('path LIKE \'amfpc/%\' OR path IN (?)', self::$_additionalConfigs)
        ->where('scope_id=?', 0)

Error is thrown in this line $select = $adapter->select(). As $adapter is just a piece of Magento Core Code I am not sure what is causing the error.

I tried to reproduce this issue in our staging site but no luck. In production Redis is configured but not in the staging site, could this be the issue?

Here is the Redis configuration set in Amasty xml configuration (z_amfpclocal.xml)

<?xml version="1.0"?>
<config>
    <global>
        <amfpc>
            <cache>
                <backend>Cm_Cache_Backend_Redis</backend>
                <backend_options>
                    <server>xx.xx.xx.xx</server> <!-- or absolute path to unix socket -->
                    <port>6379</port>
                    <persistent></persistent> <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: https://github.com/nicolasff/phpredis/issues/70 -->
                    <database>7</database> <!-- Redis database number; protection against accidental data loss is improved by not sharing databases -->
                    <password></password> <!-- Specify if your Redis server requires authentication -->
                    <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
                    <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures; a value of 1 will not retry after the first failure -->
                    <read_timeout>10</read_timeout>         <!-- Set read timeout duration; phpredis does not currently support setting read timeouts -->
                    <automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled by default -->
                    <compress_data>1</compress_data>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
                    <compress_tags>1</compress_tags>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
                    <compress_threshold>345600</compress_threshold>  <!-- Strings below this size will not be compressed -->
                    <compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf, lz4 (as l4z) and snappy -->
                    <use_lua>0</use_lua> <!-- Set to 1 if Lua scripts should be used for some operations -->
                </backend_options>
            </cache>
        </amfpc>
    </global>
</config>

Please help with your suggestions. Right now I am trying to configure Redis in our staging site. Will update here in case I can reproduce this.

Also please let me know if you need any other information to provide the hints.