fix: eliminate head-of-line blocking in RedisWorker.fetch_task() - #7975
Closed
dkliban wants to merge 1 commit into
Closed
fix: eliminate head-of-line blocking in RedisWorker.fetch_task()#7975dkliban wants to merge 1 commit into
dkliban wants to merge 1 commit into
Conversation
When the task queue has thousands of tasks needing the same blocked resource, workers could not reach tasks for free resources further down the queue. The old algorithm doubled its query window and restarted from position 0 each time, re-scanning the same blocked tasks repeatedly. Track resources that acquire_locks() reports as blocked and exclude tasks needing those resources from subsequent DB queries using PostgreSQL's array overlap operator against the existing GIN index on reserved_resources_record. In the incident scenario (17,000+ tasks blocked on one repository), this reduces the search from ~11 doubling iterations fetching ~37,000 rows to 2 queries fetching ~40 rows. Closes: pulp#7900 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 exclusive resource (#7900).
After acquire_locks reports a resource is blocked, tasks needing that resource
are excluded from subsequent DB queries using the GIN-indexed
reserved_resources_record overlap check. Both raw and shared: prefixed
variants are excluded so tasks needing either exclusive or shared access
to the blocked resource are skipped.
Changes
Testing
finds the free task in <= 5 acquire_locks calls (old algorithm needs ~8)
Benchmark results (from factory)
Fixes #7900
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com