mailchimp / mc-magento

Mailchimp for Magento 1 Integration. Syncs all data (subscriber, customers, orders, products) and enables marketing automation with email campaigns, automations, ads, postcards and more.
https://mailchimp.com/integrations/magento/
Open Software License 3.0
121 stars 94 forks source link

PHP out of memory error in mailchimp_process_webhook_data (cron) #331

Closed durzel closed 7 years ago

durzel commented 7 years ago

Have disabled Ecommerce on our Magento install after it was taking forever and a day to sync orders (5800 orders has taken nearly 4 days), and was producing regular cron errors (#312)

Now, every time mailchimp_process_webhook_data runs it produces the following errors:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/magento/public_html/lib/Zend/Db/Statement/Pdo.php on line 291
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/magento/public_html/app/code/core/Zend/Db/Select.php on line 738

AOE_Scheduler shows the task is endlessly "Running"...

Scheduler error Scheduler error 2

This has only happened since disabling Ecommerce, previously the webhook process has been running without any issues.

durzel commented 7 years ago

Have tried disabling the whole thing now, and now I'm getting this error in cron:

PHP Fatal error:  Uncaught Error: Call to a member function getId() on null in /home/magento/.modman/mc-magento/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php:120
Stack trace:
#0 /home/magento/.modman/mc-magento/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php(44): Ebizmarts_MailChimp_Model_ProcessWebhook->_subscribe(Array)
#1 /home/magento/.modman/mc-magento/app/code/community/Ebizmarts/MailChimp/Model/Cron.php(41): Ebizmarts_MailChimp_Model_ProcessWebhook->processWebhookData()
#2 /home/magento/.modman/Aoe_Scheduler/app/code/community/Aoe/Scheduler/Model/Schedule.php(217): Ebizmarts_MailChimp_Model_Cron->processWebhookData(Object(Aoe_Scheduler_Model_Schedule))
#3 /home/magento/.modman/Aoe_Scheduler/app/code/community/Aoe/Scheduler/Model/Schedule.php(623): Aoe_Scheduler_Model_Schedule->runNow(true)
#4 /home/magento/.modman/Aoe_Scheduler/app/code/community/Aoe/Scheduler/Model/Observer.php(39): Aoe_Scheduler_Model_Schedule->process()
#5 /home/magento/public_html/app/code/core/Mage/Core/Model/App.p in /home/magento/.modman/mc-magento/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php on line 120

Seems like the whole thing is falling apart.

Magento CE 1.9.3.3 M4M 1.1.7

It shouldn't be this difficult to use, should it?

durzel commented 7 years ago

Looks like this is possibly an infinite loop somewhere in loadListSubscriber, certainly the MySQL process list shows a seemingly never ending series of queries that look like this:

SELECTnewsletter_subscriber.* FROMnewsletter_subscriberWHERE (subscriber_email=:subscriber_email)

Will try and do some more debugging..

durzel commented 7 years ago

Ok, further debugging seems to show that even if you disable the extension completely if there are pending requests in the mailchimp_webhook_request then they will be processed by mailchimp_process_webhook_data cron, even if the data in them is no longer valid (e.g. subscribers that don't exist), and even if the extension is disabled at every scope.

As a consequence loadListSubscriber can return a NULL object, which is not sanity checked anywhere that it is called, therefore bombing out on getId() pretty much everywhere. Haven't delved deep yet to see how this could be reconciled, will keep looking, but I've fixed my cron errors for now at least.

centerax commented 7 years ago

@durzel this problem (checking for null subscriber) is already pushed to develop. we are releasing a new version next week.