Skip to content

[Bug]: Data Branch DAG construction recursively fails on a cyclic parent relation #26083

Closed

Description

@Ariznawlll

Description

databranchutils.NewDAG recursively calculates every node depth without tracking nodes already on the current parent walk. A cyclic parent relation such as 1 -> 2 -> 1 therefore recurses until the Go runtime terminates the process.

The snapshot-reclaim DAG already detects and stops cyclic parent walks, but the LCA-oriented DataBranchDAG does not apply the same guard while being built from mo_branch_metadata.

Tested on main commit 2eb7f523e5a10f352d3e258183ed8440510388de.

Reproduction

Run NewDAG with:

rows := []DataBranchMetadata{
    {TableID: 1, PTableID: 2},
    {TableID: 2, PTableID: 1},
}
NewDAG(rows)

A focused test executes the call in an isolated child process with a bounded Go stack. The child exits with status 2 in 3 consecutive runs.

Actual result

NewDAG never completes normally. calculateDepth(1) calls calculateDepth(2), which calls calculateDepth(1) again until recursive stack exhaustion terminates the child process.

Expected result

NewDAG should detect a node already present on the current depth-calculation path and either reject the cyclic metadata or build a safe bounded representation. Constructing the DAG must not terminate the process.

Code path

pkg/frontend/databranchutils/branch_dag.go:

  • NewDAG
  • DataBranchDAG.calculateDepth

PathFromAncestor and BranchReclaimDag already contain bounded or visited-set walks that can serve as consistency references.

Activity

  1. added this to the MO-202607 milestone on Jul 23, 2026
  2. added
    kind/bug
    on Jul 23, 2026
  3. added theissue type on Jul 23, 2026
  4. VioletQwQ-0 commented on Jul 27, 2026

    @VioletQwQ-0
    Collaborator

    Resolved by #26139, merged into main at 2026-07-24T13:22:26Z. DAG construction is now bounded for cycles and deep chains, detaches only cycle members, and preserves valid descendant edges. Focused and race tests passed, and exhaustive verification covered all 126,125 functional parent graphs with 1-6 nodes. Closing this narrow crash bug as complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions