[Reproducible] Parallel Execution + Iteration bug #15867

Closed
opened 2026-02-21 19:23:44 -05:00 by yindo · 5 comments
Owner

Originally created by @DavideDelbianco on GitHub (Aug 4, 2025).

Originally assigned to: @Nov1c444 on GitHub.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.7.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Have a workflow with iteration nodes

✔️ Expected Behavior

Only one entry per node execution should be present.
While iteration is in progress, the tracing entry should be in the correct branch

Actual Behavior

The current iteration is added to the last child at the same nesting level:
Image

After execution entries are doubled:
Image

Inside the iteration every node entry is doubled:

Image Image
Originally created by @DavideDelbianco on GitHub (Aug 4, 2025). Originally assigned to: @Nov1c444 on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.7.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Have a workflow with iteration nodes ### ✔️ Expected Behavior Only one entry per node execution should be present. While iteration is in progress, the tracing entry should be in the correct branch ### ❌ Actual Behavior The current iteration is added to the last child at the same nesting level: <img width="1859" height="916" alt="Image" src="https://github.com/user-attachments/assets/b491bbf8-475e-42ec-b22f-d18c86014700" /> After execution entries are doubled: <img width="568" height="381" alt="Image" src="https://github.com/user-attachments/assets/ac7414ee-e662-4098-aff1-12c9b90a6182" /> Inside the iteration every node entry is doubled: <img width="1021" height="203" alt="Image" src="https://github.com/user-attachments/assets/26e5a0a4-cdaa-43f1-9357-d8333be95b56" /> <img width="598" height="887" alt="Image" src="https://github.com/user-attachments/assets/8d63e89e-560f-4952-9b86-2b53c9ce59a2" />
yindo added the 🐞 bug label 2026-02-21 19:23:44 -05:00
yindo closed this issue 2026-02-21 19:23:44 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 4, 2025):

This is a known bug in Dify when multiple Iteration nodes run in parallel: trace entries are duplicated, matching the number of parallel nodes. This has been reported by other users and is related to how trace events are aggregated and visualized when parallel branches are present. The underlying event model does include identifiers to distinguish context, but the trace/logging layer in v1.7.1 doesn't fully disambiguate them, leading to the duplication you see.

Recent versions of Dify (after March 2025) include fixes and refactors that address iteration log index errors and improve trace handling for parallel and iteration nodes—see PR #14855 and related issues. Major workflow and trace changes in July 2025 (e.g., PR #22581, PR #22623) further improve trace ID propagation and event handling, which should resolve or significantly reduce this problem.

There is no documented workaround for v1.7.1 aside from upgrading. If you need to avoid the duplication, the best path is to update to the latest version, where these fixes are included. If you want to investigate or patch this yourself, the relevant logic is in the iteration node implementation, the workflow engine, and the trace event aggregation/visualization code (iteration_node.py, graph_engine.py, and the logging callback).

Let me know if you want more details on the specific code paths or recent changes!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 4, 2025): <!-- Answer --> This is a known bug in Dify when multiple Iteration nodes run in parallel: trace entries are duplicated, matching the number of parallel nodes. This has been reported by other users and is related to how trace events are aggregated and visualized when parallel branches are present. The underlying event model does include identifiers to distinguish context, but the trace/logging layer in v1.7.1 doesn't fully disambiguate them, leading to the duplication you see. Recent versions of Dify (after March 2025) include fixes and refactors that address iteration log index errors and improve trace handling for parallel and iteration nodes—see [PR #14855](https://github.com/langgenius/dify/pull/14855) and related issues. Major workflow and trace changes in July 2025 (e.g., [PR #22581](https://github.com/langgenius/dify/pull/22581), [PR #22623](https://github.com/langgenius/dify/pull/22623)) further improve trace ID propagation and event handling, which should resolve or significantly reduce this problem. There is no documented workaround for v1.7.1 aside from upgrading. If you need to avoid the duplication, the best path is to update to the latest version, where these fixes are included. If you want to investigate or patch this yourself, the relevant logic is in the iteration node implementation, the workflow engine, and the trace event aggregation/visualization code ([iteration_node.py](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/iteration/iteration_node.py), [graph_engine.py](https://github.com/langgenius/dify/blob/main/api/core/workflow/graph_engine/graph_engine.py), and the logging callback). Let me know if you want more details on the specific code paths or recent changes! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/beb2e280-33bc-4446-8fa6-9d30e740f7e2?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/beb2e280-33bc-4446-8fa6-9d30e740f7e2?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/beb2e280-33bc-4446-8fa6-9d30e740f7e2?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/beb2e280-33bc-4446-8fa6-9d30e740f7e2?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/beb2e280-33bc-4446-8fa6-9d30e740f7e2?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/beb2e280-33bc-4446-8fa6-9d30e740f7e2?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/beb2e280-33bc-4446-8fa6-9d30e740f7e2?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/23374)
Author
Owner

@DavideDelbianco commented on GitHub (Aug 4, 2025):

It's not just tracing, I've found out that there's also iteration data discrepancies:

Image

The iteration itself is not running in parallel, it seems to just execute every node 2 times with different resolved values...

@DavideDelbianco commented on GitHub (Aug 4, 2025): It's not just tracing, I've found out that there's also iteration data discrepancies: <img width="1828" height="971" alt="Image" src="https://github.com/user-attachments/assets/63ad44a8-fdd4-49cc-a989-a4f83fe22fbd" /> The iteration itself is not running in parallel, it seems to just execute every node 2 times with different resolved values...
Author
Owner

@dosubot[bot] commented on GitHub (Aug 4, 2025):

The data discrepancies you’re seeing—where nodes execute multiple times with different resolved values, even when iteration isn’t running in parallel—are a real execution bug in Dify v1.7.1. This isn’t just a tracing issue: it’s caused by how serial (non-parallel) Iteration nodes share and mutate the same variable pool object in the workflow context. When you have multiple Iteration nodes at the same workflow level, their state can interfere, leading to nodes running more than once with different data. This is a known architectural flaw in v1.7.1 and earlier, and there’s no documented workaround short of upgrading.

Recent versions (after March 2025) include major refactors and fixes that address both trace duplication and underlying execution/data issues for iteration and parallel nodes—see PR #14855 and PR #22581 for details. Upgrading to a version after these changes should resolve the problem. If you need to patch it yourself, the core issue is that serial Iteration nodes should deep-copy the variable pool for each node to isolate their state, but this isn’t enforced in v1.7.1’s workflow engine logic.

Let me know if you want more technical details or code pointers.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 4, 2025): <!-- Answer --> The data discrepancies you’re seeing—where nodes execute multiple times with different resolved values, even when iteration isn’t running in parallel—are a real execution bug in Dify v1.7.1. This isn’t just a tracing issue: it’s caused by how serial (non-parallel) Iteration nodes share and mutate the same variable pool object in the workflow context. When you have multiple Iteration nodes at the same workflow level, their state can interfere, leading to nodes running more than once with different data. This is a known architectural flaw in v1.7.1 and earlier, and there’s no documented workaround short of upgrading. Recent versions (after March 2025) include major refactors and fixes that address both trace duplication and underlying execution/data issues for iteration and parallel nodes—see [PR #14855](https://github.com/langgenius/dify/pull/14855) and [PR #22581](https://github.com/langgenius/dify/pull/22581) for details. Upgrading to a version after these changes should resolve the problem. If you need to patch it yourself, the core issue is that serial Iteration nodes should deep-copy the variable pool for each node to isolate their state, but this isn’t enforced in v1.7.1’s workflow engine logic. Let me know if you want more technical details or code pointers. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/d92e3721-b9f4-480d-8a4d-1d158ce5acaa?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/d92e3721-b9f4-480d-8a4d-1d158ce5acaa?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/d92e3721-b9f4-480d-8a4d-1d158ce5acaa?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/d92e3721-b9f4-480d-8a4d-1d158ce5acaa?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d92e3721-b9f4-480d-8a4d-1d158ce5acaa?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/d92e3721-b9f4-480d-8a4d-1d158ce5acaa?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/d92e3721-b9f4-480d-8a4d-1d158ce5acaa?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/23374)
Author
Owner

@DavideDelbianco commented on GitHub (Aug 4, 2025):

I have created a minimal reproducible bug workflow

Image

bug.ym.txt

@DavideDelbianco commented on GitHub (Aug 4, 2025): I have created a minimal reproducible bug workflow ![Image](https://github.com/user-attachments/assets/198fc326-1676-4ffd-9dcd-9a5927cbaf38) [bug.ym.txt](https://github.com/user-attachments/files/21581862/bug.ym.txt)
Author
Owner

@dosubot[bot] commented on GitHub (Sep 5, 2025):

Hi, @DavideDelbianco. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported duplicated and misassigned trace entries in workflows with iteration nodes on Dify v1.7.1 (self-hosted Docker).
  • The issue affected both parallel execution and iteration handling due to how trace events were aggregated and shared variable pools.
  • This was a known bug I confirmed and has been addressed in versions released after March 2025.
  • Major refactors and fixes (e.g., PR #14855, #22581) resolved the problem.
  • The recommended solution is to upgrade to a newer version, as no workaround exists for v1.7.1.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of Dify; if so, feel free to comment to keep the discussion open.
  • Otherwise, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Sep 5, 2025): Hi, @DavideDelbianco. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported duplicated and misassigned trace entries in workflows with iteration nodes on Dify v1.7.1 (self-hosted Docker). - The issue affected both parallel execution and iteration handling due to how trace events were aggregated and shared variable pools. - This was a known bug I confirmed and has been addressed in versions released after March 2025. - Major refactors and fixes (e.g., PR #14855, #22581) resolved the problem. - The recommended solution is to upgrade to a newer version, as no workaround exists for v1.7.1. **Next Steps:** - Please confirm if this issue is still relevant with the latest version of Dify; if so, feel free to comment to keep the discussion open. - Otherwise, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#15867