Repository navigation
Conversation
`LogicalPlanNode::try_into_logical_plan` recurses once per plan node but, unlike serialization (apache#24124), had no `recursive` stack-growth checkpoint, so a deeply nested plan could overflow the stack. Add the `recursive_protection` checkpoint to `try_into_logical_plan` and a stack safety test that round-trips a 2,000-deep plan on a 2 MiB thread. Closes apache#26737.
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.
Which issue does this PR close?
Rationale for this change
Deserializing a logical plan from protobuf recurses once per nesting level, through
LogicalPlanNode::try_into_logical_plan. Serialization already has arecursivestack-growth checkpoint (#23823 / #24124), but deserialization did not. In debug builds, where this function has a very large stack frame, a deeply nested plan could abort the process with a native stack overflow, even withrecursive_protectionenabled.What changes are included in this PR?
Adds
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]totry_into_logical_plan. Every plan-to-plan recursion goes through this function.What is the testing strategy for this PR?
Adds
deeply_nested_logical_plan_deserialization_uses_a_growable_stacktodatafusion/proto/tests/cases/stack_safety.rs. It converts a plan with 2,000 nestedSubqueryAliasnodes to proto and back on a 2 MiB thread stack.Are there any user-facing changes?
No API changes. With
recursive_protectionenabled, deeply nested logical plans now deserialize instead of overflowing the stack.This PR was prepared with AI assistance and reviewed by the author.