fix(worker): per-commit concurrency limit for upload_finisher tasks#754
Closed
thomasrockhu-codecov wants to merge 1 commit intomainfrom
Closed
fix(worker): per-commit concurrency limit for upload_finisher tasks#754thomasrockhu-codecov wants to merge 1 commit intomainfrom
thomasrockhu-codecov wants to merge 1 commit intomainfrom
Conversation
Large CI matrices (e.g. stacks-network with 167 uploads, mixpanel with 100+) fire one finisher task per upload. All of them fight for the same per-commit Redis lock, blocking worker slots for up to 30s each before retrying. This starves the worker pool and causes a cascading queue buildup (44k+ tasks). Add a Redis INCR-based concurrency gate: only MAX_CONCURRENT_FINISHERS_PER_COMMIT (3) tasks can actively work on a given commit at any time. Excess tasks exit in milliseconds, freeing their worker slots immediately. The counter is decremented in a finally block with a 660s TTL safety net. Made-with: Cursor
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
upload_finishertasks. OnlyMAX_CONCURRENT_FINISHERS_PER_COMMIT(3) finisher tasks can actively work on a given commit at any time. Excess tasks exit in milliseconds, freeing their worker slots immediately.Why
Large CI matrices fire one finisher task per upload via chord callbacks. All these finishers fight for the same per-commit Redis lock (
UPLOAD_PROCESSING). Withblocking_timeout=30s, each excess task wastes a worker slot for 30 seconds before failing, retrying with backoff, and going back to the queue. This creates a cascading worker starvation effect.How it works
finallyImpact estimate
For a commit with N concurrent finishers:
Test plan
test_exits_early_when_concurrency_limit_reached— verifies tasks over the limit return{concurrency_limited: True}and decrement the countertest_proceeds_when_under_concurrency_limit— verifies tasks under the limit proceed normally and decrement on exittest_counter_decremented_on_exception— verifies the counter is decremented even when the task throws an exception