Skip to content

[4.2-dev] fix(plan): skip empty predicate deduction traversals - #31512

Merged
XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
ck89119:issue-31502-4.2-dev
Oct 28, 2026
Merged

XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
ck89119:issue-31502-4.2-dev

Conversation

@ck89119

@ck89119 ck89119 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #31502.

What this PR does / why we need it:

Minimally backport the non-empty predicate-deduction guards from main commit 5d6f921345 (#26927). Skip the extra child traversal when no predicates were deduced, while preserving normal pushdown and non-empty deduction. No UPDATE alias, DEDUP, cancellation, or other changes from that PR are included.

Add deterministic regression coverage for both chain directions and all six affected JOIN types, non-empty deduction semantics, and an eight-table PREPARE through the real planner entry point. The unpatched eight-table INNER chain performs 509 visits for 15 nodes; the guarded version performs 15. Independently reverting any of the four guards is caught by the regression.

Validation on this target branch (Go 1.26.4, macOS arm64, branch-local native libraries):

  • New regressions fail on unpatched production code for the expected visit-count assertion; non-empty deduction and PREPARE controls pass.
  • Focused regression and related pushdown tests pass.
  • Full pkg/sql/plan tests, go vet, and incremental golangci-lint 2.6.2 pass.
  • All eight added executable production lines are covered (100%).

This addresses empty-deduction traversal amplification, not a general planning-memory budget or a proof of linear planning cost for every SQL shape. No changes to main are included.

@mergify
mergify Bot requested a review from XuPeng-SH October 28, 2026 04:06
@mergify mergify Bot added kind/bug Something isn't working kind/test-ci labels Oct 28, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 28, 2026
@ck89119
ck89119 marked this pull request as ready for review October 28, 2026 04:19
@ck89119
ck89119 requested a review from aunjgr as a code owner October 28, 2026 04:19
@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 →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed 71f28c2 against 4.2-dev 86a45d3. No blocking code findings.

The four guards match the existing main fix, preserve the normal child traversal and nonempty deduction paths, and add no state or execution mechanism. Production net +8 lines and test +165 lines are justified by the targeted regression coverage; no documentation/proof artifacts were added.

Independent local validation (Go 1.26.4, macOS arm64, branch-built native libraries):

  • Focused planner selection: 48 top-level tests passed. Running the new 8-table regression against exact base production code fails as expected: 509 visits versus 15 on head.
  • Same real PREPARE/BuildPlan entry, 16-table INNER chain with first-table filter, base/head/base: approximately 93ms / 138.5 MiB allocated on base versus 0.33ms / 0.59 MiB on head. Single-table allocation controls are unchanged; longer LEFT-chain controls show no stable regression. This measures planning, not query execution.
  • Actual 3-CN SQL: 17 scenarios, each direct and PREPARE/EXECUTE, passed, covering duplicates, NULLs, outer/semi/anti joins, scalar subquery, CTE/UNION/LIMIT and invalid-PREPARE recovery.

Reused the exact-head successful CI UT/race and SCA runs. CI is still red: pessimistic BVT first fails ddl_atomicity.sql:123 with retry for CN rolling restart, causing subsequent DDL failures and blocking coverage aggregation. I did not reproduce that CI incident on base, so this approval does not assert it is proven unrelated or waive CI.

Scope is appropriately limited to empty-deduction amplification on 4.2-dev; it is not a general planner memory-budget guarantee.

@XuPeng-SH

XuPeng-SH commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 71f28c21fc9b417c18f9f7f9dc9da410ec3d0fb0

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

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: 71f28c21fc9b417c18f9f7f9dc9da410ec3d0fb0

Assessment: approve

The complete two-file change removes empty deduction traversals while preserving ordinary child traversal and nonempty predicates. Regression coverage is appropriate. No actionable defects remain; later successful CI supersedes the earlier red-CI status note.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

Validation:

  • Reused exact-head reports covering focused/full planner tests, baseline regression controls, comparative performance measurements, and 17 direct/PREPARE SQL scenarios on three CNs.

  • Frozen CI records successful UT, SCA, BVT, coverage and required-gate checks.

  • Local source, patch, formatting and discussion-coverage audit passed; source unchanged. Receipt/log correlation: /home/xupeng/.local/state/mo-bot/jobs/1cad8cf223a493e3f2d26a8e/attempt-1/validation-receipt-index.json.

Limitations:

  • No new Go tests were run. Reused execution reports remain attributed evidence; their raw logs were not supplied.

  • This fixes empty-deduction amplification, not general planner memory bounds. The production SQL remains unknown.

This branch was previously deployed

1 inactive deployment
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 kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants