Support » Plugin: Facebook for WooCommerce » Action Scheduler Failed x thousands

  • Resolved bighippo999

    (@bighippo999)


    I’ve noticed when checking through our store the action scheduler jobs for ‘wc_facebook_regenerate_feed’ are failing.

    2020-06-02 19:35:38 +0000
    action created
    2020-06-02 19:36:24 +0000
    action started via Async Request
    2020-06-02 19:37:58 +0000
    unexpected shutdown: PHP Fatal error Maximum execution time of 60 seconds exceeded in /mnt/www/ukcophumour.co.uk/wp-content/plugins/facebook-for-woocommerce/includes/fbutils.php on line 405

    We have thousands of these errors and

    2020-06-02 19:29:47 +0000
    action created
    2020-06-02 19:30:28 +0000
    action started via WP Cron
    2020-06-02 19:35:37 +0000
    action timed out after 300 seconds

    We’re running WooCommerce 4.1.1 on WordPress 5.4.1 and plugin version 1.11.3
    Database wise, we have 2G data, 912 products with 39600 variations and over 53k orders.
    PHP time limit is 600 seconds and we run Redis object cache.

    Is anyone else getting high fail’s in the action scheduler? (WooCommerce>Status>Scheduled Actions>Failed)
    We mostly see ‘Maximum simultaneous queues already in progress (1 queue). No additional queues will begin processing until the current queues are complete.’ when opening the Scheduled actions, but occasionally it’s counting down to the next job. The concern is, this may be blocking other jobs?

    Thanks,

Viewing 11 replies - 1 through 11 (of 11 total)
  • Yes I’m getting this too. Just enabled debugging to see if theres anything obvious.

    Plugin Author SkyVerge

    (@skyverge)

    Hey @awr10e and @bighippo999,

    Thanks for reaching out with your concern and thanks for all the information here @bighippo999!

    We have seen only a few occurrences of this error with merchants with a large number of products and variants, where the PHP specified max_execution_time is not long enough for the file generation to complete. You mentioned, @bighippo999, that your setting was 600 seconds, though from the error message it seems to be set to 60 seconds. Is there any chance you could double-check your PHP settings and see if you can increase this if it is set to 60 seconds?

    @awr10e, what do you currently have set for PHP’s max_execution_time?

    Cheers,

    Simon.

    Hi Simon
    My PHP max_execution_time was set to 60 seconds, i’ve upped it to 600 seconds and its still failing.

    I have products – 649 product_variations – 7928, not all are set to sync but most are

    Does it really have to run every 15 minutes? as don’t make that many changes that can’t wait either for a daily or half day sync

    Plugin Author SkyVerge

    (@skyverge)

    Hey @awr10e!

    Thanks so much for checking that for me. I was able to catch up with the developers today about this to see what we could suggest. At this time it’s fairly difficult to adjust this interval, though the developers have raised an issue internally to look at this further.

    In the new version the developers are working on with Facebook at the moment, it will use Facebook’s new Batch API. This is going to be much more performant to sync products and in testing has looked good so far! While the feed file won’t be removed immediately, as there is a migration process that will need to happen in order to use the new API, there is a plan to potentially remove the feed file sync in a future release.

    In the meantime, the only way to adjust the feed file generation would be to remove it entirely, though this would obviously leave you without a product sync!

    add_action( 'plugins_loaded', function() {
    
        remove_action( 'init', [ facebook_for_woocommerce()->get_product_feed_handler(), 'schedule_feed_generation' ] );
    }, PHP_INT_MAX );

    There is one final option, though it’s fairly messy I’m afraid. The current sync schedule set up in Facebook is set to “replace“, which you can see when logging into Catalog Manager and browsing to Product Feed Sources. This can be adjusted to “update” instead. Replace will remove any products that are not included in the feed file when syncing, Update will not.

    If you were to switch the schedule to “update” then it might be possible to set most of your products to “excluded from sync” and only new products to “included in sync” from within WooCommerce. This should hopefully give the plugin less products to process, and have it generate a smaller feed file within the time limit. It would then sync only these products and update them, rather than removing the rest.

    I’m sorry this isn’t an ideal situation and that there is no simple workaround at this time. I really hope we can progress on the next major release with the benefits of the new API!

    Do you think any of these suggestions might be possible for you?

    Cheers!

    Simon.

    Hi Simon
    Thanks for the update.
    I’ve unticked the sync button in the options and that has removed the task, but appears to have left my currently synced products on Facebook.
    Think i’ll wait until you migrate to the new sync method, but if i need to i can retick this box.
    I’ll keep an eye on the change log on updates.
    Regards

    Plugin Author SkyVerge

    (@skyverge)

    Hey @awr10e,

    Ah, great. Thanks for letting me know! Sorry once again for the failures, please do let me know how you get on once the new major version is available.

    Cheers!

    Simon.

    Hi Simon @skyverge,

    Apologies the emails saying I had a reply had gone into spam πŸ™

    I’ve checked and we’re definitely set at 600 for php execution. WooCommerce Status page extract:

    Server environment
    Server info:		nginx/1.14.0
    PHP version:		7.2.24-0ubuntu0.18.04.6
    PHP post max size:		20 MB
    PHP time limit:		<strong>600</strong>
    PHP max input vars:		1000

    but I agree, one part of the action scheduler log says ‘Fatal error Maximum execution time of 60 seconds exceeded’ while another says ‘action timed out after 300 seconds’ and another ‘Fatal error Maximum execution time of 120 seconds exceeded’. We also have ‘PHP Fatal error Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes)’ which if my math is correct is 1G of mem (which is again interesting since we have WP_MAX_MEMORY_LIMIT = 512M and WP_MEMORY_LIMIT = 128 set in wp-config).

    I’ve actually been reading up on the action scheduler as we’ve just written a plugin to sort orders to queues as they come in and we’ve opt for using the scheduler so it doesn’t impact the generation of woocommerce pages for the customer.
    We’ve noticed some of the jobs are taking a time to start as the action scheduler is running the facebook stuff (and it’s definitely in the in-progress status for longer that 30/60 seconds, currently looking at one (5 minutes 47 seconds ago)), so we’ve had to increase the concurrent batches to 3 (instead of 1) so that the in-progress facebook job doesn’t impact other jobs. However I did read about increasing time limits and batch size for action scheduler. We may give that a go or alternatively use wp-cli to fire the scheduler which suggests it may not encounter such problems.

    I also agree with @awr10e every 15 mins does seem a bit excessive, we’d be lucky to have new products or updates weekly. Given the (at least some) jobs are running for a quite a time, it must be taking quite some resources to generate this feed so often.

    Fingers crossed for the new API version πŸ™‚

    Plugin Author SkyVerge

    (@skyverge)

    Hey @bighippo999,

    Thanks so much for all the information here, that’s really great! Assessing the schedule is certainly on the list for the developers to look at. I think the current thought is that they would rather remove this altogether in a future release. Hopefully, the Batch Update API performs as well in the wild as it did in testing!

    This may be some time before we can do that though, as we will have to make sure all merchants have migrated over to the new API connection, which wouldn’t be possible for the first release. Unfortunately as mentioned above, it’s not super simple to adjust this at the moment.

    There is a possibility to use some custom code to edit the interval:

    
    /*
     * Adjust the interval that the feed file is generated.
     */
    function sv_wc_facebook_feed_generation_interval( $interval ) {
      	return 60 * 30;
    }
    
    add_filter( 'wc_facebook_feed_generation_interval', 'sv_wc_facebook_feed_generation_interval', 10, 1 );
    

    in this example, it would set it to 30 minutes (it’s set in seconds). In order for this to take effect, however, the current scheduled actions need to be removed, which in this case means turning off product sync so that they are deleted. Once the product sync is re-enabled, the new interval should be used!

    All that said though, as your file generation is not completing at any time, it may just be simplest to disable this for the time being. At least to avoid it affecting your other scheduled actions.

    Thanks for getting back to me and keeping me in the loop! And yes, fingers crossed for the new release πŸ™‚

    Cheers!

    Simon.

    Hello I have the same problem! you fix this all ready? you can give me more especific accions to fix it?
    https://snipboard.io/pJGwkq.jpg

    https://snipboard.io/ejVGxl.jpg

    https://snipboard.io/mYTK74.jpg

    Plugin Support Pit Bozionelos

    (@pitbozionelos)

    Hey @zequ ,

    Thank you very much for replying in this thread and I’m sorry to hear that our plugin is causing you this issue.

    I’d be happy to further assist you with this, however, I’ll have to ask you to create a new topic. Despite any similarity in symptoms, your issue may be different because of possible differences in physical servers, accounts, hosts, plugins, theme, configurations, etc. Also, replying to unresolved threads is not recommended as per the Forum FAQ, and it’s possible that your reply will get archived and we won’t be able to provide you with more information.

    Would it be possible to create a new topic by clicking here and tag me to proceed with further investigating this? πŸ™‚

    Thank you,

    Pit
    SkyVerge

    Plugin Support Pit Bozionelos

    (@pitbozionelos)

    Hey @bighippo999 ,

    It has been a while since we heard from you, so I’m going to mark this topic as resolved. If you’re still experiencing issues please take a look at our documentation for more information and create a new thread if you have further questions.

    Thanks,

    Pit
    SkyVerge

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.