Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Related to closed #25821 and #12212. This is a 4.1.6-hotfix follow-up, not a new report of the already-addressed main-branch work. PR #32085 is being narrowed to the UNION/outer-join CTAS failures from matrixflow #20285; MARK optimization is deliberately excluded.
Branch Name
4.1.6-hotfix
Commit ID
Base 77052f8d1f9e6833ff5e5b41ae2343b5bcf0d152; measured metadata-corrected source 04d4098d5ecb19827152bfe8104c7a102674ee13 (also the production source at fcf51e4d13864acdbbd986878aa802eeba50340c).
Other Environment Information
Isolated local single-CN MO; GOMAXPROCS=4, GOMEMLIMIT=4GiB. Persistent SQL connection, one warmup and three measured executions. No production replay.
Actual Behavior
Correct UNION nullability makes nullable NOT IN require MARK semantics. This release branch compiles MARK as LoopJoin, exposing quadratic probe/build work instead of the previously selected, but semantically unsound, ANTI path.
For equivalent no-actual-NULL data, baseline/corrected median SQL times were:
| Probe rows | Baseline | Corrected metadata |
|---|---|---|
| 3000 | 0.759 ms | 18.882 ms |
| 6000 | 0.890 ms | 70.680 ms |
Adding an actual NULL to the second UNION branch makes the correct result zero; baseline incorrectly returns N/2. Restoring incorrect NotNullable to regain ANTI speed is not a valid fix.
Expected Behavior
Provide an efficient NULL-aware membership path while retaining SQL three-valued semantics, empty/all-NULL build behavior, safe evaluation ordering, cancellation and bounded concurrent memory use. Keep unsupported predicates on the evaluator. Independently assess a minimal backport versus a branch-local implementation; do not automatically import shuffle/spill or broad main changes.
Steps to Reproduce
CREATE TABLE l(id INT NOT NULL);
CREATE TABLE r(id INT NOT NULL);
CREATE TABLE extra(d INT);
-- Seed l with 1..N, r with 1..N/2, extra with N+1 (N=3000 and 6000).
SELECT COUNT(*) FROM l
WHERE id NOT IN (SELECT id FROM r UNION ALL SELECT d FROM extra);
-- Compare EXPLAIN and timing, then separately add NULL to extra and assert zero.Use IN and a non-null constant second UNION branch as nearby controls. Timing is local evidence, not a production SLA.
Additional information
An unmerged experimental implementation remains in PR #32085 history through 53cdb1286a80d9b1025bbac885207fddc7807bc9; it is not a production-ready patch to cherry-pick. In particular, review #32085 (comment) found uncharged build encoding buffers. This was independently reproduced with 44 actual optional builders, 256 repeated 4KiB keys each, shared 64MiB MPool: charged 47,849,472 bytes + retained key buffers 54,788,096 bytes = 102,637,568 bytes, above the 67,108,864-byte cap. No OOM kill was observed.
Acceptance must cover both build and probe scratch with cap-enforced allocation/atomic reservation, shared-index ownership, budget/OOM fallback preserving RHS batches, unrelated-error propagation, cancellation, continuation, Reset/Free and deterministic concurrent consumers/builders. Non-null proofs do not prove eager evaluation cannot introduce an earlier error. Keep per-worker full RHS indexes and uncharged retained string buffers out of the final design. Any wire-format change needs its own explicit scope/review.
Activity
fix(plan): preserve CTAS output nullability on 4.1.6 hotfix (#32085)
fix(sql): bound shared MARK membership on 4.1.6-hotfix (#32315)
[4.1.6-hotfix] fix(plan): infer result nullability from explicit proo…
slyunnn commentedon Nov 12, 2026
Partially fixed — the original INT/UNION witness and supported bounded membership path pass; the related expression/DOUBLE release risk explicitly retained by #32519 remains unresolved.
Target:
4.1.6-hotfix@bf18d1090466825da1d1c67742491af5c1da2605, [4.1.6-hotfix] fix(plan): infer result nullability from explicit proofs (#32519), frozen from remote at test start. Built from clean source using Go1.26.4and matching freshly built native libraries. All three endpoints returnedgit_version()=bf18d10904.Topology: local macOS arm64,
2 CN / 1 TN / 1 Log service / Proxy. Proxy127.0.0.1:6001, CN1127.0.0.1:16001, CN2127.0.0.1:16002were connected and actually used for original and extended SQL through PyMySQL text protocol. Existing BVT used Java/JDBC with metadata comparison enabled. No result is projected ontomainor4.2-dev.Fixed scope. PR #32315, fix(sql): bound shared MARK membership on 4.1.6-hotfix, merge
54feca6423c2e2e24b57f58e66eaf951891607cc, is present together with #32461 and #32519. The original nullable UNION query returnsN/2without an actual RHS NULL and0after inserting NULL, atN=3,000/6,000on all three endpoints. Plans retain MARK rather than relying on an unsound ANTI shortcut. Warmed text-protocol medians were approximately0.84–1.00 ms/0.95–1.14 ms; actual MARK memory records show the bounded index. IN and non-NULL-constant controls passed.Resource and lifecycle evidence. The existing
mark_membership.sqlpassed48/48at each endpoint, with metadata comparison enabled, including empty/all-NULL RHS, duplicates, NULL probes, prepared generations and evaluator controls. Focused normal tests passed across planner/LoopJoin/message (34top-level tests); focused race tests passed across LoopJoin/message (32top-level tests), including shared consumers/builders, pool cap, allocation failures, unrelated errors, cancellation, continuation and Reset/Free.Real scale verification used
2,000,000RHS rows on every endpoint. One-probe hit/miss controls retained approximately7.63 MiBMARK memory;256misses produced correct global counts and approximately39.63 MiB, including the actual32 MiBindex. Plans exposed scandop=12; this is engine execution evidence, not MOTR case scheduling. The concurrent ownership/cap assertions are component/race evidence rather than a production concurrency claim.Remaining release gate. The merged #32519 description explicitly links the following expression/DOUBLE performance risk to this issue and requires resolution or an explicit release decision. Minimal reproduction:
Actual: correct counts
2,999/5,999, and0after division generates NULL. The evaluator remains MARK with warmed medians approximately105–107 ms/424–426 ms, about4×growth when input sizes double. Reproduced independently on Proxy/CN1/CN2, one warmup plus three measurements each. This confirms a retained performance limitation, not a new result-correctness failure.The accepted #32315 design intentionally keeps unsupported expression/type domains on the evaluator. Please resolve the performance gate or explicitly record the release decision accepting this domain boundary; this report does not demand unsafe eager expression evaluation or restoration of incorrect NOT NULL metadata. The original INT witness is fixed, but no complete release acceptance is asserted while that explicitly retained decision remains open. No duplicate bug was filed.
Large-data regression required: Yes, for the adaptive work and memory boundary; the real
2,000,000-row controls above completed locally. A TKE/production throughput or memory-soak claim is not made. The remaining quadratic expression witness requires only3,000/6,000rows to expose its scaling.Reused maintained BVT/UT coverage; no duplicate MOTR commit or PR was created. Shared fixture execution was serialized. An initial overlapping BVT/scale attempt produced a fixture lock conflict and is excluded; the clean serial scale run passed. No service source was modified. This issue remains open pending the release-gate resolution/decision.
ck89119 commentedon Nov 13, 2026
The design review accepts the current boundary: expression/DOUBLE cases remain on the evaluator without acceleration. Given the limited usage scope of
4.1.6-hotfix, there is no need to expand the optimization to this domain in this hotfix. We explicitly accept this performance limitation for the release.slyunnn commentedon Nov 13, 2026
Fixed within the accepted
4.1.6-hotfixscope, based on the completed regression above.Per the developer’s release decision, expression/DOUBLE cases intentionally remain on the evaluator, and their performance limitation is accepted for this hotfix. The pending release decision is resolved; this issue is closed as completed.
fix(plan): preserve grouping-extension CTAS semantics on 4.1.6-hotfix (…