-
Notifications
You must be signed in to change notification settings - Fork 795
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
Clear cache after a scheduler update is queued #37399
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. Mu Wpcom plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
037a89b
to
8ab11a1
Compare
projects/packages/scheduled-updates/src/class-scheduled-updates.php
Outdated
Show resolved
Hide resolved
projects/packages/scheduled-updates/src/class-scheduled-updates.php
Outdated
Show resolved
Hide resolved
projects/packages/scheduled-updates/src/class-scheduled-updates.php
Outdated
Show resolved
Hide resolved
.../scheduled-updates/src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php
Outdated
Show resolved
Hide resolved
.../scheduled-updates/src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php
Outdated
Show resolved
Hide resolved
projects/packages/scheduled-updates/src/class-scheduled-updates.php
Outdated
Show resolved
Hide resolved
projects/packages/scheduled-updates/src/class-scheduled-updates.php
Outdated
Show resolved
Hide resolved
.../scheduled-updates/src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php
Outdated
Show resolved
Hide resolved
@ouikhuan @zaerl I don't know if Scheduled Updates is the best place for this, but after reading through the thread (p1715925157297969-slack-C01A60HCGUA), I do wonder if clearing cron option cache on Based on your testing it looks like updating cron array with stale data is not just a problem with ActionScheduler but with any event that gets scheduled in close timely proximity to one another? |
Yeah, I agree. This seems to be a more general problem that happens whenever two schedule events run at the same second, and might be better to place this fix somewhere else.
I think we could try to limit it to
That's correct. It can also be some other events like |
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.
@zaerl , I think we'll also need to add the "lock" when we try to delete a schedule, since it might also happens when another schedule event is triggered, what do you think?
Here's a scenario:
- wp_unschedule_event runs -> the cron get removed.
- At same second another schedule event triggered ( can be jetpack_sync_full_cron )
- The cron value gets overwritten again.
|
.../scheduled-updates/src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php
Outdated
Show resolved
Hide resolved
@obenland where do you think it's the best for us to place this fix? Should we put it on the Scheduled Updates package as an initial and run for a while to make sure we don't bring in any side effects and move it to a more general place later? Or should we move it to a more general place directly? If so, where do you think is better? Jetpack plugin or wpcomsh? |
Yeah, that's a good question. With the transient it should probably live in scheduled updates. If we removed that transient, it might make sense to put in wpcomsh with review from others. Ultimately it sounds like a consideration for Core? |
Yes, I think we'll need to have transient so it only clears the cache when it has to. And since this is more like a general issue for the schedule event system I think it'll be nice to consider adding this to Core eventually. |
.../scheduled-updates/src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php
Show resolved
Hide resolved
...kages/scheduled-updates/tests/php/class-wpcom-rest-api-v2-endpoint-update-schedules-test.php
Outdated
Show resolved
Hide resolved
projects/packages/scheduled-updates/src/class-scheduled-updates.php
Outdated
Show resolved
Hide resolved
.../scheduled-updates/src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php
Outdated
Show resolved
Hide resolved
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.
Tested several times with other schedule events running at the same second and it looks great. Thanks for handling all the feedback!
Fixes: Automattic/wp-calypso#90627
Context: p1715613932876249-slack-C01A60HCGUA
Proposed changes:
jetpack_scheduled_update_updated
is run only on successful scheduled event creationOther information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: