nexcess / magento-turpentine

A Varnish extension for Magento.
GNU General Public License v2.0
520 stars 252 forks source link

PHP Allowed memory size error #771

Closed stammmedia closed 9 years ago

stammmedia commented 9 years ago

I got an error of PHP memory size when I save a product and when I refresh the Varnish page cache:

For the page cache for example: FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /export/www/xtwostore/htdocs/magento/lib/Zend/Db/Statement/Pdo.php on line 291" while reading response header from upstream, client: 127.0.0.1, server: [...]

Already set memory to 4GB but no success.... seem it goes to endless.

We already could figure out that for product saving the oberserver seem to do something that need much memory, maybe due to very much products in our shop (3 multistores with 180.000 products).

Please let me know if there is a solution.

Thank you!

magenx commented 9 years ago

you are not saving 180k products, only few, you need to run some profiler or strace your failing php process to see where is the loop/crack

stammmedia commented 9 years ago

Please note this problem only occurs, when varnish cache is enabled in backend. Also turning of the observers in the config of Turpentine for the product savings solved the php memory size error when saving a product item, of course than the sites in cache with this product are still old.

stammmedia commented 9 years ago

Before the cash at product saving, this is the last debug info:

SQL: SELECT catalog_category_flat_store_3.* FROM catalog_category_flat_store_3 WHERE (catalog_category_flat_store_3.entity_id=3) AFF: 1 TIME: 0.0002 TRACE: #1 Magento_Db_Adapter_Pdo_Mysql[Varien_Db_Adapter_Pdo_Mysql]#000000004aa0d98b000000005e4dd962#->debugStat(2, 'SELECT `catalog...', array(), &Varien_Db_Statement_Pdo_Mysql#000000004aa0daf1000000005e4dd962#) called at [lib/Varien/Db/Adapter/Pdo/Mysql.php:433]

2 Magento_Db_Adapter_Pdo_Mysql[Varien_Db_Adapter_Pdo_Mysql]#000000004aa0d98b000000005e4dd962#->query(&Varien_Db_Select#000000004aa0daea000000005e4dd962#, array()) called at [lib/Zend/Db/Adapter/Abstract.php:756]

3 Magento_Db_Adapter_Pdo_Mysql[Zend_Db_Adapter_Abstract]#000000004aa0d98b000000005e4dd962#->fetchRow(&Varien_Db_Select#000000004aa0daea000000005e4dd962#) called at [app/code/core/Mage/Core/Model/Resource/Db/Abstract.php:380]

4 Mage_Catalog_Model_Resource_Category_Flat[Mage_Core_Model_Resource_Db_Abstract]#000000004aa0db1c000000005e4dd962#->load(&Mage_Catalog_Model_Category#000000004aa0db0c000000005e4dd962#, 3, NULL) called at [app/code/core/Mage/Core/Model/Abstract.php:225]

5 Mage_Catalog_Model_Category[Mage_Core_Model_Abstract]#000000004aa0db0c000000005e4dd962#->load(3) called at [app/code/core/Mage/Catalog/Model/Category.php:510]

6 Mage_Catalog_Model_Category#000000004aa0daf4000000005e4dd962#->getUrlPath() called at [app/code/core/Mage/Catalog/Model/Product/Url.php:184]

7 Enterprise_Catalog_Model_Product_Url[Mage_Catalog_Model_Product_Url]#000000004aa0dad9000000005e4dd962#->getUrlPath(&Mage_Catalog_Model_Product#000000004aa0dad0000000005e4dd962#, &Mage_Catalog_Model_Category#000000004aa0daf4000000005e4dd962#) called at [app/code/community/Nexcessnet/Turpentine/Helper/Cron.php:205]

8 Nexcessnet_Turpentine_Helper_Cron#000000004aa0db44000000005e4dd962#->addProductToCrawlerQueue(&Mage_Catalog_Model_Product#000000004aa0dad0000000005e4dd962#) called at [app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php:129]

9 Nexcessnet_Turpentine_Model_Observer_Ban#000000004aa0db32000000005e4dd962#->banProductPageCacheCheckStock(&Varien_Event_Observer#000000004aa0daca000000005e4dd962#) called at [app/code/core/Mage/Core/Model/App.php:1338]

10 Mage_Core_Model_App#000000004aa0d998000000005e4dd962#->_callObserverMethod(&Nexcessnet_Turpentine_Model_Observer_Ban#000000004aa0db32000000005e4dd962#, 'banProductPageCa...', &Varien_Event_Observer#000000004aa0daca000000005e4dd962#) called at [app/code/core/Mage/Core/Model/App.php:1317]

11 Mage_Core_Model_App#000000004aa0d998000000005e4dd962#->dispatchEvent('cataloginventory...', array('data_object' => &Mage_CatalogInventory_Model_Stock_Item#000000004aa0db3e000000005e4dd962#, 'item' => &Mage_CatalogInventory_Model_Stock_Item#000000004aa0db3e000000005e4dd962#)) called at [app/Mage.php:448]

12 Mage::dispatchEvent('cataloginventory...', array('data_object' => &Mage_CatalogInventory_Model_Stock_Item#000000004aa0db3e000000005e4dd962#, 'item' => &Mage_CatalogInventory_Model_Stock_Item#000000004aa0db3e000000005e4dd962#)) called at [app/code/core/Mage/Core/Model/Abstract.php:466]

13 Mage_CatalogInventory_Model_Stock_Item[Mage_Core_Model_Abstract]#000000004aa0db3e000000005e4dd962#->_afterSave() called at [app/code/core/Mage/Core/Model/Abstract.php:319]

14 Mage_CatalogInventory_Model_Stock_Item[Mage_Core_Model_Abstract]#000000004aa0db3e000000005e4dd962#->save() called at [app/code/core/Mage/CatalogInventory/Model/Observer.php:159]

15 Mage_CatalogInventory_Model_Observer#000000004aa0db3f000000005e4dd962#->saveInventoryData(&Varien_Event_Observer#000000004aa0db7e000000005e4dd962#) called at [app/code/core/Mage/Core/Model/App.php:1338]

16 Mage_Core_Model_App#000000004aa0d998000000005e4dd962#->_callObserverMethod(&Mage_CatalogInventory_Model_Observer#000000004aa0db3f000000005e4dd962#, 'saveInventoryDat...', &Varien_Event_Observer#000000004aa0db7e000000005e4dd962#) called at [app/code/core/Mage/Core/Model/App.php:1317]

17 Mage_Core_Model_App#000000004aa0d998000000005e4dd962#->dispatchEvent('catalogproduct...', array('data_object' => &Mage_Catalog_Model_Product#000000004aa0d857000000005e4dd962#, 'product' => &Mage_Catalog_Model_Product#000000004aa0d857000000005e4dd962#)) called at [app/Mage.php:448]

18 Mage::dispatchEvent('catalogproduct...', array('data_object' => &Mage_Catalog_Model_Product#000000004aa0d857000000005e4dd962#, 'product' => &Mage_Catalog_Model_Product#000000004aa0d857000000005e4dd962#)) called at [app/code/core/Mage/Core/Model/Abstract.php:466]

19 Mage_Catalog_Model_Product[Mage_Core_Model_Abstract]#000000004aa0d857000000005e4dd962#->_afterSave() called at [app/code/core/Mage/Catalog/Model/Product.php:549]

20 Mage_Catalog_Model_Product#000000004aa0d857000000005e4dd962#->_afterSave() called at [app/code/core/Mage/Core/Model/Abstract.php:319]

21 Mage_Catalog_Model_Product[Mage_Core_Model_Abstract]#000000004aa0d857000000005e4dd962#->save() called at [app/code/local/Stamm/Pim/controllers/Catalog/ProductController.php:185]

22 Stamm_Pim_Catalog_ProductController#000000004aa0d9e1000000005e4dd962#->saveAction() called at [app/code/core/Mage/Core/Controller/Varien/Action.php:418]

23 Stamm_Pim_Catalog_ProductController[Mage_Core_Controller_Varien_Action]#000000004aa0d9e1000000005e4dd962#->dispatch('save') called at [app/code/core/Mage/Core/Controller/Varien/Router/Standard.php:250]

24 Mage_Core_Controller_Varien_Router_Admin[Mage_Core_Controller_Varien_Router_Standard]#000000004aa0d9eb000000005e4dd962#->match(&Mage_Core_Controller_Request_Http#000000004aa0d9de000000005e4dd962#) called at [app/code/core/Mage/Core/Controller/Varien/Front.php:172]

25 Mage_Core_Controller_Varien_Front#000000004aa0d9f5000000005e4dd962#->dispatch() called at [app/code/core/Mage/Core/Model/App.php:354]

26 Mage_Core_Model_App#000000004aa0d998000000005e4dd962#->run(array('scope_code' => 'xtwostore_de', 'scope_type' => 'store', 'options' => array())) called at [app/Mage.php:684]

27 Mage::run('xtwostore_de', 'store') called at [index.php:99]

This message comes about fiveteen times with different flat_store numbers and different entry_id

This is the lastd ebug log before crashing when cache tries to clear at Varnish pages:

SQL: SELECT e._, cat_index.position AS cat_index_position, IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) AS visibility FROM catalog_product_entity AS e INNER JOIN catalog_category_product_index AS cat_index ON cat_index.product_id=e.entity_id AND cat_index.store_id=2 AND cat_index.category_id = '2' INNER JOIN catalog_product_entity_int AS at_visibility_default ON (at_visibility_default.entity_id = e.entity_id) AND (at_visibility_default.attribute_id = '102') AND at_visibility_default.store_id = 0 LEFT JOIN catalog_product_entity_int AS at_visibility ON (at_visibility.entity_id = e.entity_id) AND (at_visibility.attribute_id = '102') AND (at_visibility.store_id = 2) WHERE (((IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) = '4') OR (IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) = '2'))) AFF: 174773 TIME: 1.6714 TRACE: #1 Magento_Db_Adapter_Pdo_Mysql[Varien_Db_Adapter_Pdo_Mysql]#0000000027e4bb9f000000007cac1d57#->debugStat(2, 'SELECT e., `c...', array(), &Varien_Db_Statement_Pdo_Mysql#0000000027e4b911000000007cac1d57#) called at [lib/Varien/Db/Adapter/Pdo/Mysql.php:433]

2 Magento_Db_Adapter_Pdo_Mysql[Varien_Db_Adapter_Pdo_Mysql]#0000000027e4bb9f000000007cac1d57#->query('SELECTe.*,`c...', array()) called at [lib/Zend/Db/Adapter/Abstract.php:737]

3 Magento_Db_Adapter_Pdo_Mysql[Zend_Db_AdapterAbstract]#0000000027e4bb9f000000007cac1d57#->fetchAll('SELECT e., `c...', array()) called at [lib/Varien/Data/Collection/Db.php:734]

4 Mage_Catalog_Model_Resource_Product_Collection[Varien_Data_Collection_Db]#0000000027e4b9ea000000007cac1d57#->fetchAll('SELECTe., `c...') called at [app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php:1045]

5 Mage_Catalog_Model_Resource_Product_Collection[Mage_Eav_Model_Entity_Collection_Abstract]#0000000027e4b9ea000000007cac1d57#->_loadEntities(false, false) called at [app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php:871]

6 Mage_Catalog_Model_Resource_Product_Collection[Mage_Eav_Model_Entity_Collection_Abstract]#0000000027e4b9ea000000007cac1d57#->load() called at [lib/Varien/Data/Collection.php:741]

7 Mage_Catalog_Model_Resource_Product_Collection[Varien_Data_Collection]#0000000027e4b9ea000000007cac1d57#->getIterator() called at [app/code/community/Nexcessnet/Turpentine/Helper/Cron.php:172]

8 Nexcessnet_Turpentine_Helper_Cron#0000000027e4ba37000000007cac1d57#->getAllUrls() called at [app/code/community/Nexcessnet/Turpentine/Model/Observer/Cron.php:73]

9 Nexcessnet_Turpentine_Model_Observer_Cron#0000000027e4b9ab000000007cac1d57#->queueAllUrls(&Varien_Event_Observer#0000000027e4b9a8000000007cac1d57#) called at [app/code/core/Mage/Core/Model/App.php:1338]

10 Mage_Core_Model_App#0000000027e4bb8c000000007cac1d57#->_callObserverMethod(&Nexcessnet_Turpentine_Model_Observer_Cron#0000000027e4b9ab000000007cac1d57#, 'queueAllUrls', &Varien_Event_Observer#0000000027e4b9a8000000007cac1d57#) called at [app/code/core/Mage/Core/Model/App.php:1317]

11 Mage_Core_Model_App#0000000027e4bb8c000000007cac1d57#->dispatchEvent('turpentine_ban_a...', array('127.0.0.1:6082' => true)) called at [app/Mage.php:448]

12 Mage::dispatchEvent('turpentine_ban_a...', array('127.0.0.1:6082' => true)) called at [app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php:234]

13 Nexcessnet_Turpentine_Model_Observer_Ban#0000000027e4ba76000000007cac1d57#->banAllCache(&Varien_Event_Observer#0000000027e4b985000000007cac1d57#) called at [app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php:261]

14 Nexcessnet_Turpentine_Model_Observer_Ban#0000000027e4ba76000000007cac1d57#->banCacheType(&Varien_Event_Observer#0000000027e4b985000000007cac1d57#) called at [app/code/core/Mage/Core/Model/App.php:1338]

15 Mage_Core_Model_App#0000000027e4bb8c000000007cac1d57#->_callObserverMethod(&Nexcessnet_Turpentine_Model_Observer_Ban#0000000027e4ba76000000007cac1d57#, 'banCacheType', &Varien_Event_Observer#0000000027e4b985000000007cac1d57#) called at [app/code/core/Mage/Core/Model/App.php:1317]

16 Mage_Core_Model_App#0000000027e4bb8c000000007cac1d57#->dispatchEvent('adminhtmlcache...', array('type' => 'turpentine_pages')) called at [app/Mage.php:448]

17 Mage::dispatchEvent('adminhtmlcache...', array('type' => 'turpentine_pages')) called at [app/code/core/Mage/Adminhtml/controllers/CacheController.php:128]

18 Mage_Adminhtml_CacheController#0000000027e4bb57000000007cac1d57#->massRefreshAction() called at [app/code/core/Mage/Core/Controller/Varien/Action.php:418]

19 Mage_Adminhtml_CacheController[Mage_Core_Controller_Varien_Action]#0000000027e4bb57000000007cac1d57#->dispatch('massRefresh') called at [app/code/core/Mage/Core/Controller/Varien/Router/Standard.php:250]

20 Mage_Core_Controller_Varien_Router_Admin[Mage_Core_Controller_Varien_Router_Standard]#0000000027e4bbff000000007cac1d57#->match(&Mage_Core_Controller_Request_Http#0000000027e4bbca000000007cac1d57#) called at [app/code/core/Mage/Core/Controller/Varien/Front.php:172]

21 Mage_Core_Controller_Varien_Front#0000000027e4bbe1000000007cac1d57#->dispatch() called at [app/code/core/Mage/Core/Model/App.php:354]

22 Mage_Core_Model_App#0000000027e4bb8c000000007cac1d57#->run(array('scope_code' => 'xtwostore_de', 'scope_type' => 'store', 'options' => array())) called at [app/Mage.php:684]

23 Mage::run('xtwostore_de', 'store') called at [index.php:99]

Does this help?

stammmedia commented 9 years ago

I solved the problem. I disabled the lines 169 to 175 in Cron.php function getAllUrls(). After that it worked.