Repository navigation
fix(plan): preserve forced index access and safe TopValue on 4.2 - #32675
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
|
This pull request is merged. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 80378068d61d0c16d21fd84191418136c1ce7138
Assessment: approve
The fix reuses existing filter and JOIN planners; its pass-local memo and delegation flag preserve shared-scan column ownership. No actionable correctness or design findings remain after planner and public SQL validation.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Read the complete six-file delta, closing issue #32665 and both discussion entries; saved the plan, closure record and discussion ledger.
-
Go 1.26.6: 40 focused and 1,797 package-short root tests passed, including all 13 added tests. Three subtests were skipped.
-
Owning pkg/sql/plan build and vet passed; native prerequisites were built from fingerprinted current inputs.
-
One-CN MySQL probe passed 13 FORCE/IGNORE comparisons, two EXPLAIN checks and four prepared bindings including NULL. Earlier harness setup failures and matching source snapshots remain retained separately.
-
Receipt, source and discussion audit passed; see review-evidence-audit.json and retained logs. Source checkout remained unchanged.
Limitations:
-
CI was still in progress in the supplied snapshot. Author-reported race, broader mo-tester and benchmark runs lack retained execution receipts.
-
Local public-SQL coverage used one embedded CN.
8037806 to
33d4dd8
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 33d4dd86cd3a50ba530c55da163d7bed5e3a3cea
Assessment: approve
The forced-access and NULL-safe TopValue changes coherently reuse existing planner and reader owners. No actionable correctness or design findings remain. Reported slower forced plans remain accepted performance limits.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Reviewed all 16 changed files, affected owners/consumers, four linked issues and all five discussion entries.
-
Isolation preflight passed. Matching native prerequisites were built from 170 fingerprinted frozen inputs using repository Makefiles.
-
All 37 focused tests passed across plan, Top, readutil and disttae: focused-tests.log; checks/1794571747986818497-2.json.
-
Owning packages passed 2,341 root tests: plan/readutil/disttae with -short, Top without -short. Three subtests skipped; details in test-results.json. Receipts: checks/1794572163637377269-2.json and checks/1794572153665692250-2.json.
-
Build, vet, formatting and diff checks passed. Final source, discussion, native-provenance and receipt audit passed: validation-audit.json; checks/1794572251121808990-2.json. Source remained unchanged.
Limitations:
-
Local validation used Linux/amd64 and Go 1.26.6. Integration paths excluded by -short were not run locally.
-
Race, public SQL, two-CN and performance validation were assessed as author-reported evidence without supplied raw artifacts or local reproduction.
-
The supplied performance report retains material regressions for some forced-index workloads; approval does not establish a universal speedup or zero regression.
|
mo-bot review · Commit: Review discussion changed before publication; a fresh contextual review is queued. |
Retraction: my earlier "FORCE index access is dropped" reports were caused by a broken test setup, not by this PRI need to correct my two previous comments on this PR. Their central claim was wrong, and I apologize for the noise. Root cause of my errorMy local machine had other leftover MatrixOne instances running. On repeated runs my This also explains the "BVT is green locally but my repro disagrees" contradiction: there was no real contradiction. Corrected verification (this time with instance identity proven)To eliminate the mix-up I ran this head on an isolated port range (logservice/raft/gossip moved off 32000-32002, frontend on its own port), confirmed clean startup from the launch log, and added temporary planner tracing (reverted afterwards, no source changes kept):
So the forced index access this PR is meant to preserve does work here; FORCE and AUTO agree on the motivating case. What I withdraw
Lesson / for the recordThe only real defect here was in my harness: it never verified that the instance answering SQL was the binary I had just built. Once instance identity was enforced (isolated ports + startup-log check + planner tracing), this PR behaved as described. Sorry again to the author and reviewers for the incorrect report and the time spent on it. |
|
mo-bot review · Commit: New discussion was assessed; the previous review remains unchanged. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: d5fb9ef53b28c28251ce0891f6ec52f39bcc545b
Assessment: approve
No actionable findings remain. The 41-file change preserves the reviewed fixes and coherently reuses existing index, statistics, Top and reader owners. The base compression merge adds no material contract conflict; the later wrong-server QA reports are withdrawn.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Verified the complete PR patch and all 41 changed files are byte-identical to full review 5914259191; assessed all 35 discussion entries and both closing issues.
-
Inspected the three base-only objectio changes and their reader/format/ownership interaction. LZ4 and extent contracts remain intact; base test oracles were inspected, not executed.
-
Reused the supplied prior review's matching build/vet, focused/normal/race/stress, static and logical-oracle coverage with its original scope and limitations.
-
Bounded static audit passed; receipt checks/1794808234910258149-2.json reconciles with source-audit.log, source-audit.json, change-map.json and the complete discussion ledger. Source remains clean.
Limitations:
-
No fresh product, race, SQL, distributed or performance execution was run after the merge; prior raw execution logs were not supplied in this job.
-
The prior review retains three baseline Parquet assertion failures, four skipped cases and 15 legacy molint diagnostics; these are not clean passes.
-
Reported two-CN runs selected ForceOneCN. Explained slower forced paths and unproven larger-scale performance remain accepted limits.
|
mo-bot review · Commit: Review discussion changed before publication; a fresh contextual review is queued. |
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
Reviewed the complete PR against origin/4.2-dev at head 5c1ccca, including forced-index planning, prefix predicates, ordered TopValue execution, reader and filter behavior, metadata compatibility, and tests. The head update merges the updated base; after separating that base commit, the PR-owned diff is byte-identical to the previously reviewed patch. All prior findings and refreshed PR discussions were rechecked, and no actionable findings remain. The focused go test -mod=readonly -v ./pkg/container/types test passed, and the complete diff passed git diff --check. Broader native-dependent tests were not run because this checkout lacks the required prebuilt CGO headers and libraries; this is a test coverage limitation.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 5c1cccaa874fe84a5dc416b43c3a26bde8efbdba
Assessment: approve
No actionable findings remain. The unchanged implementation reuses existing planner, statistics, Top and reader owners. Resolved selectivity and withdrawn QA concerns remain closed; the new review adds no unresolved issue. Revision-11 performance limits remain accepted.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Qualified the complete 41-file patch and reviewed merge interactions against the completed same-head review; assessed all 39 discussion entries.
-
Reconciled retained receipts and logs for source integrity, formatting of 36 Go files and the independent logical oracle covering 91 result sets across 227 statements.
-
Current source/evidence audit passed: checks/1794821828836588936-2.json. Details are retained in validation-audit.json and validation-manifest.json.
-
Reused supplied source-scoped build/vet, normal/race/stress and public-SQL reports with their original limitations.
Limitations:
-
No fresh MatrixOne runtime, race, distributed SQL or performance execution was run. The newly reported types-only pass and historical runtime reports lack supplied raw logs; skips, baseline failures and analyzer diagnostics are not current clean passes.
-
Substantive hosted CI remains pending. The logical oracle does not validate physical pruning or distributed execution; reported two-CN runs selected ForceOneCN. Explained slower forced paths and larger-scale performance remain accepted limits.
Reuse existing bounded filter, covering and ordering access owners and remove the ORDER-to-JOIN delegation state. Preselect profitable private fixed-size LIMIT/OFFSET keys with the canonical Project/Top operators, retaining complete SQL predicates and final ordering. Avoid repeated predicates and PK projection values; preserve shared-scan ownership and canonical limit validation. Keep semantic SQL oracles while removing ignored plan snapshots. Validate planner normal/race and repeated one-/two-CN SQL; retain quantified performance limits in the evidence record.
Publish complete index predicates before calculating scan costs and retain native planner scheduling. Reuse pruned-reader scheduling for ordered scans without changing worker or terminal counts. Reduce scalar decoding, key allocation, varlena sorting and final Top sorting costs. Keep dense IN range search in persisted blocks; preserve per-key MVCC lookups. Bound unsorted integer membership and implicit-PK map construction. Retain SQL predicates, final ordering, NULL safety and exact result checks. Performance acceptance remains open; this commit does not waive that gate.
Backport the test-only synchronization from main (a605eb6). Receiving the response does not imply that the publisher has completed its deferred slot release.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 55be2a45778efdae7c1ee1f06b93a2c67a935ddd
Assessment: approve
No actionable findings remain. The change reuses existing index, statistics, Top and reader owners; its bounded proofs preserve predicates, ordering and ownership. The selectivity finding is resolved, withdrawn QA claims remain closed, and revision-11 performance tradeoffs remain accepted.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed all 42 changed files, both closing issues and all 41 discussion entries; saved the complete discussion ledger.
-
Source integrity, formatting, index-plugin checks and receipt/log reconciliation passed; see validation-audit.json and checks/1794835219735458878-2.json.
-
Isolated Go 1.26.6 types suite passed 176 root tests and 618 subtests; TestDecimal128Float was skipped.
-
Independent logical oracle matched 91 ordered result sets across 227 SQL/result statement pairs.
-
Qualified supplied historical validation against 40 identical changed files and traced the remaining base-integration changes.
Limitations:
-
Frozen CI contains 6 successes, 9 skipped, 4 pending and 2 neutral checks.
-
Native-dependent owning suites, live SQL, race and performance checks were not rerun locally; historical raw runtime logs were unavailable.
-
Reported two-CN runs selected ForceOneCN. Slower forced-access paths and unproven larger-scale performance remain accepted limits.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #32665
Fixes #32690 on 4.2-dev
What this PR does / why we need it:
Preserve a useful forced regular-index access when ORDER BY still needs a separate sort. A bounded index-side Top is admitted only when the access is private, all required predicates and sort keys can be evaluated safely, the order includes the primary key, and known statistics justify it. The base SQL predicates and final Top remain authoritative; an unproven residual prevents a static reader limit.
Keep nullable TopValue pruning fail-open when nullability, physical type, scale or block metadata cannot prove exclusion. Reuse existing scan-reader and shuffle ownership, exact IN membership, vector and Top execution paths while avoiding redundant reader, decoding and sorting work.
Publish complete index predicates before deriving scan statistics. A synthesized prefix range and its decoded SQL residual must not count the same condition twice. Scan statistics derive an estimation-only view from the actual encoded access and decoded rechecks, recognizing every proven static integer prefix component or exact IN set. The executable expressions keep their own selectivities for filter ordering and block estimates. Unproven cases remain conservative.
The pre-existing 4.2 DECIMAL comparison and pruning defect exposed by this PR's CI was fixed independently by #32767, now merged into 4.2-dev as 6dd9f9d. This branch is rebased on that merge. The original reported DECIMAL query has also been verified on main.
The logtail CI failure is addressed by backporting the test-only read-barrier synchronization already merged on main in #30998. Receiving the response can precede the publisher's deferred release; the test now waits to reacquire the sole admission slot and still detects a leak.
The CI follow-up updates the expected block-filter plan and fixes the test comparator's tie key for two IVF JOIN queries. Their original SQL is unchanged; actual plans confirm that the default query still uses IVF and the forced exact query retains its exact path.
Validation
Current fix on 57: full
pkg/sql/plannormal tests, the focused selectivity suite under-race, andstatic-check-selectedforpkg/sql/planexited successfully. Golangci-lint reported zero issues; molint also printed fivecheckrecoverdiagnostics in code unchanged from the previous PR head. On the previous PR head, the new multi-prefix regression failed with 18,939.39 estimated rows; after the fix the index scan and inner Top input cost both estimate 75,757.58. The test also covers open ranges, a residual, low selectivity, repeated refresh, and mismatching/NULL/sourced bounds.Executed FORCE-versus-IGNORE SQL on one- and two-CN embedded instances, before and after flushing both the table and its index. Range, offset, descending order, residual, NULL, empty, IN and composite-primary-key cases matched; after flush
EXPLAINconfirmed the index-side Top and both rechecks. The two-CN instance selectedForceOneCN, so this does not claim multi-CN parallel execution.Logtail test-only follow-up before the current selectivity fix: the exact failing logtail test passed 100 race-detector repetitions; its full owning package passed normal and race tests, go list/build/vet, and static-check-selected.
On the clean 4.2-dev baseline, controlled publisher scheduling demonstrated that the response can arrive before the deferred slot release. A temporary leak-injection overlay made the corrected test fail as expected; no production mutation was retained.
Against 4.2-dev at 296402f and fix: preserve DECIMAL comparison domains on 4.2 #32767: actual SQL on one and two CNs, before and after flush, including FORCE/AUTO/IGNORE, composite DECIMAL bounds, NULL, outer joins and overflow. The original FORCE query was verified to use its index.
A DECIMAL composite-index query with a non-exact range was verified to apply its decoded residual below the internal Top; both FORCE and IGNORE returned the same expected rows. After rebasing, actual CHAR index and JOIN runtime-filter probes and the one/two-CN DECIMAL and Top/vector plan probes all passed.
Before the current selectivity fix, relevant two-CN BVT: 1,451/1,451 statements passed, with no failures or skips. This includes all three previously failing fix: preserve DECIMAL comparison domains on 4.2 #32767 files as well as force_index_order, explain_index and vector_ivf_equi_join.
Before the current selectivity fix, the complete pkg/sql/plan and pkg/sql/plan/function suites passed both normally and with race detection. Earlier focused tests for the affected packages and selectivity proof boundaries also passed.
Before the current selectivity fix, vet and the project static-check-selected target (molint and golangci-lint) passed for all 12 Go packages then changed relative to 4.2-dev.
BuildPlan tests with explicit 1M-row statistical fixtures verify the range and IN estimates are counted once and remain correct after a leaf statistics refresh. Tests also cover NULL, parameter sources, malformed/different vectors, changed bindings and truncated keys.
Performance
For this selectivity fix, an ABBA planner microbenchmark on 57 compared the previous PR head and the fix using the same four FORCE query/fixture shapes. The two-run mean changed from -3.2% to +2.8% across cases; the multi-prefix Top case changed from 289.4 to 290.5 microseconds per planning iteration. This includes fixture construction and parsing and is not a SQL execution latency benchmark.
On host 57, a direct ABBA comparison used the prior #32675 head baefd9b and the then-candidate d4671cf (before the later prerequisite CI follow-up), one million flushed/analyzed rows in concentrated and scattered layouts, eight SQL cases, 100 warmups and 300 measured executions per case per process. All 16 comparisons used identical plans and result digests; mean process medians changed between -4.6% and +5.1%.
A separate comparison made before the prerequisite CI follow-up against the then-#32767 baseline showed that some FORCE queries are 14%–47% slower because the old code ignored FORCE and used a table scan, while the candidate performs the requested index scan and backfill. Other workloads improved; for example the concentrated IN/Top case improved about 75%. The identical-plan AUTO case was faster in the concentrated layout and essentially unchanged in the scattered layout. These numbers describe the tested workloads, not every possible query.
A separate pre-existing 4.2 issue remains for reused untyped prepared parameters whose DECIMAL scale changes; it also reproduces without an index and is outside this PR.