Conversation
Fix a race condition in inserting a one-time job. It could also be avoided by using a "FOR UPDATE" on the select, but I think this solution is cleaner. Also fix a bug in the test where if we rounded up to the nearest second, the finish time was one second off from the value we compared it to, and the test failed 50% of the time.
tmccombs
commented
Feb 13, 2026
| // Same as "addJob()" but without the finish | ||
| val prepared = connection.prepareStatement( | ||
| """ | ||
| SELECT EXISTS( |
Contributor
Author
There was a problem hiding this comment.
@hunterrees do you have an opinion on whether we should use INSERT IGNORE, or add a FOR UPDATE for this select?
Contributor
There was a problem hiding this comment.
I think the INSERT IGNORE is cleaner personally. Makes it easier to follow
There was a problem hiding this comment.
If INSERT IGNORE will work I think that will be better. Cleaner and I believe fewer locks to worry about.
aegbert5
approved these changes
Feb 13, 2026
| // Same as "addJob()" but without the finish | ||
| val prepared = connection.prepareStatement( | ||
| """ | ||
| SELECT EXISTS( |
Contributor
There was a problem hiding this comment.
I think the INSERT IGNORE is cleaner personally. Makes it easier to follow
hunterrees
approved these changes
Feb 13, 2026
| // Same as "addJob()" but without the finish | ||
| val prepared = connection.prepareStatement( | ||
| """ | ||
| SELECT EXISTS( |
There was a problem hiding this comment.
If INSERT IGNORE will work I think that will be better. Cleaner and I believe fewer locks to worry about.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix a race condition in inserting a one-time job.
It could also be avoided by using a "FOR UPDATE" on the select, but I think this solution is cleaner.
Also fix a bug in the test where if we rounded up to the nearest second, the finish time was one second off from the value we compared it to, and the test failed 50% of the time.
@aegbert5