-
-
Notifications
You must be signed in to change notification settings - Fork 23.3k
fix(runtime): resolve deadlock on converging conditional paths #5544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Previously, when conditional branches merged into a single node, execution would silently halt. The merging node would wait indefinitely for input from the "skipped" branch. This fix propagates the ignored status to downstream dependencies by injecting `null` inputs. This satisfies the waiting condition (`hasReceivedRequiredInputs`) and allows the flow to proceed using data from the active branch only.
Summary of ChangesHello @Domenic-MZS, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical deadlock issue in the runtime execution of graph-based systems, particularly in Directed Acyclic Graphs (DAGs) that utilize conditional branching. Previously, when a conditional path was skipped, any downstream node that converged from both the active and skipped paths would become stuck, waiting indefinitely for an input that would never arrive. The implemented solution modifies the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively resolves a deadlock issue in conditional graph paths by propagating a null signal down the skipped branches. The implementation is clear and directly addresses the problem described. I have one suggestion to improve the efficiency of finding downstream nodes, but overall this is a great fix.
This refactoring improves efficiency by using the graph object for a direct lookup of downstream nodes, instead of filtering the entire edges array in each loop iteration. This avoids an O(E) operation (where E is the number of edges) inside the loop, making the code cleaner and more performant, especially for larger graphs. Co-authored-by: @gemini-code-assist
|
Does not work when: A: If block A-------B----| Where After resuming the execution from B, C is not executed... |
|
ah I see the reason now, thanks for pointing out the Human In the Loop part as well |
fix(runtime): resolve deadlock on converging conditional paths
Fixes #5501
📝 The Deadlock Problem
The issue described by @Sohorev is a classic "deadlock" in graph-based systems, specifically in Directed Acyclic Graphs (DAGs) that incorporate conditional branching.
When there was a condition (IF/Condition Node) that split the flow into Path A and Path B, and then both paths later converged into a single Node C, the following occurred:
...
To avoid this, the
processNodeOutputsfunction was modified, so that when the system determines which nodes should be ignored (ignoreNodeIds), it also "notifies" the nodes depending on them (the descendant nodes) that the specific input would not arrive, so that they would stop waiting for it.This was achieved by simulating a
nullvalue to propagate within the ignored nodes to its dependents. This satisfied the dependency and allows the convergence node to execute using only the data from the active branch. (Ignore null value is already implemented so this works like a charm).TL;DR
Previously, when conditional branches merged into a single node, execution would silently halt. The merging node would wait indefinitely for input from the "skipped" branch.


This fix propagates the ignored status to downstream dependencies by injecting

nullinputs. This satisfies the waiting condition (hasReceivedRequiredInputs) and allows the flow to proceed using data from the active branch only.