Skip to content

fix(sql): support bounded deep existential predicates - #28364

Merged
XuPeng-SH merged 9 commits into
matrixorigin:mainfrom
aptend:fix/deep-existential-28293
Sep 8, 2026
Merged

XuPeng-SH merged 9 commits into
matrixorigin:mainfrom
aptend:fix/deep-existential-28293

Conversation

@aptend

@aptend aptend commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #28293

What this PR does / why we need it:

Two-level existential filters whose innermost predicate references both its parent and grandparent currently fail during correlated-column pullup. This change admits a bounded set of WHERE EXISTS, NOT EXISTS and truth-only scalar IN predicates, including up to eight restricted innermost OR arms, and lowers them to SEMI/MARK joins without materializing the inner relation product. NULLs, empty inputs, outer duplicates and existing successful planning paths retain their semantics; unsupported shapes retain the existing rejection behavior.

Repeated non-PK RIGHT SEMI/ANTI hash matches skip groups already completed in the worker-local bitmap. Distributed broadcast also retires explicitly stopped receivers without truncating delivery to remaining local or remote consumers, while preserving real query and transport errors.

Validation before the main merge: full planner, dispatch and hashjoin packages; focused compile and race checks; 250/250 MySQL differential cases; 34/34 BVT statements twice; two-CN execution and cancellation/reuse twice. Merge validation is recorded in the linked report.

Performance checks cover duplicate keys, high NDV, skew, asymmetric relation sizes, natural two-CN execution and existing planner paths. Tested cases show no statistically supported latency regression above 5%; this is not a universal bound. The outer-gated ANTI shape uses about 5.2 MB more hash memory (7.1%) at 4.5 million build rows for its Boolean hash key.

See the design and validation report for scope, measurements and limitations.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the queued label Sep 8, 2026
@mergify

mergify Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-08 05:01 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-08 05:16 UTC · at 1c6c8408c21fb5b2db703c25f584053c910cebf7

This pull request spent 15 minutes 54 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

The pull request can't be updated

This pull request seems to come from a fork, and Mergify needs the author's permission to update its branch.
The author needs to enable "Allow edits from maintainers" on this pull request, or update the branch manually.

Failing checks:

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 67677d9 into matrixorigin:main Sep 8, 2026
20 of 21 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 8, 2026
XuPeng-SH pushed a commit that referenced this pull request Sep 14, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue #28378

## What this PR does / why we need it:

Add regression coverage for queued stream cancellation, shuffle receiver
retirement, and distributed IVF query cleanup. Production fixes are
already present through #28358, the relevant dispatch/remote pipeline
changes in #28364, and #28539; this PR changes tests only and does not
establish their individual causal contribution to the original TKE
incident.

- Observe serialized MORPC sequence numbers after a queued message is
canceled. The identical test compiles on the #28358 parent and fails
with expected sequence 2 versus actual 3.
- Cover first, middle, last, and consecutive shuffle receiver
retirement, checking both subsequent sends and one-time notification.
Exercise query/connection cancellation during real receiver credit
waiting through the CN handler, preserving the terminal error and
releasing lifecycle registration.
- Add a two-CN IVF test with 256 128-dimensional vectors. The
representative L2 case exercises eight concurrent sessions with one
simultaneous query per session; cosine, normalized L2, and raw-vector
IP/normalized-query retain their per-distance lifecycle and result
checks. The test covers exact full-probe comparison, approximate-result
validity, empty results, and subsequent queries. Test preparation
failure uses the actual phase runner, transaction rollback, worker exit,
and database cleanup. Preparation and query budgets are cumulative but
separate; cleanup gets its own context. SQL pre-cancellation is not
presented as proof of active remote cancellation. The fixture provides
16 vectors per IVF list on average; Vector Index Scan selects Multi-CN
without a 65,536-row threshold, so the 256-row fixture preserves the
lifecycle and result oracles while bounding the owning package's race
cost.
- Extend test/distributed/cases/vector/vector_ivf_multicn_search.sql and
.result with cosine, raw-vector IP/normalized-query, empty-result, and
follow-up checks. The GROUP_CONCAT metadata expectation uses the
existing server TEXT mapping and Connector/J 8.0.15 metadata; results
were not regenerated blindly.

Validation (final file contents include the follow-up assertion, SCA,
coverage-budget, fixture-size, and concurrency-budget fixes; exact head
323daee; upstream base
07b2596; product base
2a6fe7f):

- macOS arm64, Go 1.26.4, repository CGo wrapper, GOMAXPROCS=4, test
package parallelism 1.
- New mechanism tests: ordinary 100 iterations and race 20 iterations
passed. MORPC, dispatch, and compile packages passed ordinary/race
checks; unchanged evidence was reused.
- Follow-up P2 validation:
TestRemoteNotifyCancellationReleasesCreditWaitAndRegistration passed
ordinary 100 iterations and race 20 iterations after asserting that
connection cancellation closes proc.Ctx, records a non-nil
ErrStreamClosed cause, and preserves it through repeated terminal
cleanup.
- After the follow-up edit, the complete owning ./pkg/sql/compile
package passed once under the race detector; no race report was emitted.
- Exact prior-head fixture validation: GOWORK=off go test -mod=readonly
-count=1 -timeout=15m -run '^TestIssue28378IVFFlatRemoteLifecycle$'
./pkg/tests/issues passed in 14.855s; the same exact test with -race and
a 20m timeout passed in 34.817s. After the first fixture-size change,
the 1,024-row test passed ordinary in 16.675s and race in 33.739s; after
the final 256-row/one-iteration change, it passed ordinary in 16.591s
and race in 24.467s.
- The MORPC parent counterexample validates the sequence mechanism. The
IVF integration test is regression coverage, not a deterministic
reproduction of the historical incident.
- Reviewer P2 response: the fixture was reduced from 65,536 to 256 rows
and the concurrent repeat count from two to one in 323daee. XuPeng-SH
measured the prior 65,536-row test at 573.55s in the exclusive -p 1
-race UT stage on parent head 7944a5b; the focused runs above measure
the latest local fixture at 16.591s ordinary and 24.467s race. These are
different environments and modes, so the numbers are reported as bounded
before/after evidence rather than a CI performance claim. The exact-head
CI run below provides the Linux cost measurement.
- Exact current-head CI run 34756863153 for f7cb131 passed Ubuntu UT,
SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, and CI Required.
The subsequent exact-head run 34799486791 for 323daee passed on
attempt 2: Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic
BVT, Coverage, and CI Required are green. Its first attempt failed only
in the unrelated optools TestUTHeartbeatStopsCleanly with `WaitDelay
expired before I/O complete`; the failed Coverage chain passed on rerun
without code changes.
- Formal BVT: CN1 and CN2 JDBC entry points each passed 36/36
comparisons with full metadata checking. go vet, gofmt, and diff checks
passed.

Deployment evidence for the already-fixed product base, independently of
this new test commit:

- Old baseline run
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34352473993:
HNSW/L2/cosine/normalize errors were 0/1702/1266/588.
- Fixed-product run
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34464342049:
all four original million-vector SIFT128 cases completed with 100
terminals, five-minute measurements, and zero client errors. The five
data hashes match the failed baseline. Acceptance was checked from
artifact counters and error files, not only workflow success.

QA required: yes — distributed timing and deployed-workload acceptance.
Automated terminal coverage includes completed SQL assertions,
cancellation waiter exit, preserved terminal errors, registration
removal, and cleanup. QA should review the target release's inclusion of
the existing production fixes and the attached run evidence. First-error
query/stream/peer correlation and unique root-cause attribution remain
unavailable; this PR must not auto-close #28378.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8364)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#28293

## What this PR does / why we need it:

Two-level existential filters whose innermost predicate references both
its parent and grandparent currently fail during correlated-column
pullup. This change admits a bounded set of WHERE EXISTS, NOT EXISTS and
truth-only scalar IN predicates, including up to eight restricted
innermost OR arms, and lowers them to SEMI/MARK joins without
materializing the inner relation product. NULLs, empty inputs, outer
duplicates and existing successful planning paths retain their
semantics; unsupported shapes retain the existing rejection behavior.

Repeated non-PK RIGHT SEMI/ANTI hash matches skip groups already
completed in the worker-local bitmap. Distributed broadcast also retires
explicitly stopped receivers without truncating delivery to remaining
local or remote consumers, while preserving real query and transport
errors.

Validation before the main merge: full planner, dispatch and hashjoin
packages; focused compile and race checks; 250/250 MySQL differential
cases; 34/34 BVT statements twice; two-CN execution and
cancellation/reuse twice. Merge validation is recorded in the linked
report.

Performance checks cover duplicate keys, high NDV, skew, asymmetric
relation sizes, natural two-CN execution and existing planner paths.
Tested cases show no statistically supported latency regression above
5%; this is not a universal bound. The outer-gated ANTI shape uses about
5.2 MB more hash memory (7.1%) at 4.5 million build rows for its Boolean
hash key.

See the [design](docs/rfcs/20260907_deep_existential_decorrelation.md)
and [validation
report](docs/rfcs/20260907_deep_existential_validation.md) for scope,
measurements and limitations.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#28378

## What this PR does / why we need it:

Add regression coverage for queued stream cancellation, shuffle receiver
retirement, and distributed IVF query cleanup. Production fixes are
already present through matrixorigin#28358, the relevant dispatch/remote pipeline
changes in matrixorigin#28364, and matrixorigin#28539; this PR changes tests only and does not
establish their individual causal contribution to the original TKE
incident.

- Observe serialized MORPC sequence numbers after a queued message is
canceled. The identical test compiles on the matrixorigin#28358 parent and fails
with expected sequence 2 versus actual 3.
- Cover first, middle, last, and consecutive shuffle receiver
retirement, checking both subsequent sends and one-time notification.
Exercise query/connection cancellation during real receiver credit
waiting through the CN handler, preserving the terminal error and
releasing lifecycle registration.
- Add a two-CN IVF test with 256 128-dimensional vectors. The
representative L2 case exercises eight concurrent sessions with one
simultaneous query per session; cosine, normalized L2, and raw-vector
IP/normalized-query retain their per-distance lifecycle and result
checks. The test covers exact full-probe comparison, approximate-result
validity, empty results, and subsequent queries. Test preparation
failure uses the actual phase runner, transaction rollback, worker exit,
and database cleanup. Preparation and query budgets are cumulative but
separate; cleanup gets its own context. SQL pre-cancellation is not
presented as proof of active remote cancellation. The fixture provides
16 vectors per IVF list on average; Vector Index Scan selects Multi-CN
without a 65,536-row threshold, so the 256-row fixture preserves the
lifecycle and result oracles while bounding the owning package's race
cost.
- Extend test/distributed/cases/vector/vector_ivf_multicn_search.sql and
.result with cosine, raw-vector IP/normalized-query, empty-result, and
follow-up checks. The GROUP_CONCAT metadata expectation uses the
existing server TEXT mapping and Connector/J 8.0.15 metadata; results
were not regenerated blindly.

Validation (final file contents include the follow-up assertion, SCA,
coverage-budget, fixture-size, and concurrency-budget fixes; exact head
323daee; upstream base
07b2596; product base
2a6fe7f):

- macOS arm64, Go 1.26.4, repository CGo wrapper, GOMAXPROCS=4, test
package parallelism 1.
- New mechanism tests: ordinary 100 iterations and race 20 iterations
passed. MORPC, dispatch, and compile packages passed ordinary/race
checks; unchanged evidence was reused.
- Follow-up P2 validation:
TestRemoteNotifyCancellationReleasesCreditWaitAndRegistration passed
ordinary 100 iterations and race 20 iterations after asserting that
connection cancellation closes proc.Ctx, records a non-nil
ErrStreamClosed cause, and preserves it through repeated terminal
cleanup.
- After the follow-up edit, the complete owning ./pkg/sql/compile
package passed once under the race detector; no race report was emitted.
- Exact prior-head fixture validation: GOWORK=off go test -mod=readonly
-count=1 -timeout=15m -run '^TestIssue28378IVFFlatRemoteLifecycle$'
./pkg/tests/issues passed in 14.855s; the same exact test with -race and
a 20m timeout passed in 34.817s. After the first fixture-size change,
the 1,024-row test passed ordinary in 16.675s and race in 33.739s; after
the final 256-row/one-iteration change, it passed ordinary in 16.591s
and race in 24.467s.
- The MORPC parent counterexample validates the sequence mechanism. The
IVF integration test is regression coverage, not a deterministic
reproduction of the historical incident.
- Reviewer P2 response: the fixture was reduced from 65,536 to 256 rows
and the concurrent repeat count from two to one in 323daee. XuPeng-SH
measured the prior 65,536-row test at 573.55s in the exclusive -p 1
-race UT stage on parent head 7944a5b; the focused runs above measure
the latest local fixture at 16.591s ordinary and 24.467s race. These are
different environments and modes, so the numbers are reported as bounded
before/after evidence rather than a CI performance claim. The exact-head
CI run below provides the Linux cost measurement.
- Exact current-head CI run 34756863153 for f7cb131 passed Ubuntu UT,
SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, and CI Required.
The subsequent exact-head run 34799486791 for 323daee passed on
attempt 2: Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic
BVT, Coverage, and CI Required are green. Its first attempt failed only
in the unrelated optools TestUTHeartbeatStopsCleanly with `WaitDelay
expired before I/O complete`; the failed Coverage chain passed on rerun
without code changes.
- Formal BVT: CN1 and CN2 JDBC entry points each passed 36/36
comparisons with full metadata checking. go vet, gofmt, and diff checks
passed.

Deployment evidence for the already-fixed product base, independently of
this new test commit:

- Old baseline run
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34352473993:
HNSW/L2/cosine/normalize errors were 0/1702/1266/588.
- Fixed-product run
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34464342049:
all four original million-vector SIFT128 cases completed with 100
terminals, five-minute measurements, and zero client errors. The five
data hashes match the failed baseline. Acceptance was checked from
artifact counters and error files, not only workflow success.

QA required: yes — distributed timing and deployed-workload acceptance.
Automated terminal coverage includes completed SQL assertions,
cancellation waiter exit, preserved terminal errors, registration
removal, and cleanup. QA should review the target release's inclusion of
the existing production fixes and the attached run evidence. First-error
query/stream/peer correlation and unique root-cause attribution remain
unavailable; this PR must not auto-close matrixorigin#28378.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8364)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#28293

## What this PR does / why we need it:

Two-level existential filters whose innermost predicate references both
its parent and grandparent currently fail during correlated-column
pullup. This change admits a bounded set of WHERE EXISTS, NOT EXISTS and
truth-only scalar IN predicates, including up to eight restricted
innermost OR arms, and lowers them to SEMI/MARK joins without
materializing the inner relation product. NULLs, empty inputs, outer
duplicates and existing successful planning paths retain their
semantics; unsupported shapes retain the existing rejection behavior.

Repeated non-PK RIGHT SEMI/ANTI hash matches skip groups already
completed in the worker-local bitmap. Distributed broadcast also retires
explicitly stopped receivers without truncating delivery to remaining
local or remote consumers, while preserving real query and transport
errors.

Validation before the main merge: full planner, dispatch and hashjoin
packages; focused compile and race checks; 250/250 MySQL differential
cases; 34/34 BVT statements twice; two-CN execution and
cancellation/reuse twice. Merge validation is recorded in the linked
report.

Performance checks cover duplicate keys, high NDV, skew, asymmetric
relation sizes, natural two-CN execution and existing planner paths.
Tested cases show no statistically supported latency regression above
5%; this is not a universal bound. The outer-gated ANTI shape uses about
5.2 MB more hash memory (7.1%) at 4.5 million build rows for its Boolean
hash key.

See the [design](docs/rfcs/20260907_deep_existential_decorrelation.md)
and [validation
report](docs/rfcs/20260907_deep_existential_validation.md) for scope,
measurements and limitations.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#28378

## What this PR does / why we need it:

Add regression coverage for queued stream cancellation, shuffle receiver
retirement, and distributed IVF query cleanup. Production fixes are
already present through matrixorigin#28358, the relevant dispatch/remote pipeline
changes in matrixorigin#28364, and matrixorigin#28539; this PR changes tests only and does not
establish their individual causal contribution to the original TKE
incident.

- Observe serialized MORPC sequence numbers after a queued message is
canceled. The identical test compiles on the matrixorigin#28358 parent and fails
with expected sequence 2 versus actual 3.
- Cover first, middle, last, and consecutive shuffle receiver
retirement, checking both subsequent sends and one-time notification.
Exercise query/connection cancellation during real receiver credit
waiting through the CN handler, preserving the terminal error and
releasing lifecycle registration.
- Add a two-CN IVF test with 256 128-dimensional vectors. The
representative L2 case exercises eight concurrent sessions with one
simultaneous query per session; cosine, normalized L2, and raw-vector
IP/normalized-query retain their per-distance lifecycle and result
checks. The test covers exact full-probe comparison, approximate-result
validity, empty results, and subsequent queries. Test preparation
failure uses the actual phase runner, transaction rollback, worker exit,
and database cleanup. Preparation and query budgets are cumulative but
separate; cleanup gets its own context. SQL pre-cancellation is not
presented as proof of active remote cancellation. The fixture provides
16 vectors per IVF list on average; Vector Index Scan selects Multi-CN
without a 65,536-row threshold, so the 256-row fixture preserves the
lifecycle and result oracles while bounding the owning package's race
cost.
- Extend test/distributed/cases/vector/vector_ivf_multicn_search.sql and
.result with cosine, raw-vector IP/normalized-query, empty-result, and
follow-up checks. The GROUP_CONCAT metadata expectation uses the
existing server TEXT mapping and Connector/J 8.0.15 metadata; results
were not regenerated blindly.

Validation (final file contents include the follow-up assertion, SCA,
coverage-budget, fixture-size, and concurrency-budget fixes; exact head
323daee; upstream base
07b2596; product base
2a6fe7f):

- macOS arm64, Go 1.26.4, repository CGo wrapper, GOMAXPROCS=4, test
package parallelism 1.
- New mechanism tests: ordinary 100 iterations and race 20 iterations
passed. MORPC, dispatch, and compile packages passed ordinary/race
checks; unchanged evidence was reused.
- Follow-up P2 validation:
TestRemoteNotifyCancellationReleasesCreditWaitAndRegistration passed
ordinary 100 iterations and race 20 iterations after asserting that
connection cancellation closes proc.Ctx, records a non-nil
ErrStreamClosed cause, and preserves it through repeated terminal
cleanup.
- After the follow-up edit, the complete owning ./pkg/sql/compile
package passed once under the race detector; no race report was emitted.
- Exact prior-head fixture validation: GOWORK=off go test -mod=readonly
-count=1 -timeout=15m -run '^TestIssue28378IVFFlatRemoteLifecycle$'
./pkg/tests/issues passed in 14.855s; the same exact test with -race and
a 20m timeout passed in 34.817s. After the first fixture-size change,
the 1,024-row test passed ordinary in 16.675s and race in 33.739s; after
the final 256-row/one-iteration change, it passed ordinary in 16.591s
and race in 24.467s.
- The MORPC parent counterexample validates the sequence mechanism. The
IVF integration test is regression coverage, not a deterministic
reproduction of the historical incident.
- Reviewer P2 response: the fixture was reduced from 65,536 to 256 rows
and the concurrent repeat count from two to one in 323daee. XuPeng-SH
measured the prior 65,536-row test at 573.55s in the exclusive -p 1
-race UT stage on parent head 7944a5b; the focused runs above measure
the latest local fixture at 16.591s ordinary and 24.467s race. These are
different environments and modes, so the numbers are reported as bounded
before/after evidence rather than a CI performance claim. The exact-head
CI run below provides the Linux cost measurement.
- Exact current-head CI run 34756863153 for f7cb131 passed Ubuntu UT,
SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, and CI Required.
The subsequent exact-head run 34799486791 for 323daee passed on
attempt 2: Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic
BVT, Coverage, and CI Required are green. Its first attempt failed only
in the unrelated optools TestUTHeartbeatStopsCleanly with `WaitDelay
expired before I/O complete`; the failed Coverage chain passed on rerun
without code changes.
- Formal BVT: CN1 and CN2 JDBC entry points each passed 36/36
comparisons with full metadata checking. go vet, gofmt, and diff checks
passed.

Deployment evidence for the already-fixed product base, independently of
this new test commit:

- Old baseline run
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34352473993:
HNSW/L2/cosine/normalize errors were 0/1702/1266/588.
- Fixed-product run
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34464342049:
all four original million-vector SIFT128 cases completed with 100
terminals, five-minute measurements, and zero client errors. The five
data hashes match the failed baseline. Acceptance was checked from
artifact counters and error files, not only workflow success.

QA required: yes — distributed timing and deployed-workload acceptance.
Automated terminal coverage includes completed SQL assertions,
cancellation waiter exit, preserved terminal errors, registration
removal, and cleanup. QA should review the target release's inclusion of
the existing production fixes and the attached run evidence. First-error
query/stream/peer correlation and unique root-cause attribution remain
unavailable; this PR must not auto-close matrixorigin#28378.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8364)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#28293

## What this PR does / why we need it:

Two-level existential filters whose innermost predicate references both
its parent and grandparent currently fail during correlated-column
pullup. This change admits a bounded set of WHERE EXISTS, NOT EXISTS and
truth-only scalar IN predicates, including up to eight restricted
innermost OR arms, and lowers them to SEMI/MARK joins without
materializing the inner relation product. NULLs, empty inputs, outer
duplicates and existing successful planning paths retain their
semantics; unsupported shapes retain the existing rejection behavior.

Repeated non-PK RIGHT SEMI/ANTI hash matches skip groups already
completed in the worker-local bitmap. Distributed broadcast also retires
explicitly stopped receivers without truncating delivery to remaining
local or remote consumers, while preserving real query and transport
errors.

Validation before the main merge: full planner, dispatch and hashjoin
packages; focused compile and race checks; 250/250 MySQL differential
cases; 34/34 BVT statements twice; two-CN execution and
cancellation/reuse twice. Merge validation is recorded in the linked
report.

Performance checks cover duplicate keys, high NDV, skew, asymmetric
relation sizes, natural two-CN execution and existing planner paths.
Tested cases show no statistically supported latency regression above
5%; this is not a universal bound. The outer-gated ANTI shape uses about
5.2 MB more hash memory (7.1%) at 4.5 million build rows for its Boolean
hash key.

See the [design](docs/rfcs/20260907_deep_existential_decorrelation.md)
and [validation
report](docs/rfcs/20260907_deep_existential_validation.md) for scope,
measurements and limitations.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#28378

## What this PR does / why we need it:

Add regression coverage for queued stream cancellation, shuffle receiver
retirement, and distributed IVF query cleanup. Production fixes are
already present through matrixorigin#28358, the relevant dispatch/remote pipeline
changes in matrixorigin#28364, and matrixorigin#28539; this PR changes tests only and does not
establish their individual causal contribution to the original TKE
incident.

- Observe serialized MORPC sequence numbers after a queued message is
canceled. The identical test compiles on the matrixorigin#28358 parent and fails
with expected sequence 2 versus actual 3.
- Cover first, middle, last, and consecutive shuffle receiver
retirement, checking both subsequent sends and one-time notification.
Exercise query/connection cancellation during real receiver credit
waiting through the CN handler, preserving the terminal error and
releasing lifecycle registration.
- Add a two-CN IVF test with 256 128-dimensional vectors. The
representative L2 case exercises eight concurrent sessions with one
simultaneous query per session; cosine, normalized L2, and raw-vector
IP/normalized-query retain their per-distance lifecycle and result
checks. The test covers exact full-probe comparison, approximate-result
validity, empty results, and subsequent queries. Test preparation
failure uses the actual phase runner, transaction rollback, worker exit,
and database cleanup. Preparation and query budgets are cumulative but
separate; cleanup gets its own context. SQL pre-cancellation is not
presented as proof of active remote cancellation. The fixture provides
16 vectors per IVF list on average; Vector Index Scan selects Multi-CN
without a 65,536-row threshold, so the 256-row fixture preserves the
lifecycle and result oracles while bounding the owning package's race
cost.
- Extend test/distributed/cases/vector/vector_ivf_multicn_search.sql and
.result with cosine, raw-vector IP/normalized-query, empty-result, and
follow-up checks. The GROUP_CONCAT metadata expectation uses the
existing server TEXT mapping and Connector/J 8.0.15 metadata; results
were not regenerated blindly.

Validation (final file contents include the follow-up assertion, SCA,
coverage-budget, fixture-size, and concurrency-budget fixes; exact head
323daee; upstream base
07b2596; product base
2a6fe7f):

- macOS arm64, Go 1.26.4, repository CGo wrapper, GOMAXPROCS=4, test
package parallelism 1.
- New mechanism tests: ordinary 100 iterations and race 20 iterations
passed. MORPC, dispatch, and compile packages passed ordinary/race
checks; unchanged evidence was reused.
- Follow-up P2 validation:
TestRemoteNotifyCancellationReleasesCreditWaitAndRegistration passed
ordinary 100 iterations and race 20 iterations after asserting that
connection cancellation closes proc.Ctx, records a non-nil
ErrStreamClosed cause, and preserves it through repeated terminal
cleanup.
- After the follow-up edit, the complete owning ./pkg/sql/compile
package passed once under the race detector; no race report was emitted.
- Exact prior-head fixture validation: GOWORK=off go test -mod=readonly
-count=1 -timeout=15m -run '^TestIssue28378IVFFlatRemoteLifecycle$'
./pkg/tests/issues passed in 14.855s; the same exact test with -race and
a 20m timeout passed in 34.817s. After the first fixture-size change,
the 1,024-row test passed ordinary in 16.675s and race in 33.739s; after
the final 256-row/one-iteration change, it passed ordinary in 16.591s
and race in 24.467s.
- The MORPC parent counterexample validates the sequence mechanism. The
IVF integration test is regression coverage, not a deterministic
reproduction of the historical incident.
- Reviewer P2 response: the fixture was reduced from 65,536 to 256 rows
and the concurrent repeat count from two to one in 323daee. XuPeng-SH
measured the prior 65,536-row test at 573.55s in the exclusive -p 1
-race UT stage on parent head 7944a5b; the focused runs above measure
the latest local fixture at 16.591s ordinary and 24.467s race. These are
different environments and modes, so the numbers are reported as bounded
before/after evidence rather than a CI performance claim. The exact-head
CI run below provides the Linux cost measurement.
- Exact current-head CI run 34756863153 for f7cb131 passed Ubuntu UT,
SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, and CI Required.
The subsequent exact-head run 34799486791 for 323daee passed on
attempt 2: Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic
BVT, Coverage, and CI Required are green. Its first attempt failed only
in the unrelated optools TestUTHeartbeatStopsCleanly with `WaitDelay
expired before I/O complete`; the failed Coverage chain passed on rerun
without code changes.
- Formal BVT: CN1 and CN2 JDBC entry points each passed 36/36
comparisons with full metadata checking. go vet, gofmt, and diff checks
passed.

Deployment evidence for the already-fixed product base, independently of
this new test commit:

- Old baseline run
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34352473993:
HNSW/L2/cosine/normalize errors were 0/1702/1266/588.
- Fixed-product run
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34464342049:
all four original million-vector SIFT128 cases completed with 100
terminals, five-minute measurements, and zero client errors. The five
data hashes match the failed baseline. Acceptance was checked from
artifact counters and error files, not only workflow success.

QA required: yes — distributed timing and deployed-workload acceptance.
Automated terminal coverage includes completed SQL assertions,
cancellation waiter exit, preserved terminal errors, registration
removal, and cleanup. QA should review the target release's inclusion of
the existing production fixes and the attached run evidence. First-error
query/stream/peer correlation and unique root-cause attribution remain
unavailable; this PR must not auto-close matrixorigin#28378.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/enhancement size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compatibility]: deep correlated EXISTS and IN predicates referencing innermost and outer columns are rejected

3 participants