Repository navigation
fix: preserve composite index access for joins - #32832
Conversation
Allow VALUES-driven joins to use bounded composite-index prefixes while preserving complete-key priority and exact runtime-filter requirements. Gate forced-join reorientation on constructible bounded access so generic FORCE INDEX fallback retains cardinality-selected build/probe orientation. Add focused planner and distributed SQL regressions for bounded access, fallback orientation, residual semantics, and metadata-error atomicity. Related to matrixorigin#32460.
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
|
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: 6a2d5034ffc7fe362a88d9b781dc919a50ac0a55
Assessment: approve
Shared candidate discovery and existing exact runtime-filter machinery provide a coherent fix. The statement-local marker preserves forced-index fallback after reorientation. No actionable correctness or design defects remain.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Reviewed the complete seven-file delta, baseline admission rules, runtime-filter consumers, physical-planning order, hint fallback, metadata errors and test oracles. Saved review-plan.md and complete discussion-assessment.json.
-
Source/format audit passed: checks/1794881734479106937-2.json matches review-source-audit.log. Verified frozen inputs, clean source, patch/blob indexes, formatting, discussion coverage and native fingerprints. Two canonical mo-tester fixture trailing spaces remain.
-
Independent fixture oracle passed: checks/1794881498661882011-2.json matches fixture-oracle.log. SQLite evaluation verifies all four populated result tables and scalar UNION equivalence; this is not MatrixOne execution.
-
Reused completed UT, SCA, shared-build and multi-CN BVT successes in the frozen head's CI rollup. Author-reported focused/full planner tests and preceding service validation remain attributed evidence.
Limitations:
-
Local planner validation timed out during dependency downloads before tests ran: checks/1794881717738530256-2.json, exit 124, planner-focused.log. This provides no runtime result.
-
No local MatrixOne service BVT or production performance benchmark was run. Individual CI logs were unavailable; newer pending duplicate runs were not counted as passes.
🚫 Left the queue · pull request dequeued11 min in the queue, with no time running CI. So far
Reason Pull request #32832 has been dequeued Mergify failed to merge the pull request. GitHub can't merge the pull request after 10 minutes of retrying.
To get back in the queue
Tick the box to put this pull request back in the merge queue (same as
3 merge conditions met
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
Which issue(s) this PR fixes:
Related to #32460.
What this PR does / why we need it:
Root causes
VALUESjoin supplies the valid contiguous leadinguser_id/run_idprefix ofidx_control(user_id, run_id, event_type, event_idx), so it received no bounded index-join candidate and scanned the base table despiteFORCE INDEX.applyIndicesForJoinsreturned through generic hinted-index backfill before bounded composite-prefix admission. The resultingidx_controlscan had nouser_id/run_idruntime-filter probe.FORCE INDEXaccess remained but cardinality-selected orientation was lost, potentially making the large fact input the hash-build side.Changes
ONexpressions and uses placeholder tags so rejection has no planner side effects.VALUESlookup, build-side forced access, serialized two-keyMatchPrefixbounds, non-leading and partial-unique rejection, complete-key priority and fallback, one-million-versus-ten-row cardinality orientation, primary hints, and metadata-error atomicity.UNION ALLequivalence, residual and range predicates, duplicate/NULL/unmatched keys,IGNORE INDEX, and teardown.Issue-to-test proof for #32460
TestForceIndexJoinUsesLeadingCompositePrefixfailed on unchanged base7fcd9bdff8433d72983f0399fd5c10dcab91a00abecauseidx_controlwas absent. It now requires the explicit index scan, retained filtered base scan, matching build/probe tags,MatchPrefix,RUNTIME_FILTER_KEY_SERIAL_FULL_V1, two varchar probe components, and a two-argumentserial_fullbuild expression.TestForceIndexJoinUsesLeadingCompositePrefixFromBuildSidefailed before the build-side repair with zero runtime-filter probes. It now proves that the forced build-side form receives the same bounded access.TestForceIndexJoinGenericFallbackPreservesCardinalityBuildSideand the strengthenedTestForceIndexJoinBuildSideRetainsGenericFallbackfailed on the unchanged orientation candidate. After the gate, the same commands pass: the one-million-row input stays on probe, the ten-row input stays physical child 1/hash build, genericidx_controlaccess remains, and non-leading equality has no prefix probe.pkg/sql/planpackage passes.MatchPrefixand two-componentserial_fullplan lines and verified populated rows(0,11),(1,11),(2,7), residual counts, boundaries, duplicate/NULL/unmatched keys,UNION ALL, andIGNORE INDEX. Two normal mo-tester comparisons each passed 14/14. The SQL/result fixture hashes are unchanged in this revision; current orientation behavior is covered by the focused and package planner tests.Validation
Original-base proof (expected exit 1: no
idx_controlscan):.agents/skills/mo-dev/scripts/mo-cgo-test -o /tmp/issue-32460-main-go/plan-baseline.test -v -count=1 -timeout=180s -run '^TestForceIndexJoinUsesLeadingCompositePrefix$' ./pkg/sql/planBuild-side pre-repair proof (expected exit 1: zero runtime-filter probes):
.agents/skills/mo-dev/scripts/mo-cgo-test -o /tmp/issue-32460-main-review-go/plan-buildside.test -v -count=1 -timeout=180s -run '^TestForceIndexJoinUsesLeadingCompositePrefixFromBuildSide$' ./pkg/sql/planOrientation proof (exit 1 before the gate on both probe-side assertions; the identical command exited 0 after the gate):
.agents/skills/mo-dev/scripts/mo-cgo-test -o /tmp/issue-32460-main-review2-go/plan-cardinality.test -v -count=1 -timeout=180s -run '^(TestForceIndexJoinGenericFallbackPreservesCardinalityBuildSide|TestForceIndexJoinBuildSideRetainsGenericFallback)$' ./pkg/sql/planFinal focused proof (exit 0; all eleven top-level tests and subtests passed, package 2.095s):
.agents/skills/mo-dev/scripts/mo-cgo-test -o /tmp/issue-32460-main-review2-go/plan-cardinality.test -v -count=1 -timeout=180s -run '^(TestForceIndexJoinUsesLeadingCompositePrefix|TestForceIndexJoinUsesLeadingCompositePrefixFromBuildSide|TestForceIndexJoinBuildSideRetainsGenericFallback|TestForceIndexJoinGenericFallbackPreservesCardinalityBuildSide|TestIndexJoinCompositePrefixSafetyBoundaries|TestIndexJoinPrefersCompleteKeyOverPartialPrefix|TestNormalizeForcedJoinProbeSideSkipsPrimary|TestForceIndexForJoinReturnsMetadataErrorsAtomically|TestRightForceIndexForJoinRollsBackSwapOnMetadataError|TestNormalizeForcedJoinProbeSidePreservesOrientationOnMetadataError|TestNormalizedForceIndexJoinReturnsFallbackMetadataErrorAtomically)$' ./pkg/sql/planComplete planner package (exit 0;
ok github.com/matrixorigin/matrixone/pkg/sql/plan 162.211s):Vet and incremental lint (both exit 0; vet empty, lint 0 issues):
Supporting service build on the preceding revision (exit 0; only duplicate-library linker warnings):
Supporting distributed SQL proof on the preceding revision.
genrsgenerated the inspected result; two isolatedrunconfigurations each reported total 14, success 14, failed 0, ignored 0, abnormal 0:gofmtreports no files requiring formatting. The committed diff check reports only the two canonical mo-tester trailing spaces onValues Scan "*VALUES*"result lines; both normal comparisons accepted those generated results.Residual risks
mo-servicebuild were not rerun after the final orientation-only planner revision. Current-revision proof is the focused and complete planner package plus vet/lint; broader distributed optimizer suites and other CI checks remain for CI.