Repository navigation
fix(sql): honor empty scan decisions before constructing readers - #29650
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.
Deep review of commit 94a8e0598ccc2a1a50cceaf5961ba4aebe2c2424 against ffe8362614b8bde8fe0fa249ee472edc87bf256a: no blocking findings; code meets the approval bar. GitHub CI is still running.
The correction belongs in the existing scan-admission owner. It honors DROP/FALSE before storage reader construction, while preserving pipeline execution, JOIN finalization, cancellation and cleanup. Exact-empty proof remains the producer's responsibility; missing payload, spill, capacity fallback and build failure keep their existing PASS/error behavior. No duplicate validation, cache or execution path was added.
I reviewed every changed hunk and the producer → scan → join/cleanup/reuse closure. The old lifecycle tests now reach genuine range/reader setup and retain their original close, ordering and cancellation assertions. Implementation is +17/-17; tests are +212/-39; no documentation delta. The test increment covers distinct owner and public contracts and reuses the existing cluster fixture.
Additional independent two-CN QA in this review passed (normal, -count=1, exit 0):
- Real RIGHT SINGLE + runtime filter with two all-NULL build keys: zero probe scan rows/bytes, both preserved NULL result rows retained.
- Binary prepared SELECT reuse across NULL → matching → NULL.
- FALSE aggregate identities, empty INNER and scalar comparison, preserved RIGHT/ANTI results.
- Multi-row scalar subquery still errors, and the session executes the next statement successfully.
Verified and reused the exact-tree normal/race, SCA, old-code negative control, cross-CN target-lock and performance evidence. The performance conclusion is removal of the N-scaled validation scan; the local hot-data medians are not a production throughput promise.
There are currently no inline review comments or code-related discussion items left to address; the Qodo comment is a service notice. Linux UT/SCA/coverage and BVT checks remain pending.
This review is recorded as COMMENT because the authenticated account is also the PR author; it does not represent a GitHub APPROVE state.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29197
Related to #29196.
What this PR does / why we need it:
An update-only
INSERT ... ON DUPLICATE KEY UPDATEwith a secondary UNIQUE key resolved its target selectively, but still scanned the entire hidden UNIQUE index during final INSERT-only validation. At 100,000 rows that stage read 100,000 rows / 400,000 bytes on ordinary, KEY-partitioned and RANGE-partitioned tables.HashBuild already publishes a valid DROP when the conditional validation keys are all NULL.
Scope.buildReadersconsumed DROP but merely skipped range collection, then constructed ordinary storage readers anyway. Nil relation data intentionally permits an in-memory scan, so this did not stop reading.Return the existing empty readers before ordinary reader construction for DROP and constant-FALSE decisions, releasing unused assigned range metadata. Reuse the same helper for existing vector and star-count empty readers. Nonempty validation, optional PASS fallback, target resolution, locking and DEDUP finalization retain their existing owners.
Reader lifecycle tests previously used a dummy FALSE predicate while expecting storage readers to execute. Replace that shortcut with shared real range-collection setup, keeping reader ownership, ordering, close and cancellation assertions.
Validation
pkg/sql/compilesuite: normal and race,-count=1.mo_locks(), commit its holder, then verify both increments on the single original row.gpt-6.1-sol / xhighdesign and complete-change review: no unresolved material blockers.Performance
Same hot-data, single-client harness: 100 / 10,000 / 100,000 rows, three warmups and 20 direct/prepared samples per shape. All nine UNIQUE validation scans now read zero rows / zero bytes. At 100,000 rows, prepared medians were:
These are local latency observations, not a production throughput guarantee. Legitimate nonempty validation and PASS fallback can still scan; this change does not claim to resolve every full-scan case in #29196.
Implementation: +17/-17 lines. Tests: +212/-39 lines. Documentation: no tracked changes. CI is pending publication.