node executes multiple times in parallel branch #15189

Closed
opened 2026-02-21 19:20:36 -05:00 by yindo · 3 comments
Owner

Originally created by @Madiao on GitHub (Jul 8, 2025).

Originally assigned to: @Nov1c444 on GitHub.

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.5

Cloud or Self Hosted

Cloud

Steps to reproduce

similar promble as https://github.com/langgenius/dify/issues/20356

a node cannot have multiple incoming edges from parallel branches and be expected to run only once.

for eg:

node[代码执行4]has two incoming edges in parallel branches, it will execute twice

Image

this does not run like other workflow engine, so I treate this as a bug.

I try to fix this bug, by add finish count.

1) when a node finish in graphEngine._run(), increase the execution times of next_node.

Image Image
  1. before start run node in graphEngine._run(), if the number of pre-node has been executed is greater than the in-degree of node, then execute; otherwise, break and exit the current thread.
Image Image

my final execute: the node[代码执行4] only execute once.

Image

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @Madiao on GitHub (Jul 8, 2025). Originally assigned to: @Nov1c444 on GitHub. ### Self Checks - [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 (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.5 ### Cloud or Self Hosted Cloud ### Steps to reproduce similar promble as https://github.com/langgenius/dify/issues/20356 a node cannot have multiple incoming edges from parallel branches and be expected to run only once. for eg: node[代码执行4]has two incoming edges in parallel branches, it will execute twice <img width="3648" height="1446" alt="Image" src="https://github.com/user-attachments/assets/04789b77-4e15-4a2d-acc7-8134a87fa052" /> this does not run like other workflow engine, so I treate this as a bug. I try to fix this bug, by add finish count. 1) when a node finish in graphEngine._run(), increase the execution times of next_node. <img width="1063" height="302" alt="Image" src="https://github.com/user-attachments/assets/516b9ee3-8e84-43a8-ab33-905db35a7baa" /> <img width="1484" height="781" alt="Image" src="https://github.com/user-attachments/assets/4d649082-acfc-4efa-88e6-37f27b6eb525" /> 2) before start run node in graphEngine._run(), if the number of pre-node has been executed is greater than the in-degree of node, then execute; otherwise, break and exit the current thread. <img width="1274" height="243" alt="Image" src="https://github.com/user-attachments/assets/6389aaab-6396-4e82-819c-fa3362dd8561" /> <img width="1275" height="730" alt="Image" src="https://github.com/user-attachments/assets/241f2b66-7e69-4805-b034-1558617d7a09" /> my final execute: the node[代码执行4] only execute once. <img width="3655" height="1345" alt="Image" src="https://github.com/user-attachments/assets/09ee48f7-96bd-4222-a316-347a19d689cb" /> ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug🌊 feat:workflow labels 2026-02-21 19:20:36 -05:00
yindo closed this issue 2026-02-21 19:20:36 -05:00
Author
Owner

@Madiao commented on GitHub (Jul 9, 2025):

In the iteration node, a branch will be executed concurrently multiple times, so relying solely on the dimensions of parallel and node is not enough. Therefore, an index parameter needs to be added at the beginning of the iteration, and parallel_index_node is used as the key. Hence, the following changes have been made.

  1. in IterationNode._run: add index param to _run_single_iter_parallel to _run_single_iter_parallel to graph_engine.run.index represents the round of iteration.
    Image
Image
  1. When recording and check the pre execution count, the generated key is {parallel_id}-{index}
Image Image
@Madiao commented on GitHub (Jul 9, 2025): In the iteration node, a branch will be executed concurrently multiple times, so relying solely on the dimensions of parallel and node is not enough. Therefore, an index parameter needs to be added at the beginning of the iteration, and parallel_index_node is used as the key. Hence, the following changes have been made. 1. in IterationNode._run: add index param to _run_single_iter_parallel to _run_single_iter_parallel to graph_engine.run.index represents the round of iteration. <img width="803" height="464" alt="Image" src="https://github.com/user-attachments/assets/9a7d919b-efde-4ca7-81e4-a4997e954505" /> <img width="857" height="563" alt="Image" src="https://github.com/user-attachments/assets/bdf17c31-980e-4da8-abf4-d7cd5fcdb0e5" /> 2. When recording and check the pre execution count, the generated key is {parallel_id}-{index} <img width="794" height="446" alt="Image" src="https://github.com/user-attachments/assets/7bdc9458-a0ee-4fc2-a75d-c0dc39c7d815" /> <img width="774" height="442" alt="Image" src="https://github.com/user-attachments/assets/8c644b9a-d0b3-49b1-b83a-4e586230e92e" />
Author
Owner

@chenyi-666 commented on GitHub (Jul 11, 2025):

I have a similar problem here:
Just modify one line in the process to control the problem of repeated execution or non-repeated execution

Image Image
@chenyi-666 commented on GitHub (Jul 11, 2025): I have a similar problem here: Just modify one line in the process to control the problem of repeated execution or non-repeated execution <img width="1920" height="716" alt="Image" src="https://github.com/user-attachments/assets/e6b07b02-e151-4af1-b997-e0148c4bedf1" /> <img width="1895" height="868" alt="Image" src="https://github.com/user-attachments/assets/49c11343-e8f0-41d4-b26c-9f104a78f1de" />
Author
Owner

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

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

Issue Summary:

  • You reported a bug in version 1.5 where nodes with multiple incoming edges from parallel branches executed multiple times.
  • You proposed a fix using an index parameter and a composite key {parallel_id}-{index} to ensure single execution after all predecessors finish.
  • Another user, chenyi-666, shared a similar issue and suggested a one-line modification to control repeated execution.
  • The issue was resolved by implementing your proposed fix, improving execution tracking in parallel workflows.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of Dify by commenting here.
  • If no further updates are provided, I will automatically close this issue in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 28, 2025): Hi, @Madiao. 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 a bug in version 1.5 where nodes with multiple incoming edges from parallel branches executed multiple times. - You proposed a fix using an index parameter and a composite key {parallel_id}-{index} to ensure single execution after all predecessors finish. - Another user, chenyi-666, shared a similar issue and suggested a one-line modification to control repeated execution. - The issue was resolved by implementing your proposed fix, improving execution tracking in parallel workflows. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of Dify by commenting here. - If no further updates are provided, I will automatically close this issue 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#15189