-
Notifications
You must be signed in to change notification settings - Fork 1
Add better handling of deadlocks in DbScheduler #15
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
Conversation
dc5ac44 to
cc585e0
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 2.x.x #15 +/- ##
============================================
+ Coverage 65.43% 68.07% +2.63%
- Complexity 120 132 +12
============================================
Files 10 10
Lines 434 473 +39
============================================
+ Hits 284 322 +38
- Misses 150 151 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Does it need to use an extra dependency for retries? Seems like you've got all the logic here already, apart from the basic Also, looks like the examples in |
e90040c to
1ca7bce
Compare
|
@chrisminett Examples and README have been updated with the new usage of DbScheduler |
| ORDER BY | ||
| scheduled_ts DESC | ||
| LIMIT {$batchSize}"; | ||
| LIMIT {$batchSize} |
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.
should we be binding batchSize just to be safe?
Limit :batchSize
and then add the batchSize through the stuff below where you are doing minimumPickup
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.
It's not quite that simple. The default type PDO uses for binding is string (which would be a syntax error here as it would be quoted) and phlib/db does not support setting the type of a bind.
This should be safe as-is, we are using strict types and $batchSize is type hinted as an int, so it shouldn't be possible to pass an unsafe value here. The :minimumPickup binding was added back in the PHP 5.4 days before strict typing was in the language.
1ca7bce to
74de03c
Compare
74de03c to
51b5aaa
Compare
This updates DbScheduler to handle deadlocks better when claiming jobs. This should prevent potential issues when running multiple workers for the MonitorCommand.
This makes the following changes:
SELECT ... FOR UPDATEand the update the rows as claimed, which should prevent unnecessary locks when indexes are properly configured for the table.SKIP LOCKEDto be used on the query. This change allows jobs to be considered claimed by a worker as soon as the row becomes locked.stechstudio/backofflibrary and requires aBackoffobject to passed into the constructor.