BUG: recover_sub_pool no longer raises on concurrent create_actor - #204
Merged
qinxuye merged 3 commits intoAug 30, 2026
Merged
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #204 +/- ##
===========================================
- Coverage 88.97% 75.85% -13.13%
===========================================
Files 48 57 +9
Lines 4038 5326 +1288
Branches 770 581 -189
===========================================
+ Hits 3593 4040 +447
- Misses 358 1145 +787
- Partials 87 141 +54
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
recover_sub_pool iterated self._allocated_actors[address].values() directly while awaiting self.call() inside the loop. create_actor() mutates that same dict across an await too (a placeholder key set before its own call, popped after), so a create_actor() landing during recovery raised RuntimeError: dictionary changed size during iteration. Snapshot the values into a list before iterating, mirroring the same guard already used for self.sub_processes in monitor_sub_pools. Fixes xorbitsai#48
AmirF194
force-pushed
the
fix/48-recover-sub-pool-dict-race
branch
from
August 29, 2026 04:02
7e8707c to
e406f91
Compare
qinxuye
reviewed
Aug 29, 2026
create_actor() inserts a placeholder under key None before awaiting the sub pool create and only pops it once that call returns. If the sub pool dies mid create, the placeholder is left in the dict holding the caller's original, unfinished message. recover_sub_pool()'s replay loop was iterating that entry too, resending an unfinished, from_main=False CreateActorMessage straight to the sub pool and duplicating the pending create. Skip entries keyed by None when replaying, and add a test that pins this behavior.
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
Contributor
Author
|
Thanks for catching the placeholder replay case and for the quick review, appreciate it. |
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.
What do these changes do?
MainActorPool.recover_sub_pool(indigen/pool.py) iteratesself._allocated_actors[address].values()directly and awaitsself.call(...)inside the loop for every actor being recreated.create_actor(pool.py) writes into that same dict across an awaittoo: it sets a placeholder key before calling out, then replaces or
pops it once the call returns. If a
create_actorcall lands on thesame sub pool address while
recover_sub_poolis mid-loop, the dict'ssize changes between two iteration steps and Python raises
RuntimeError: dictionary changed size during iteration, abortingrecovery for every actor still left in the loop.
The fix snapshots
.values()into a list before iterating, so latermutations of the live dict don't affect the iteration in progress.
monitor_sub_poolsalready guards its own iteration overself.sub_processesthe same way a few lines down, so this bringsrecover_sub_poolin line with that existing pattern rather thanintroducing a new one.
Related issue number
Fixes #48
Check code requirements
Verification
test_recover_sub_pool_concurrent_create_actordrives thereal
recover_sub_pool/create_actormethods on aMainActorPoolinstance with
call/start_sub_pool/wait_sub_pools_readystubbed,and controls the interleaving with
asyncio.Events so acreate_actorcall is guaranteed to land while recovery is pausedmid-iteration. Confirmed it fails on unmodified
mainwith theexact
RuntimeErrorfrom the issue, and passes on this branch, bothin the same container.
xoscar/backendssuite: 82 passed, 1 pre-existing failure(
test_sub_pool_quit_with_main_pool, a zombie-reaping assertion thatfails identically on unmodified
mainin this container due to noinit process; unrelated to this change) plus 6 skipped, both before
and after the fix.
black,flake8,isortandmypy(this repo's own pre-commithooks) all clean on the two changed files.
ci.ymlmatrix across all five Python versionsand three OSes; verified on Python 3.11 in a Debian container only.