Repository navigation
fix: use bounded composite unique index key sets - #32830
Conversation
Add exact-key access for complete composite unique indexes when all other key parts have equality predicates and one part has a finite IN. Preserve residual filtering, backfill, index-only plans, hint safety, statistics ordering, resource bounds, retry handling, and fallback. Related to matrixorigin#32410.
Exercise all supported literal variants against the serial encoding size contract, and reject malformed, dynamic, unsupported, and over-budget inputs. This closes the changed-code coverage gap reported on PR matrixorigin#32830 without changing production behavior.
|
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: bb3ee9b9132463de9e894b76fbd18f7fac08ab0b
Assessment: approve
The bounded key-set path preserves complete unique-key semantics and existing residual/backfill behavior. It reuses the serial codec and access builders; per-scan reservations and revalidation justify the added helper by bounding optional materialization and fallback work.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Reviewed all five changed files, linked #32410 and its comments, and all three discussion entries; retained the change map, closure analysis and complete discussion ledger.
-
Static audit passed with receipt checks/1794877304765424400-2.json and retained stdout/stderr: clean pinned head, patch matches frozen range, diff-check and gofmt passed.
-
Reused the frozen PR's reported complete planner package PASS (159.218s), encoder equivalence tests, related planner checks and 56/56 real-SQL BVT after checking their selection and independent result/work oracles.
-
Frozen CI snapshot records Coverage and CI Required SUCCESS; pending/skipped checks were not counted as passes. Static-audit.json preserves the check snapshot and source hashes.
Limitations:
-
No local Go/native/SQL execution was performed; local_validation contains no retained execution artifacts. Author-run results are attributed evidence, not independently reproduced runs.
-
The reported RED control uses b815a4c rather than the assigned merge-base. Baseline source independently establishes the missing key-set path; operator row counts demonstrate bounded work, not latency or throughput.
|
The attempt-2 |
|
@Mergifyio queue |
🚫 Left the queue · pull request dequeued2 h 54 min in the queue, with no time running CI. So far
Reason Pull request #32830 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
To get back in the queue
Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
|
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: 56ee1cf3ac5db52e2b38988f24a41ae028d35d3f
Assessment: approve
The complete composite-unique IN path preserves residuals, hints, NULL/dynamic fallback and prefix-index safety. It reuses canonical serial encoders and existing access builders; per-scan reservations and declined-candidate tracking justify the added local state by bounding encoding and retries. Complete source, tests and discussion review found no actionable defect.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Preflight passed. Native prerequisites were built through repository Makefiles in the diagnostic directory; source-audit.json verifies all 196 native input hashes, artifact provenance and the clean frozen head.
-
Focused normal Go run passed all 16 selected roots, including all 14 added roots, with no skips/failures; focused-normal.jsonl and its check receipt are reconciled in validation-review.json.
-
Full ./pkg/sql/plan normal Go run passed: 5,076 test roots, 49.798s test execution; two existing unrelated subtests skipped. Every added root executed. See planner-package.jsonl and validation-review.json.
-
Public MySQL SQL-integration probe passed twice in one process using the existing single-CN fixture and a diagnostic Go overlay: all 56 original regression statements per iteration, 12 original plan/work regexes and 23 independently derived result sets, prepared reuse and database teardown. See public-normal.jsonl, public-overlay.json and validation-review.json.
-
Frozen current-head evidence records successful UT, static analysis, coverage and compose BVT checks. All eight discussion keys are reconciled in discussion-assessment.json; changed Go files pass gofmt and the frozen delta passes git diff --check.
Limitations:
-
The public diagnostic probe verifies SQL results and plan/work assertions, not mo-tester's result metadata/format rendering. Local execution used one CN; multi-CN BVT success is supplied CI evidence.
-
External reusable CI workflow bodies and raw old-head author runs were not supplied. Their detailed selection/performance claims are not treated as local proof; no latency or throughput improvement is claimed.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #32410.
What this PR does / why we need it:
Root cause
A complete composite unique secondary index had ordinary equality/range access, but no key-set candidate for equality-bound key parts plus one finite
INdimension. The planner therefore could not lower the predicate to exact serialized keys or cap candidate work by the finite key count. A less selective secondary index or table scan could win and read the entire run history. Forced-index fallback and unknown-statistics candidate ordering also lacked the guards needed to expose bounded access safely.This adapts merged PR #32577 and its required composite key-set support from #32567 to
main.Changes
KeySetIndexConditioncandidate matching, cost/cardinality caps, index-only and base-row backfill integration, forced-hint and declared-prefix safety, unknown-statistics ranking, bounded reservation/retry handling, and cancellation propagation.NULLconstantIN; reject dynamic values, multiple set dimensions, malformed metadata, and declared prefixes.NULLvalues, residual filters, index-only/backfill plans, hints, competing indexes, missing statistics, incomplete keys, prefixes, resource limits, retries, revalidation, and cancellation.NULL, unsupported types, string byte boundaries, and planning-budget rejection.Issue-to-test proof
b815a4cfb5b2, the focused trailing-INplanner case selectedidx_cinstead ofuk_abc; the same case passes after this change with an exact unique-key set. Equality and fallback controls retained their expected behavior.uq_user_run_keyfor ordinary and forced trailing-INqueries. Base-table and unique-indexinputRows=3 outputRows=3bound work by the three requested keys instead of scanning 5,000 history rows. The query returnsevent_idx1, 2, and 3 with residual filtering, noncovered projection, backfill, and ordering preserved.NULLretain SQL three-valued semantics. Declared prefixes, incomplete/nontrailing key shapes, mixed hints, competing indexes, and missing-statistics controls return the intended rows.event_idx1 through 7.Validation
.agents/skills/mo-dev/scripts/mo-cgo-test -o /tmp/issue-32410-main-plan-baseline.test -v -count=1 -timeout=10m -run '^(TestCompositeUniqueTrailingInPointAccess|TestCompositeUniqueTrailingInRejectsPrefixLengths|TestCompositeUniqueForcedOrderRejectsPrefixPointAccess|TestCompositeUniqueForcedOrderRejectsCompetingPrefixAccess|TestCompositeUniqueMissingStatsPreferCompleteEquality)$' ./pkg/sql/plan— intended bounded-access failures on the clean base..agents/skills/mo-dev/scripts/mo-cgo-test -o /tmp/issue-32410-main-fast-path-review.test -v -count=1 -timeout=10m -run '^(TestFastExactKeySetMatchesSerialFolding|TestCompositeUniqueKeySetCardinalityAndFastPath)$' ./pkg/sql/plan— PASS in 2.026s..agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s -run '^(TestIndexKeySetLiteralBoundVariants|TestIndexKeySetLiteralBoundRejectsInvalidInputs)$' -coverprofile=/Users/ghs-mo/MOWorkSpace/tmp/issue-fix/issue-fix-loop/state/artifacts/issue-32410/pr-event-focused-literal-tests.cover.out ./pkg/sql/plan— PASS; both tests and all 34 subtests passed.index_key_set.go, raising changed-code coverage from 293/412 (71.12%) to a projected 315/412 (76.46%), above the strict 75% gate. Production files are unchanged between the profiles. Exact-head CI run 43970538694 subsequently passed Coverage and CI Required onbb3ee9b9132463de9e894b76fbd18f7fac08ab0b.-run:.agents/skills/mo-dev/scripts/mo-cgo-test -o /tmp/issue-32410-main-plan-ci-fix.test -v -count=1 -timeout=30m ./pkg/sql/plan— PASS in 159.218s..agents/skills/mo-dev/scripts/mo-cgo-test -o /tmp/issue-32410-main-plan-related.test -v -count=1 -timeout=10m -run '^(TestRegularIndexSelector.*|TestEncodedIndex.*|TestIndexHint.*|TestForceIndex.*|TestScopedForceIndex.*|TestApplyIndicesForFilters.*|TestApplyExtraFiltersOnIndex.*|TestResolveRegularIndexBackfillResidualAccess|TestRangeBackfill.*|TestRegularIndexOnly.*|TestReplaceEqualCondition.*|TestReplaceNonEqualCondition.*)$' ./pkg/sql/plan— PASS in 2.420s; also included in the final unfiltered package run.java -Xms1024M -Xmx1024M -cp /Users/ghs-mo/MOWorkSpace/mo-tester:/Users/ghs-mo/MOWorkSpace/mo-tester/lib/* -Dconf.yml=/Users/ghs-mo/MOWorkSpace/tmp/issue-fix/issue-fix-loop/state/artifacts/issue-32410/main-runtime/mo.yml -Drun.yml=/Users/ghs-mo/MOWorkSpace/tmp/issue-fix/issue-fix-loop/state/artifacts/issue-32410/main-runtime/run.yml io.mo.Tester method=run rate=100— 56/56 success, 0 failed, 0 abnormal after result generation and manual review.make -j8 build-with-prebuilt-native— PASS.go vet -mod=readonly ./pkg/sql/planwith the repository CGo environment — PASS.golangci-lint run -c .golangci.yml --new-from-rev b815a4cfb5b2eee24b620f7c078dab6f42b12537 ./pkg/sql/plan— 0 issues.gofmt, tracked/untracked whitespace, and delivery-scope checks passed.Residual risks and limits
NULL-containing inputs, multipleINdimensions, declared prefixes, malformed metadata, broad estimates, and resource-limit excess; these cases preserve semantics through ordinary fallback.EXPLAIN ANALYZErow counts establish bounded operator work for this fixture; they are not latency or throughput benchmarks.