Repository navigation
Fix DynamoDB backend: tolerate ResourceInUseException when pool processes race to create the result table - #11106
Merged
auvipy merged 3 commits intoNov 24, 2026
Conversation
…sses race to create the result table When the result table does not exist yet, every pool process tries to create it on its first write. The losers' create_table raises ResourceInUseException, which _get_or_create_table let through, so the result write failed and the task was stored as FAILURE although it ran. Treat the error as 'another process is creating it': wait for the table to become ACTIVE and describe it, as the backend did before celery#7734.
This comment was marked as abuse.
This comment was marked as abuse.
Member
|
there is no need for rush. the review Q is pretty long |
auvipy
approved these changes
Nov 24, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11106 +/- ##
=======================================
Coverage 91.35% 91.35%
=======================================
Files 153 153
Lines 21889 21896 +7
Branches 2721 2722 +1
=======================================
+ Hits 19997 20004 +7
Misses 1590 1590
Partials 302 302
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
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.
Problem
Fixes #11087.
When the DynamoDB result table does not exist yet, every pool process of a worker tries to create it on its first result write. The processes that lose the race get
ResourceInUseExceptionfromcreate_table, andDynamoDBBackend._get_or_create_table()lets it propagate — so the result write fails and a task that ran fine is stored as FAILURE. This is a regression from #7734, which dropped theResourceInUseExceptiontolerance the backend had up to 5.2.x.Fix
In
_get_or_create_table(), wrap thecreate_tablecall: onResourceInUseException, treat it as "another process is creating the table" — wait for the table to becomeACTIVEvia the existing_wait_for_table_status()and return a freshdescribe_table. Any otherClientErrorfromcreate_tablestill propagates unchanged.Tests
New unit tests in
t/unit/backends/test_dynamodb.py:test_get_or_create_table_create_race— describe →ResourceNotFoundException, create →ResourceInUseException, then describe returns the ACTIVE table. Fails without the fix (theClientErrorpropagates), passes with it.test_get_or_create_table_create_other_error— a different create error (ValidationException) still propagates and no wait happens.Full file:
t/unit/backends/test_dynamodb.py— 40 passed with the fix; the new race test fails on unpatchedmain. flake8 clean.Disclosure: this change was prepared with the assistance of an AI coding tool; the diagnosis, reproduction and test results above were verified locally by running the test suite.