fix: add depth guard to sync_node_execution to prevent unbounded recursion#3441
Open
falloficaruss wants to merge 1 commit into
Open
fix: add depth guard to sync_node_execution to prevent unbounded recursion#3441falloficaruss wants to merge 1 commit into
falloficaruss wants to merge 1 commit into
Conversation
- Add _depth and _max_depth parameters (default 50) to _sync_execution and sync_node_execution
- Raise FlyteAssertion when nesting exceeds limit instead of crashing with RecursionError
- Add unit tests verifying depth guard and regression safety
Fixes #7338
Signed-off-by: Abhishek Shinde <norizzabhii@gmail.com>
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.
Tracking issue
Closes flyteorg/flyte#7338
Why are the changes needed?
FlyteRemote.sync_node_executionrecursively syncs launched-LP executions and parent-node children with no depth limit. A workflow graph withdeeply nested launched LPs triggers
RecursionError, crashing the Python process. Everypyflyte run --remotecall against such an executionblows up.
What changes were proposed in this pull request?
_depthand_max_depthparameters to_sync_executionandsync_node_execution(default_max_depth=50)FlyteAssertionat entry when_depth > _max_depthinstead of overflowing the Python call stack_depth + 1: the per-node sync in_sync_execution, the launched-LP path, dynamic subworkflowchildren, static subworkflow children, and both branch-node child paths
How was this patch tested?
tests/flytekit/unit/remote/test_recursion_guard.pywith 4 tests:test_max_depth_raises_flyte_assertion— verifiesFlyteAssertionis raised when depth exceeds limittest_reasonable_depth_does_not_raise— verifies default depth allows normal operationtest_nested_under_default_limit— verifies nested calls under the limit succeedtest_sync_execution_depth_guard— verifies the guard on_sync_executionindependentlytests/flytekit/unit/remote/pass with no regressionsSetup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link