Repository navigation
Conversation
…event shared-dict corruption under concurrent execution
auvipy
requested changes
Aug 8, 2026
auvipy
left a comment
Member
There was a problem hiding this comment.
closing in favor of another pr
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.
Description
Fix a bug where
autoretry_for+retry_backoffmutate a singleretry_kwargsdict shared across all executions of a task.Root Cause
In
celery/app/autoretry.py,add_autoretry_behaviour()builds theretry_kwargsdict once per task class at registration time. The generatedrun()closure captures this single dict and mutates it in place on every retry:Under concurrent execution (eventlet/gevent pools), one execution's write of
countdown/max_retriescan land in the window between another execution's write and its use of that dict intask.retry(**retry_kwargs), so that other execution ends up retrying with the wrong backoff delay.Fix
Copy the
retry_kwargsdict inside theexceptblock before mutating it, so each execution uses its own copy.Test
Added
test_autoretry_shared_retry_kwargs_not_mutatedregression test that:autoretry_for+retry_backoffretry_kwargsdict via__closure__task.run()withRetryexception{'countdown': 4}before the fix)Closes #10456