Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Memory Leaks
- This topic has 34 replies, 2 voices, and was last updated 5 years, 7 months ago by Soft79.
-
AuthorPosts
-
April 8, 2018 at 3:55 pm #2937Jonathan MooreParticipant
Couple of thoughts:
- – Is there an issue with the product wrapping and can it be removed? since I don’t need my runtime to be always checking for downgrade compatiblity of WooCommerce. It seems to be memory hungry as per log messages below
- The issues I’m seeing may be particularly when pages are being pre-cached by wp supercache (I can’t reproduce interactively): in this caching context the coupons aren’t required at all, so could we set the plugin to not load in this context?
The sort of things I see in the logs are below. While there could be other contributory factors, it seems to stop when I deactivate this plugin.
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 528384 bytes) in wp-content/plugins/woocommerce-auto-added-coupons-pro/includes/WJECF_WC.php on line 53
and:
PHP Fatal error: Maximum execution time of 90 seconds exceeded in wp-includes/cache.php on line 700
PHP Fatal error: Maximum execution time of 90 seconds exceeded in wp-includes/functions.php on line 3512
PHP Fatal error: Maximum execution time of 90 seconds exceeded in wp-includes/taxonomy.php on line 1439
PHP Fatal error: Maximum execution time of 90 seconds exceeded in wp-content/plugins/woocommerce-auto-added-coupons-pro/includes/WJECF_WC.php on line 24
PHP Warning: Invalid argument supplied for foreach() in wp-includes/class-wp-hook.php on line 277
PHP Warning: Invalid argument supplied for foreach() in wp-includes/class-wp-hook.php on line 277
PHP Warning: Invalid argument supplied for foreach() in wp-includes/class-wp-hook.php on line 277
PHP Warning: Invalid argument supplied for foreach() in wp-includes/class-wp-hook.php on line 277
PHP Warning: Invalid argument supplied for foreach() in wp-includes/class-wp-hook.php on line 277April 8, 2018 at 5:10 pm #2938Soft79KeymasterI’m not aware of any issues. Do you have many auto coupons by any chance?
Or if you don’t use the auto coupon feature at all, does disabling WJECF_AutoCoupon fix the memory issue?
Alternatively, what if you append the following line before line 43: if ( $object instanceof WC_Coupon ) ?
$this->wrappers = array();
Does that solve the memory issue?
…I have been thinking about dropping WC2 support but haven’t made up my mind yet.
April 8, 2018 at 9:17 pm #2939Jonathan MooreParticipantI got this plugin mainly to be able to do auto-coupon, so yes I have a free gift for first time buyers, optional rewards for spending more than a certain amount and a 5 for 4 type deal on some product category for example.
I’ve been running with the plugin disabled again for some hours and everything has been fine with no further errors reported.
I’ll dig some more and have a look at the change you suggested.
April 8, 2018 at 10:15 pm #2940Soft79KeymasterCan you also please post the WC System Status Report?
April 9, 2018 at 7:07 am #2944Jonathan MooreParticipantThere are 36 coupons and 1,411 products so I’m more wondering about the product wrapping.
The single use free gift coupon has been auto-applied and used 217 times.I had reduced the PHP memory limit from 300MB to 192MB and the timeout from 120s to 90s, everything running fine for >12 hours including new orders received with this plugin turned off. (I’m thinking about reducing it further to fail faster)
But when I turn this plugin back on again the errors recur.I’m not able to cause a hang interactively which is why I think one of the cron jobs must be causing it.
Server load is fairly low and Apache/PHP-FPM load is mitigated by using nginx in front, supercache generated pages processed via .htaccess and redis cache. but when these problems occur php-fpm uses up max cpu and also blows memory limit – at least if allowed to run for long enough.This is this morning – interactively auto-coupons etc are working correctly and this plugin log seems ok, but then in the background something else is happening:
[09-Apr-2018 06:06:09 UTC] PHP Fatal error: Maximum execution time of 90 seconds exceeded in /wp-content/plugins/woocommerce-auto-added-coupons-pro/includes/WJECF_WC.php on line 24
[09-Apr-2018 06:07:39 UTC] PHP Fatal error: Maximum execution time of 90 seconds exceeded in /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php on line 586
[09-Apr-2018 06:09:09 UTC] PHP Fatal error: Maximum execution time of 90 seconds exceeded in /wp-content/object-cache.php on line 965
[09-Apr-2018 06:10:40 UTC] PHP Fatal error: Maximum execution time of 90 seconds exceeded in /wp-includes/class-wp-list-util.php on line 166
[09-Apr-2018 06:10:56 UTC] PHP Fatal error: Maximum execution time of 90 seconds exceeded in /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php on line 678
[09-Apr-2018 06:10:56 UTC] PHP Warning: Invalid argument supplied for foreach() in /wp-includes/class-wp-hook.php on line 277
[09-Apr-2018 06:10:56 UTC] PHP Warning: Invalid argument supplied for foreach() in /wp-includes/class-wp-hook.php on line 277
[09-Apr-2018 06:10:56 UTC] PHP Warning: Invalid argument supplied for foreach() in /wp-includes/class-wp-hook.php on line 277
[09-Apr-2018 06:10:56 UTC] PHP Warning: Invalid argument supplied for foreach() in /wp-includes/class-wp-hook.php on line 277
[09-Apr-2018 06:10:56 UTC] PHP Warning: Invalid argument supplied for foreach() in /wp-includes/class-wp-hook.php on line 277
[09-Apr-2018 06:12:26 UTC] PHP Fatal error: Maximum execution time of 90 seconds exceeded in /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php on line 554
[09-Apr-2018 06:13:56 UTC] PHP Fatal error: Maximum execution time of 90 seconds exceeded in /wp-includes/plugin.php on line 191
[09-Apr-2018 06:15:27 UTC] PHP Fatal error: Maximum execution time of 90 seconds exceeded in /wp-includes/taxonomy.php on line 1392
[09-Apr-2018 06:16:59 UTC] PHP Fatal error: Maximum execution time of 90 seconds exceeded in /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-product.php on line 1120
[09-Apr-2018 06:50:56 UTC] PHP Fatal error: Maximum execution time of 90 seconds exceeded in /wp-content/plugins/woocommerce-auto-added-coupons-pro/includes/WJECF_Wrap.php on line 26Running on PHP7, does Polylang which has the WPML capable api which has been working fine with this plugin, I haven’t updated woocommerce recently (3.1.2) but there have been updates to WP and Polylang.
But what is coming up consistently in the logs is the woocommerce product data and the WJECF wrap.
I’ve used this plugin for over a year without noticing major problem until recent months.
I do note this plugin is generally well defensively coded with use of safe_add_action to avoid recursion.
And in some place tests for: WJECF()->is_request( ‘frontend’ )But some combination of factors is triggering an infinite loop until out of memory or execution time or both.
April 9, 2018 at 7:28 am #2945Jonathan MooreParticipantcould I send the WC System Status Report separately rather than posting publicly on the forum?
April 9, 2018 at 7:43 am #2946Jonathan MooreParticipantOh, and I kick of the wordpress cron from Unix rather than the visitor triggered.
I wonder if it would be valid to test for WJECF()->is_request( ‘cron’ ) and not load the plugin for cron, or whether there is any case where it would be needed.April 9, 2018 at 11:00 am #2947Soft79KeymasterPlease send the Status Report using the Contact form.
April 9, 2018 at 1:32 pm #2953Jonathan MooreParticipantYes 2.6.2 – only noticed one call of this type
April 10, 2018 at 6:20 am #2957Jonathan MooreParticipantI thought I was getting somewhere as the errors seem to occur roughly every 15 minutes, which coincides with the cron job:
*/15 * * * * wget -q -O – https://www.mysite.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1I turned off the only job that WP Crontrol said was due:
woocommerce_ac_send_email_action wcal_send_email_cron()
Abandoned Cart Lite for WooCommerce (the free version on wordpress.org/plugins)
but that didn’t seem to solve it, even turning off the plugin altogether.Turning off the cron job altogether certainly seemed to reduce the occurrence of problems but not eliminate it.
Once again the only sure way of eliminating the problem was deactivating this plugin.April 10, 2018 at 8:46 am #2958Soft79KeymasterYou could error_log the url of every http request, to find out in which requests the issue occurs.
The Abandoned Cart plugin is not in the status report!
Did emptying the wrappers array help at all?
If instead of disabling our plugin completely, just disabling AutoCoupon (from plugin’s settings page) does that prevent the issue?
April 10, 2018 at 3:40 pm #2961Jonathan MooreParticipant>error_log the url of every http request, to find out in which requests the issue
Well Apache should already do that, not sure what logging from the app would most help>The Abandoned Cart plugin is not in the status
Yes I turned it off in case it was the problem>Did emptying the wrappers array help at all?
I didn’t do that yet, I will>If instead of disabling our plugin completely, just disabling AutoCoupon
Well this is the functionality mainly used so not so keen on disabling itThanks, some more things to try
April 10, 2018 at 3:55 pm #2962Soft79Keymastererror_log the url of every http request, to find out in which requests the issue
Well Apache should already do that, not sure what logging from the app would most helpCan you see a link between the requests and the error messages? I.e. is it always the cron requests like you suspect?
If instead of disabling our plugin completely, just disabling AutoCoupon
Well this is the functionality mainly used so not so keen on disabling itWell, before you told me you were running with the plugin disabled for some hours so I hoped it was an option. Otherwise
you could try this in a testing environment. I think the only functionality of our plugin that could potentially cause an infinite loop would be the AutoCoupon in combination with other plugins that that use similar filters or actions, but this must be investigated in your environment.April 10, 2018 at 9:21 pm #2964Jonathan MooreParticipantno there’s nothing directly related in the Apache logs, but actually I don’t think there’s a request either – I’d already established from some of the logs $_SERVER[‘REQUEST_URI’] etc are not set, hence is from cron call etc
I tried re-enabling without AutoCoupon and then with AutoCoupon and only had one memory blowout in last 5 hours (previously was about every 15min regardless of increasing memory) which was:
PHP Fatal error: Allowed memory size of 201326592 bytes exhausted (tried to allocate 4194304 bytes) in /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php on line 455
‘value’ => maybe_unserialize( $meta->meta_value ),
.. I can’t find any meta value in the db which could account for 4,194,304 bytes so that remains odd..I had cleared all transients and user sessions (including shopping carts) from the woocommerce screen, and then gone through applying workarounds to every plugin that was showing any type of minor error.
A corrupted transient / basket seems likely cause of main issue, though exactly how it was triggering any code weakness remains unclear.April 11, 2018 at 7:12 am #2968Jonathan MooreParticipantI’m wrong again, as soon as I turn everything back on, it came back again, like clockwork, 15min fails.
However I’ve now narrowed my suspicions to use of:add_filter('woocommerce_coupon_get__wjecf_free_product_ids', array($this, 'getFreeProductsInLanguage'), 10, 2);
Within Hyyan WooCommerce Polylang integration.
Since I wrote and contributed that part of the code that simplifies my research..
All it does is when the user has a choice of free products (added by an auto-added coupon), these products offered are substituted by the correct language versions.
Normally this works fine but something about recent Polylang updates and term optimisations must be throwing it out. Or some corruption somewhere in the whole wp terms (wp_term_relationships has 37,568 rows).
Or also, it’s getting called when it shouldn’t be.Anyhow I’ll run with that feature disabled for a day or two and see how it goes.
If you think of any reason use of woocommerce_coupon_get__wjecf_free_product_ids might cause a problem please let me know..
-
AuthorPosts
- You must be logged in to reply to this topic.