Skip to content

test: cover IVF remote stream lifecycle regressions - #28672

Merged
XuPeng-SH merged 17 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28378-regressions
Sep 14, 2026
Merged

XuPeng-SH merged 17 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28378-regressions

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • 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 fix(morpc): avoid client stream sequence gaps #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:

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.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Addressed the P2 connection-cancellation oracle gap in follow-up commit 4e6fe7b3049ba2c6a4808c2f6130dab61851a072.

The connection subtest now asserts, before terminal publication and registry cleanup, that proc.Ctx.Done() is closed, context.Cause(proc.Ctx) is non-nil, and the cause is ErrStreamClosed, in addition to the existing wire-error check. This prevents a handler-only cleanup path from passing while the owning query remains alive.

Validation after the edit:

  • focused test: ordinary 100 iterations passed;
  • focused test: race 20 iterations passed;
  • complete ./pkg/sql/compile package: one race run passed with no race report;
  • gofmt and git diff --check: passed.

The BVT plan-path enhancement remains a non-blocking follow-up; this change addresses the blocking P2 only.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Reduce or justify the 65,536-vector regression fixture — pkg/tests/issues/issue_28378_test.go:295–299

This fixture builds 65,536 128-dimensional vectors and recreates them for four IVF index cases. On this exact head, the exclusive -p 1 -race UT stage reports TestIssue28378IVFFlatRemoteLifecycle taking 573.55 seconds out of 1180.70 seconds for the owning issues package; this is test execution time, not fixture admission wait. The current MultiCN IVF path has no 65,536-row threshold (stats.go:3281–3288, compile.go:5249–5260), and an existing 16-row BVT already exercises a MultiCN plan.

The testing contract requires a measured before/after delta and a written reason why reuse, injection, or a smaller dataset cannot prove the same contract when a test materially increases owning-package time. I could not find either in the PR body, comments, diff, or validation evidence. Please reduce the fixture while preserving its oracles, or provide the same-mode cost comparison and explain which necessary boundary a smaller fixture cannot exercise. Green CI shows this run passed; it does not close this cost/controllability gate.

The rest of the current diff has no other verified blocker. Current exact-head SCA, UT/race, coverage, shared build, and PROXY/PESSIMISTIC multi-CN BVT checks pass.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Addressed the P2 fixture-size concern in follow-up commit f7cb131935d0a72cbaa418be99e5149b1b131282.

  • Reduced the IVF fixture from 65,536 to 4,096 rows and centralized the row bound.
  • Kept 256-row insertion batches, 128 dimensions, 16 IVF lists, both CN indexed remote-path checks, eight concurrent L2 sessions, exact full-probe comparison, probe-5 validity/empty-result/follow-up checks, cancellation, and cleanup assertions.
  • The vector-index plan selects Multi-CN without a 65,536-row threshold; 4,096 rows provide 256 vectors per list on average, so the larger fixture did not add a lifecycle boundary.
  • Focused validation passed: ordinary ~15s, race ~35s; package vet and test compilation also passed.

The PR body records the size rationale and validation. Please re-review the updated head.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

XuPeng-SH, addressed in f7cb131: the IVF fixture is now 4,096 rows instead of 65,536, still 256 vectors per IVF list on average, and the test comment records why the 65,536 boundary is not required by the Multi-CN vector-index path. Exact-head focused validation passed in ordinary mode at 15.470s and race mode at 36.096s. Your 573.55s measurement was on the prior 65,536-row parent head under the exclusive -p 1 -race UT stage; I have recorded the different-mode caveat in the PR body rather than presenting it as a CI performance claim. The body now points to product base 288a0a2 and fresh exact-head run 34756863153, which is still in progress.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6 medium deep review of exact head f7cb131935d0a72cbaa418be99e5149b1b131282: no blocker found; approved.

Reviewed all six changed files across queued-stream cancellation sequence preservation, dispatch retirement of consecutive stopped receivers, remote credit-wait cancellation and lifecycle cleanup, and the IVF dual-CN regression coverage. Worker joins and fixture/database teardown are bounded; I found no concrete leak, cancellation deadlock, duplicate retirement, or major racing-UT slowdown mechanism.

Exact-head CI evidence: race-test job passed; the IVF test took 45.55s in the exclusive race-test stage (queries 43.23s, injected preparation failure cleanup 2.32s). The compose artifact confirms vector_ivf_multicn_search.sql ran 36/36 successfully in 0.938s. I reused these exact-head CI results rather than rerunning the heavier fixture locally.

@mergify

mergify Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-14 00:10 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-14 00:18 UTC · at e9054d0434b5bd33cf4ed987c3e5e89759c6c53a

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

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Reason

Pull request #28672 has been dequeued

Queue conditions are not satisfied:

  • #changes-requested-reviews-by<=0
  • approved-reviews-by=XuPeng-SH

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review update at current head e9054d0434b5bd33cf4ed987c3e5e89759c6c53a: REQUEST_CHANGES on test cost.

The added top-level TestIssue28378IVFFlatRemoteLifecycle at pkg/tests/issues/issue_28378_test.go:144 takes 45.55 seconds in the race-test job by itself; its queries subtest takes 43.23 seconds. This exceeds the accepted cost for one racing UT. My prior approval at an earlier head did not account for this per-test cost and should not be treated as approval of this revision.

Keep the lifecycle regression coverage, but materially reduce the single-test cost: shrink the fixture/index/query work or move the longer stress portion to a slower suite. Please measure and report the exact focused -race test duration after the change. The 45.55-second evidence is from the exact prior head's CI; the IVF test source is unchanged in the current head. The current head's CI is still in progress.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Revalidated the current pushed head 323daee056991164e5f807ac070295baf633b460 after the fixture/concurrency bound update.

  • The IVF fixture is now 256 rows (16 vectors per list on average), and the eight-session L2 interleaving performs one simultaneous query per session. The preparation-failure, four distance cases, cancellation-before-admission check, follow-up query, remote execution assertions, and cleanup all remain intact.
  • Exact focused validation on the current head passed in normal mode: test elapsed 15.06s, package elapsed 16.977s; -race passed with test elapsed 20.62s and package elapsed 24.788s, with no race report.
  • For the same host and native artifact, the prior 4,096-row exact-head baseline passed with test elapsed 40.47s and package elapsed 44.087s. The comparison is bounded local evidence, not a cross-run CI performance claim.

The branch and PR remain Ready/MERGEABLE; fresh exact-head CI is still running, followed by the normal distributed BVT/QA gates.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Current head 323daee056991164e5f807ac070295baf633b460 has now completed the exact-head CI rerun successfully: run 34799486791, attempt 2; CI Required, Ubuntu UT, SCA, Coverage, shared build, and multi-CN BVT checks are green. The earlier Coverage failure was the unrelated intermittent optools/TestUTHeartbeatStopsCleanly (WaitDelay expired before I/O complete); the rerun passed without code changes.

The Linux Ubuntu UT report for this head shows TestIssue28378IVFFlatRemoteLifecycle passing in 12.58s (queries 10.15s; preparation-failure 2.43s). Please re-review this exact head; the IVF fixture is 256 rows and one simultaneous query per session, with lifecycle, cancellation, remote-path, result, and cleanup assertions retained.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

@XuPeng-SH the requested fixture/cost change is on 323daee056991164e5f807ac070295baf633b460. Exact-head CI run 34799486791 attempt 2 is fully green; the focused IVF test passes in 12.58s on Ubuntu UT. Please re-review this head when available.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed exact head 323daee056991164e5f807ac070295baf633b460. The earlier race-UT timing concern is resolved: the exact-head race CI reports 12.58s for the IVF lifecycle suite (queries 10.15s, preparation_failure 2.43s), down from 45.55s. The test still covers dual-CN result correctness, cancellation, receiver retirement, waiter cleanup, rollback, and independent cleanup. BVT artifact reports 36/36 successful. I found no remaining correctness, lifecycle, or material test-cost blocker.

@mergify

mergify Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-14 04:44 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-14 04:54 UTC · at 5ce02a0b503c52799d4733931c849a7ba642449d

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

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.

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

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep-reviewed exact head 323daee056991164e5f807ac070295baf633b460 against base 07b25969bfea9d4b76d3bf05d5b0497e4f36eba0, including all prior reviews/comments, the final fixture/concurrency reduction, and the complete six-file diff. No blocker found. The tests exercise post-admission MORPC cancellation without sequence gaps, first/middle/last/consecutive shuffle receiver retirement, query/connection cancellation while blocked on remote batch credit with terminal ownership cleanup, and bounded dual-CN IVF result/lifecycle coverage. Worker, transaction, connection, database, and timeout cleanup paths are bounded and joined. Local exact-head validation passed: each focused mechanism test for MORPC, dispatch, and remote notify ran 10 times; the phase-budget and two-CN IVF lifecycle suite passed in 13.929s; gofmt and diff checks were clean. Exact-head required CI is green.

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/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: IVFFlat SIFT128 queries close RPC streams on main

4 participants