Change redis worker task pickup algo to respect FIFO shared resources#7623
Merged
Change redis worker task pickup algo to respect FIFO shared resources#7623
Conversation
dkliban
previously approved these changes
Apr 22, 2026
A finalizer task (exclusive resource lock) can start before sibling tasks (shared resource lock) have completed if they are blocked on a separate exclusive resource. In the Redis worker, this bypasses FIFO ordering because the sibling's shared resource is never added to blocked_shared when the blocking reason is its exclusive resource. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ad4364c to
0d7e7a3
Compare
ggainey
approved these changes
Apr 22, 2026
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.
When the redis task worker is fetching tasks, it is checking waiting tasks in creation order that have
app_lock=null. Then for each task it tries to acquire the resource (and task) locks on the task from redis. If it succeeds then it proceeds to switch the the task'sapp_lock=self.app_statusand return the task, with the goal being that the redis checks will make this final update call only happen on one worker, reducing database row contention. Now the redis check only sees currently taken resource locks from running tasks, it has no idea about tasks that are waiting ahead of the task we are checking. So the redis worker needs to create a list of taken resources ahead of the current checked task to prevent out of order execution.Another thing to note is that the
block_resource_listthat redis returns is opportunistic so it will return as soon as it finds a blocked resource. It doesn't always check every resource that was blocked.📜 Checklist
See: Pull Request Walkthrough