-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve our job scheduling service for more resilience #9435
Improve our job scheduling service for more resilience #9435
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic makes sense, and nice catch @oaratovskyi. I think this would be sufficient to ensure AS is initialized before being used. Thanks for the fix! LGTM 🚀 it!
Size Change: 0 B Total Size: 1.33 MB ℹ️ View Unchanged
|
Thank you for digging into the flaky unit tests on GitHub CI, @tpaksu! I also thought about force-calling the AS init hook, but refrained from it because of the danger of side effects, the primary one being that the AS is not initialized, but we are "letting the world know" that it has. But since we have no better way forward, and it is only affecting our unit tests, I think we can go with it and revisit if it turns out to bite us in the back. |
@vladolaru the action When I searched for
and on I don't know if this is the real cause on GH, but maybe, we can add another clause to the function you modified on our side, that checks if the |
Update: After much investigation with @tpaksu (see p1726471929778379/1719838546.986229-slack-C03KTTK2YMA), we found out why PHPUnit tests were failing in GitHub CI jobs, while they didn't locally. The reason is that we are using WC 7.6.0 in CI, and that version ships with a too-old version of ActionScheduler, one that doesn't fire the To maintain backward compatibility (until we increase the minimum supported WC version - there was an attempt to do so), we introduced logic to check for the WC 7.9.0 version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good and work according to the instructions!
Fixes #9434
Related #6662 #5279
Changes proposed in this Pull Request
We improved our job scheduling service to adjust to whether the ActionScheduler has been initialized or not. If it has, we schedule the job immediately. If it hasn't, we hook into the WP action that is fired on the ActionScheduler initialization (
action_scheduler_init
) and schedule the job then.Note: This will only work with WooCommerce 7.9.0+ (ActionScheduler 3.5.5+). The provided solution is backward compatible.
Additionally, I took the opportunity to snatch a performance gain and check with
as_has_scheduled_action
(introduced in ActionScheduler 3.3.0 - quite a while back) if there are scheduled jobs before un-scheduling them. We save up to 3 DB queries this way (see details).Testing instructions
http://localhost:8082/wp-admin/tools.php?page=action-scheduler&status=pending
) and delete/run anywcpay_
actions.wcpay_update_compatibility_data
hook, scheduled for approx. 2 minutes into the future. Wait a couple of seconds, refresh the page, and see that the time for running the job is decreasingwcpay_update_compatibility_data
hook should be rescheduled with a scheduled time of approx 2 minutes into the futuretrue
:wcpay_update_compatibility_data
andwcpay_webhook_fetch_events
wcpay_track_new_order
hook.npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge