Skip to content

fix(compile): backport IVF sampling cancellation fixes to 4.2 - #32398

Merged
XuPeng-SH merged 3 commits into
matrixorigin:4.2-devfrom
VioletQwQ-0:fix/32389-ivf-sampling-cancel-4.2
Nov 9, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:4.2-devfrom
VioletQwQ-0:fix/32389-ivf-sampling-cancel-4.2

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Nov 9, 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 #32389

What this PR does / why we need it:

Backport the missing behavior from #27890 and #28926 to 4.2-dev. A normal StopSending during parallel reader construction must not publish a terminal execution error while the query remains live.

Normalize the result before the pre-publication ParallelRun cleanup chooses End versus Error. Construct readers from the source scope context so reader cancellation and cleanup classification observe the same lifetime. Reuse the branch-local normalizer and retain rate-limited cancellation diagnostics; do not backport main's newer outcome/protocol refactors. Real query cancellation, deadline, storage errors and mixed primary/cancellation errors remain terminal.

Validation (base 6d4dc2f):

  • Base behavior: FAIL — new deterministic construction-cancellation regression and real local/remote reader-context boundary tests detect the old behavior.
  • PR-head behavior: PASS — eight focused tests; each also passes 100 race repetitions. Full pkg/sql/compile normal and race tests pass; full colexec and connector normal tests pass.
  • BVT: test/distributed/cases/vector/vector_ivf_sampling_cancel.sql and .result. Both standalone and two-CN topology pass 27/27 assertions twice on the same instance; teardown checked after each run. Service logs confirm SAMPLE 100 PERCENT LIMIT 10000, using 10,001 low-dimensional vectors and sequential L2/cosine/IP creation/query/drop.
  • Static/build: make cgo, service build, compile go vet, incremental golangci-lint and git diff --check pass.
  • Retained unrelated failure: full pkg/vm/process normal tests hit TestHarvestExternalCounterSetAndTerminalWait at operator_analyzer_test.go:552 (strictly positive duration around an empty callback). The unchanged baseline reproduces the same assertion in 46/100 targeted runs; no test was skipped or modified to hide it.
  • Earlier setup/oracle attempts retained locally: macOS binary loader path corrected; IP BVT ordering corrected to ASC for this branch's negative dot-product function; direct race binary cwd corrected to the package directory for resource-relative tests. Final checks above use the corrected inputs.

QA required: yes — the original fixed-version SIFT 1M/128-dimensional TKE scenario is NOT RUN in this PR preparation. These tests close the known missing mechanisms; they do not prove the first cancellation owner of the reported incident or that the original intermittent failure has disappeared. Keep this PR Draft and #32389 open pending QA. No performance or zero-intermittency claim.

No public API, SQL syntax, configuration, catalog, storage format, retry or timeout change.

Review follow-up: the cancellation fixture now owns and closes its private AutoIncrementService before restoring the prior runtime. Worker cleanup cancels and joins through a separate completion channel even when the result is unread. A regression checks service closure, private-runtime reference removal, old-runtime restoration, and worker completion after an early subtest return. This follow-up changes only tests; the product and SQL BVT evidence above is reused.

Follow-up validation: four directly affected tests pass normally and each passes 100 race repetitions; full pkg/sql/compile normal and race pass; incremental lint and git diff --check pass. Astra medium re-review confirms the original P2 is resolved with no remaining confirmed blocker.

@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 →

@XuPeng-SH

XuPeng-SH commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: e9205837b6c85b8c908104bcc004d56ca0d1828b

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: e9205837b6c85b8c908104bcc004d56ca0d1828b

Assessment: approve

The scoped 4.2 backport reuses existing cancellation classification and cleanup ownership, aligns reader contexts with their source pipeline, and correctly closes fixture workers and services. No actionable regression remains.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed the complete four-file delta, relevant owners and consumers, linked issue 32389 and all discussion entries; discussion-assessment.json covers every key.

  • All nine focused tests passed normally and under -race, followed by 100 race repetitions per test through nine exact-test commands: 900 repetitions passed.

  • Whole compile normal/race runs each recorded 769 passing tests and three baseline-reproduced Parquet failures, with no race reports. Colexec and connector normal suites passed 83 and 13 tests.

  • Isolation preflight, fresh native build, native integrity, formatting, diff and clean frozen-source checks passed. Receipts and retained logs are mapped in validation-reconciliation.json.

  • Supplied exact-head snapshot records successful later x86 UT, arm64 SCA and multi-CN BVT checks.

Limitations:

  • Full compile package runs were not green: the three Parquet assertion failures reproduce on exact baseline Go inputs in both normal and race modes.

  • The distributed SQL case was reviewed but not executed locally; supplied author BVT reports lack retained raw execution logs.

  • Original fixed-version TKE SIFT1M/128D QA and attribution of the first cancellation owner remain unverified.

@XuPeng-SH
XuPeng-SH merged commit 899f08b into matrixorigin:4.2-dev Nov 9, 2026
XuPeng-SH added a commit that referenced this pull request Nov 13, 2026
## 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:

Related to #32146.

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

Backport the large-variable-length write memory fixes and their
lifecycle dependencies to `v4.2.8-hotfix`. A 196,092-row fixture with
very large JSON/text values completes its batched UPDATE on 4.2.8 but
OOM-kills a 20-GiB CN during the subsequent VARCHAR-to-INT COPY ALTER.
The backports bound CN spill runs and pooled writer retention while
preserving buffer/object ownership through completion, cancellation, and
failure.

Cherry-picked with source provenance, in order: #32081, #32155, #32332,
#32164, #32398, #32454, and #32065. The target branch's existing #32704
is retained. There are no manual production-code changes to the seven
backports.

Validation on head `cc1d6c51a156e232182030b093bbf9bfc1ae95c1`:

- Fresh native build succeeds with actual-head version/commit metadata.
Formatting and `git diff --check` pass. All seven commits have identical
added/removed lines and paths to their source commits; only #32155 has
documentation-only unchanged-context differences.
- Actual-head full-data run PASS: 196,092 rows, 147,941 converted rows;
PK/row count, payload byte lengths and CRC sums, final statuses, and INT
type verified. All roles report `OOMKilled=false`.
- CN limit and total memory+swap are both 20 GiB, 6 CPUs, GOMEMLIMIT 1
GiB, cache 2 GiB. Sampled CN RSS peak: **12.4115 GiB** (2-second
sampling). Sampled cgroup usage peak: 19.7955 GiB; kernel cgroup
high-water reached 20 GiB, with zero failcnt/OOM. RSS is not total
container memory, so this does not imply 7.6 GiB of container headroom.
- Driver start through final verification: **431.90 s (7m12s)**,
including token UPDATE **221.59 s**, token COPY ALTER **200.84 s**, and
remaining validation/setup. Service startup and cold-backup restore are
excluded.
- Native-toolchain scoped regressions pass: nine owning packages (2,302
tests/subtests); compile import/cancellation selector (153); focused
race checks across mpool, rscthrottler, objectio and ioutil (93). Runs
use `-count=1`, the repository CGo test wrapper, and default vet checks.
No failures; task services are stopped. Full-repository CI/review is not
part of this local validation, and further GitHub results are not
awaited.

The workload measures the MOI offset212 token-table migration, with
placeholder companion tables, rather than all MOI deployment phases.
Logical restore uses a shared DISK backend and changes the original
physical object layout; customer data and raw logs are not included in
this PR. Single-run timings are not a statistical performance benchmark.


Revision `b6b9f3ba40d7bb9e598b2a8846b7ed166b4a48b7` (test-only
follow-up):

- Carries #32439's unordered two-observation reset assertion and
#28467's 512-MiB RLIMIT target; closes the actual fixture-owned
increment service; adapts first-replay setup to this release's embed API
and TCP SQL transport. Production changes in the seven backports remain
identical to their sources.
- New local validation (Darwin/arm64, Go 1.27.1, CGo wrapper,
`-count=1`): owning production packages build; all four changed test
packages vet; `objectio/ioutil` full coverage and race pass; `mpool`
coverage passes; `sql/compile` full normal and race pass with
`TMPDIR=/private/tmp`; first-replay
startup/disconnect/reconnect/prepared SQL passes normal and race.
Spill-reset and fixture-ownership tests each pass `-race -count=100`.
Formatting, diff whitespace, and delivery artifact checks pass.
- Run 43449877707 attempt 1 failed SCA job 131969091882 (`make
static-check-analysis`) on missing `embed.WithDataPath`; coverage job
131969165708 reports that build error, RLIMIT runtime allocation
failure, and the fixture closure assertion. These backported test
defects are addressed here; the old run is not rerun because the push
triggers fresh CI. Pinned molint rebuilt for the local Go version exits
zero but emits inherited analyzer diagnostics; this is not a
zero-diagnostic SCA claim.
- Local Parquet fanout failures also reproduce in an unmodified archive
of target base `b572b5cd95a25d404cd0f0df32629b39c6fff120`; full PR
compile normal/race pass with a short temporary root. No Parquet
code/test is changed. Linux-only RLIMIT execution is reused from
#28467's upstream coverage/race evidence; not executed on this Darwin
host. Original migration and other upstream validation above retain
their stated revisions/configurations; the customer-data migration was
not repeated for these test changes. New CI is not awaited. Raw local
logs remain outside the source tree.

---------

Co-authored-by: aptend <[email protected]>
Co-authored-by: XuPeng-SH <[email protected]>
Co-authored-by: GreatRiver <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: 和光同尘 <[email protected]>
Co-authored-by: jiangxinmeng1 <[email protected]>
aptend added a commit to aptend/matrixone that referenced this pull request Nov 21, 2026
The original backport carried matrixorigin#32332 and matrixorigin#32398 from 4.2.8. Retain the matrixorigin#32065 cleanup error propagation and mpool allocation accounting. The independent startup, RPC, realloc, prepared-reader, and IVF changes can be reviewed separately.
aptend added a commit to aptend/matrixone that referenced this pull request Nov 21, 2026
The shared cancellation fix in matrixorigin#32398 has an import dependency. A bounded local scan can hold the import ticket while its reader still listens to the live query context after a sibling fails. Bind those readers to their pipeline and preserve the primary cancellation cause. The IVF-specific regression and ordinary reader behavior stay out of this backport.
@VioletQwQ-0
VioletQwQ-0 deleted the fix/32389-ivf-sampling-cancel-4.2 branch December 1, 2026 03:47

This branch was successfully deployed

No deployments
ci — 11d8ea84 Deployed Nov 9, 2026 by XuPeng-SH
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 size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants