Skip to content

[Bug] Fix multi-member recursive CTE frontier handling - #32828

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/32799-recursive-cte-rounds
Nov 17, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/32799-recursive-cte-rounds

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes

Fixes #32799
Fixes #32612

What this PR does / why we need it

Recursive members must forward their round markers even when their local frontier is empty. Only the shared recursive sink can decide that the global post-DISTINCT frontier is empty and terminate the CTE. This prevents a member from stopping early while MergeCTE still waits for its marker, fixing both the cross-generation hang and the missing later-member row.

Recursive joins containing a recursive scan bypass shuffle exchange: it can forward a round marker before buffered bucket tails, breaking feedback-round ordering. Other joins retain the existing shuffle planning.

Validation:

  • Full race suites: pkg/sql/colexec/dispatch, pkg/sql/plan.
  • Deterministic embedded-cluster cancellation and prepared-statement reuse regression, including race.
  • Distributed BVT through mo-tester on 2 CNs: 11/11 cases passed twice, including both issue repros, multi-member DISTINCT convergence, and recursive table join.
  • go vet; molint (0 issues); incremental golangci-lint.

Resource tradeoff: recursive-scan joins use the existing broadcast build path, which may consume more build-side memory and does not use shuffle-only spill/retry for very large joins. This change makes no performance-improvement claim.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@XuPeng-SH

XuPeng-SH commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 74545ab8a1e547bc251d1d1ea95028b89cb7c684

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 74545ab8a1e547bc251d1d1ea95028b89cb7c684

Assessment: approve

No actionable defects found. Termination correctly belongs to the shared recursive sink, and existing broadcast execution preserves frontier ordering without adding another mechanism.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • Six focused regressions and five owning/consumer packages passed normally.

  • Full dispatch and planner race suites passed; dispatch regressions passed 100 repetitions each, and cancellation/prepared reuse passed two repetitions.

  • Native SQL probe passed all 11 maintained statements on both CN coordinators, asserting six exact result sets each. The base-dispatch negative control failed as expected.

  • Frozen source, discussion coverage, native provenance, commands, receipts and retained logs were verified in validation-ledger.json.

Limitations:

  • Recursive joins accept higher broadcast build memory usage and lack shuffle-only spill/retry; no performance improvement was claimed or benchmarked.

  • The initial planner race run exceeded its 240-second budget; the unchanged package passed with a 600-second bound.

This branch was successfully deployed

No deployments
ci — a05ccabc Deployed Nov 17, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/L Denotes a PR that changes [500,999] lines

Projects

None yet

2 participants