-
Notifications
You must be signed in to change notification settings - Fork 107
[PLTFRM-1860] Search: Use additional status WHERE clause in update_jobs() to prevent race condition #6662
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
base: develop
Are you sure you want to change the base?
Conversation
512d0c6 to
6b95704
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #6662 +/- ##
=============================================
+ Coverage 34.85% 34.90% +0.04%
- Complexity 5029 5030 +1
=============================================
Files 295 295
Lines 20737 20739 +2
=============================================
+ Hits 7228 7238 +10
+ Misses 13509 13501 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull request overview
This PR adds race condition protection to the Search Queue's update_jobs() method by introducing an optional $where_conditions parameter. This allows atomic check-and-update operations to prevent concurrent processes from updating jobs that have already been processed by another process. The change is applied to checkout_jobs() and process_jobs() methods to ensure jobs are only updated when they're in the expected state.
Key Changes:
- Added optional
$where_conditionsparameter toupdate_jobs()method for conditional updates - Updated
checkout_jobs()to only update jobs that are in 'queued' status - Updated
process_jobs()to only update jobs that are in 'scheduled' status
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| search/includes/classes/class-queue.php | Added $where_conditions parameter to update_jobs() method and implemented WHERE clause logic; updated checkout_jobs() and process_jobs() to use conditional updates |
| tests/search/includes/classes/test-class-queue.php | Added comprehensive test coverage for the new WHERE conditions functionality, including race condition scenarios and edge cases; updated existing test_process_jobs() to set jobs to 'scheduled' status before processing |
102738c to
09127a4
Compare
09127a4 to
2b63f3a
Compare
…bs() to prevent race condition Co-Authored-By: Copilot <[email protected]>
2b63f3a to
3d747a7
Compare
|



Description
This pull request enhances the job queue system by adding support for conditional updates on jobs, improving concurrency safety. The main change is that the
update_jobsmethod now accepts additional WHERE conditions, allowing updates to be restricted based on job state (such as only updating jobs with a specific status). This helps prevent race conditions when multiple processes interact with the queue.Changelog Description
Changed
Pre-review checklist
Please make sure the items below have been covered before requesting a review:
Pre-deploy checklist
Steps to Test