Skip to content

Fix Map zone gather race for async process-type tasks#776

Draft
GeigerJ2 wants to merge 3 commits into
aiidateam:mainfrom
GeigerJ2:fix/map-gather-race-async-tasks
Draft

Fix Map zone gather race for async process-type tasks#776
GeigerJ2 wants to merge 3 commits into
aiidateam:mainfrom
GeigerJ2:fix/map-gather-race-async-tasks

Conversation

@GeigerJ2
Copy link
Copy Markdown
Contributor

@GeigerJ2 GeigerJ2 commented Apr 13, 2026

update_map_task_state aggregated outputs by iterating over the gather_item's own clones, but for async process-type source tasks (CalcJob, WorkChain, @task.graph) the awaitable callback cascade can finish all mapped source tasks and reach the gather phase before continue_workgraph has scheduled the gather_item clones. The missing clone results caused a KeyError or left clones stuck in PLANNED, hanging the engine's finalize path.

Two changes fix this:

  • generate_mapped_tasks now skips cloning gather_item entirely. The gather_item executor is a pure pass-through (return_input), so no per-item clone is needed. Skipping it also removes the PLANNED-clone hang.

  • update_map_task_state reads results directly from each mapped source task's clones (via source_task.mapped_tasks) instead of from gather_item clones. This is semantically equivalent and race-free because source task results are populated by update_task_state before the cascade can reach the gather phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant