Skip to content

fix: preserve source context for parallel readers - #28926

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/issue-28816-reader-cancel
Sep 15, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/issue-28816-reader-cancel

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

Fixes #28816

Root cause: reader construction selected the compile-scope context instead of the source scope context, allowing cancellation to escape during ParallelRun reader setup.

This patch gives source scope context precedence with a compile fallback and adds source/fallback/nil regression coverage while preserving real storage errors.

Validation: compile ordinary and race tests; changed-line coverage 7/8 (87.50%); incremental SCA 0 issues.

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

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

Reviewed exact head 78b3660f7af1a5d0999ac8e5b32abf17de7c54b4. The reader build now waits on the source scope context—the same context used by normalizeScopeRunError—while retaining the compile-process fallback, which closes the StopSending cancellation race without hiding query cancellation or substantive reader errors. I reviewed the complete diff and review history and found no blocking issue. Validation: the four focused compile tests passed 20 consecutive runs; the source-context, StopSending-during-build, and query-cancellation tests also passed 10 runs under -race.

@mergify

mergify Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

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

  • Queue this pull request

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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 at exact head 78b3660.

Local decision: BLOCKED on validation evidence (COMMENT ONLY). No confirmed code defect.

The change affects production cancellation behavior, but the available evidence reports focused race repetitions without measured durations or a documented budget override; the package-race claim lacks identifiable terminal output. The required R3 race-validation gate therefore remains unverified.

Please provide auditable exact-head adaptive race results for each affected focused test and one owning-package race pass, with test selection, execution mode, and terminal output recorded. This is an evidence gap, not a demonstrated runtime failure.

As this is an author-owned PR, this result is submitted as COMMENT only.

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

Reviewed exact head 78b3660 against ceaf9c6. No confirmed blocker.

Source-scope context now takes precedence for all three reader-construction paths, with the compile context only as fallback. Tenant/snapshot and reader hints are still applied after choosing the context. Existing blocked-reader tests distinguish graceful StopSending from real query cancellation; the change does not convert arbitrary storage errors into success or introduce a new owner/goroutine.

I checked the existing CI evidence rather than repeating the earlier missing-package-race concern. Exact-head run 34938329927 is green. Its ut-summary artifact 10387439513 contains ut-checkpoint.log: the light test command explicitly selects pkg/sql/compile with -race, and the stage ends status=0 at 2026-09-15T07:53:27Z. The full two-file diff and source/fallback/nil, blocked reader and query-cancel controls were inspected. Author-reported focused repetitions remain separate from this independently verified package-race evidence.

No new local tests, native build or cluster run.

@XuPeng-SH
XuPeng-SH merged commit 1d7d425 into matrixorigin:main Sep 15, 2026
15 of 19 checks passed
@XuPeng-SH
XuPeng-SH deleted the fix/issue-28816-reader-cancel branch September 15, 2026 11:49
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Fixes matrixorigin#28816

Root cause: reader construction selected the compile-scope context
instead of the source scope context, allowing cancellation to escape
during ParallelRun reader setup.

This patch gives source scope context precedence with a compile fallback
and adds source/fallback/nil regression coverage while preserving real
storage errors.

Validation: compile ordinary and race tests; changed-line coverage 7/8
(87.50%); incremental SCA 0 issues.

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
Fixes matrixorigin#28816

Root cause: reader construction selected the compile-scope context
instead of the source scope context, allowing cancellation to escape
during ParallelRun reader setup.

This patch gives source scope context precedence with a compile fallback
and adds source/fallback/nil regression coverage while preserving real
storage errors.

Validation: compile ordinary and race tests; changed-line coverage 7/8
(87.50%); incremental SCA 0 issues.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
XuPeng-SH added a commit that referenced this pull request Nov 9, 2026
## What type of PR is this?

- [ ] API-change
- [x] 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.

---------

Co-authored-by: XuPeng-SH <[email protected]>

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

size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ParallelRun can surface StopSending cancellation during reader construction

4 participants