fix: prevent head-of-line blocking in RedisWorker fetch_task() - #7977
Closed
dkliban wants to merge 3 commits into
Closed
fix: prevent head-of-line blocking in RedisWorker fetch_task()#7977dkliban wants to merge 3 commits into
dkliban wants to merge 3 commits into
Conversation
Track blocked resources across fetch_task() iterations and exclude them at the DB level using reserved_resources_record__overlap, leveraging the existing partial GIN index. This prevents workers from re-scanning thousands of blocked tasks when free resources exist further in the queue. Closes: pulp#7900 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes head-of-line blocking in RedisWorker.fetch_task() when thousands of
tasks need the same blocked resource (#7900).
After acquire_locks reports a resource as blocked, tasks needing that resource
are excluded from subsequent DB queries using reserved_resources_record overlap,
leveraging the existing partial GIN index. Both raw and shared: prefixed
variants are excluded.
Tests
Two test files:
Reproduction test (test_fetch_task_hol_blocking.py): 200 blocked tasks + 1 free task, asserts acquire_locks called <= 3 times. Fails on buggy code (6 calls), passes on fix (2 calls).
Scale test (test_fetch_task_scale.py): 2000 tasks across 50 resources with DB query assertions:
Fixes #7900
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com