Repository navigation
fix(plan): preserve guarded prepared integer range access - #29612
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed c464380f793af447f56ec6e6376462504e3155aa against current main 21f711a7b852238394417e547282e14dce8660d9, including every changed hunk, callers and failure/cache paths. No subagents were used.
No new blocking code findings. The design and correctness of this bounded repair meet the code-review bar. Signed admission has one owner; BETWEEN publishes both bounds atomically; complete original guards survive consumer-local lowering; failed guards retain the original semantic path and last safe cache. Superseded DML guard wiring is removed. No parallel cache/state machine/execution path was added.
Independent current-head QA passed: 195 prepared executions across TINYINT/SMALLINT/INT, target boundaries and signed 64-bit extremes, BETWEEN/NOT BETWEEN, either literal bound, scalar comparisons, NULL-safe equality and recovery. Expected IDs were calculated independently in Go. The complete prepared numeric/temporal public integration suite also passed; terminal package result: 16.129s. Existing owning-package/cache evidence remains valid for unchanged functions; public validation also exercises the merged frontend source-classification changes.
Implementation +105 net lines, tests +192, documentation 0. The tests reuse existing fixtures and exercise distinct result, physical-path, warning and cache contracts.
Performance acceptance for #29606 remains open. Restored index/storage pruning and the catastrophic-path improvement are established. Contended GOOD/fixed rounds have opposing results (+59.49% and -22.65%), and fixed sampled CPU/query remains higher; neither aggregate +5.80% nor overlapping ranges proves stable historical parity or zero overhead. Keep Refs #29606 and retain the full-nightly/GOOD criterion. CI is still pending, not passed.
No actionable review threads or issue comments were outstanding at this head; the only PR comment is the Qodo service-paused notice. This COMMENT records the review because the authenticated account is also the PR author and cannot self-approve.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Additional adversarial QA: black-box and white-box
Reviewed head: c464380f793af447f56ec6e6376462504e3155aa. Head freshly verified unchanged. This supplements the previous review; no production or tracked test files were modified.
Black-box: independent result oracle
TestQA29612ProjectionAndDML passed using the existing embedded-cluster fixture and real MySQL prepared-statement protocol. Package terminal result: PASS, 10.533s.
35 additional prepared executions test adjacent consumers rather than repeating only the reported BETWEEN workload:
- IN/NOT IN projection: signed tinyint endpoints, duplicates, out-of-domain parameters, int64 extrema, mixed NULL and all NULL. Each prepared handle transitions safe -> unsafe -> NULL -> safe. All six rows, including a NULL column, are checked against independently computed Go three-valued logic.
- UPDATE comparison: the same prepared handle transitions through safe, overflow, int64 extrema, NULL and safe again. After each execution, all persisted counters are checked against independently accumulated expected values. Unsafe parameters must not wrap and update unrelated rows.
- FORCE/IGNORE INDEX are semantic controls for projection, not evidence that projection selected index access.
These supplement the previous 195 independently checked range executions and exact-head public prepared numeric/temporal suite. The new diagnostic test is external and mounted via Go overlay; it is not proposed as additional production test bulk.
White-box: owner and fallback contracts
Eight focused tests passed, with nonempty selection and terminal success:
- Frontend:
TestPreparedSignedNarrowingCacheGuard,TestPreparedBinaryIntegerCastDiagnosticProofBoundary,TestPreparedBinaryIntegerSerialDiagnosticProofBoundary(package 3.410s). - Planner:
TestPreparedSignedKeyGuardPreservesOtherDependencies,TestPreparedIntegerConsumerLoweringProvenance,TestPreparedIntegerBetweenAtomicAdmission,TestPreparedIntegerAdmissionRejectsUnsupportedDomains,TestPreparedWideIntegerComparisonKeepsColumn(package 2.461s).
The challenged invariants are both-bound atomic admission, retained original wide-source guards, preservation of other value dependencies, rejection of unsupported provenance/domain proofs, safe cache reuse and unsafe fallback without poisoning later safe executions. Binding, per-execution admission and plan/compile publication remain owned by existing components; the patch does not introduce another cache or state machine.
Decision and limits
No additional reproducible correctness blocker was found in these challenges. No evidence of wraparound writes, NULL result corruption, partial BETWEEN admission or guard escape was observed. This is a bounded no-new-blocker conclusion, not proof that every prepared-expression shape is optimized.
Unsigned, floating-point, decimal, text, explicit/derived expressions and DML BETWEEN/IN are not all covered by the new fast-path optimization. Their continued conservative handling is not itself a regression; do not claim the entire related performance family is solved.
Historical GOOD performance parity remains unproved: prior contended GAAG rounds disagree (+59.49%, -22.65%; aggregate +5.80%), and measured fixed CPU/query is higher. Restored pruning and substantial improvement over the broken base do not establish stable GOOD parity or close #29606's full performance acceptance. CI still has in-progress jobs; no CI-green claim is made.
This self-authored COMMENT records QA evidence and is not independent GitHub APPROVE.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of head 261665d8d57d44fd2411750893eb8c85d2abc987 against base/merge-base 21f711a7b852238394417e547282e14dce8660d9. No subagents used; no source changes.
Conclusion: no blocking code finding. This bounded repair meets the code-review bar; historical GOOD/full-nightly performance acceptance is still open.
Design and complete change map
All seven changed files/hunks and the affected binding -> diagnostic proof -> cache publication/reuse paths were reviewed.
- Planner binding (R2 SQL semantics / R3 hot path): one existing signed-integer admission owner serves comparison, IN and SELECT BETWEEN. BETWEEN publishes only after both bounds succeed; rejected attempts remove only their own tentative guards and retain value dependency. Consumer-local lowering does not mutate source bindings or sibling occurrences. Complete original wide-source guards survive optimization. The redundant DML guard wiring was removed.
- Frontend proof/cache consumer (R2 protocol / R3 cached execution): current decoded integer values are range-checked only after packet type, sign, position and long-data checks. Explicit casts, untrusted provenance and unsupported domains retain normal probing. Unsafe executions rebind without overwriting the last safe cache; compilation failure, replacement and statement close retain the existing cleanup owners. No new cache, state machine, storage gate bypass, lock, goroutine or execution path.
- Tests (R2 public contract): existing fixtures are reused. Eight distinguishing rows cover result sets, physical access, warnings and safe/unsafe/category/recovery sequences. Typed tests separately verify immutable guards, atomic rollback, source provenance and Plan/Compile identity. These are distinct oracles rather than duplicated result assertions. Current net increment: production +105, tests +194, documentation 0.
This is a bounded bug fix, not a new subsystem. Remaining mixed-domain/conservative branches are necessary semantic alternatives, not redundant compatibility machinery. No persisted/wire format changes; mixed-version rollout is outside this review's requested scope.
Evidence audit and QA challenge
The only delta since the previous reviewed head c464380f793af447f56ec6e6376462504e3155aa is test cleanup: immediate Rows.Close defer and per-warning-case subtests with immediate Stmt.Close defer. Result, path and warning oracles are retained. Production and the independent diagnostic tests are unchanged, so their evidence is reused, not described as newly executed:
- 195 public prepared executions across TINYINT/SMALLINT/INT, exact/out-of-domain and int64 limits, BETWEEN/NOT BETWEEN, literal bounds, scalar comparison, NULL-safe equality and recovery; independent Go expected IDs. Public suite plus QA terminal PASS: 16.129s.
- 35 adjacent public executions for IN/NOT IN projection and UPDATE, checking independent three-valued results and all persisted counters through safe -> unsafe -> NULL -> safe transitions. Terminal PASS: 10.533s.
- Eight focused frontend/planner tests: full original guards, both-bound atomic admission, other dependencies, excluded provenance, safe cache identity and unsafe recovery. Terminal package PASS: frontend 3.410s, planner 2.461s.
- Cleanup revision's full TestPreparedNumericTemporalContracts: terminal PASS 14.745s; scoped SCA: 0 issues.
- Freshly verified current-head CI run 37214726958, attempt 2 is SUCCESS: required CI, Linux UT, arm64 SCA, both enabled BVT jobs and coverage pass. CodeQL and Connector/J checks also pass. Disabled/skipped jobs are not counted as executed evidence.
- Current range diff --check passes. Review worktree remains clean.
Performance and prior comments
Restored range/index/storage pruning and improvement over the broken base are supported. However, the two contended GOOD/fixed rounds disagree (+59.49% and -22.65%); sampled fixed CPU/query is higher. Neither aggregate +5.80% nor the 15.769us cached-admission benchmark proves stable historical parity or zero overhead. Keep Refs #29606: that issue remains open for full performance acceptance. No new measurements were produced by this review.
There are no inline review comments or review threads, and no actionable unresolved PR conversation comments. The earlier SCA cleanup finding is fixed; the earlier reviews' pending-CI statement is now superseded by current-head success. The performance limitation is deliberately not marked resolved.
Submitted as COMMENT because the authenticated account is the PR author; this is not a GitHub APPROVE or an independent human approval.
What type of PR is this?
Which issue(s) this PR fixes:
Refs #29606
What this PR does / why we need it:
The real sysbench random_ranges client sends BIGINT parameters for INT columns. Prepared binding promoted the column or lowered BETWEEN into OR-connected AND pairs, losing usable index ranges. Conservative diagnostic classification then prevented storage pruning. Ordinary bindings could also be marked value-dependent by a discarded dynamic bound-order check.
Share the existing guarded signed-integer admission across comparisons, IN and BETWEEN. Admit a closed range atomically, retain immutable full semantic cast guards for every EXECUTE, and use the existing index/storage range path and type-keyed Plan/Compile cache. Trusted decoded binary integer consumers perform one transport conversion; unsafe or unsupported values retain the existing semantic path. Only static bounds need the existing BETWEEN order-folding check. No storage diagnostic gate is relaxed and no cache, state machine or execution path is added.
Validation:
The change adds 105 net production lines and 192 net test lines across seven existing files; it reuses the existing integration fixture. Design and full implementation review use gpt-6-astra / xhigh. Local evidence is macOS arm64 with matching native-artifact provenance; CI and full nightly-scale validation remain pending.
Interleaved local performance results (all eight retained):
Aggregate QPS is 8,967.47 fixed versus 8,475.72 GOOD. Compiler activity was recorded during every client window; opposing round outcomes prevent the aggregate +5.80% from establishing stable equivalence. Sampled server CPU/query was 494–536µs fixed versus 406–484µs GOOD. These whole-revision comparisons do not isolate the repair's incremental cost. Historical GOOD and full-nightly performance acceptance remain open in #29606; this PR does not claim zero overhead.
The latest unfixed base replay reached 387.72 QPS. The fixed replay retains ten serialized
prefix_betweenindex ranges and storage pruning. A representative final profile reduces the incident's dominant row-filtering hotspot to 1.30% sampled cumulative CPU. The cached 20-bound admission benchmark passes at 15.769µs/op, preserving Plan/Compile identity on every iteration (40 semantic/transport candidates). This is complete admission cost, not pure guard cost. Client p95 reporting is invalid and is not used as latency evidence.Final gpt-6-astra / xhigh review approves this bounded repair for delivery with the performance qualification above. No storage safety gate was removed; genuine warning/error and unsupported-domain behavior remain protected.