Skip to content

fix: preserve cancellation identity across hnsw read path - #28070

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
aptend:fix/27261-qcloud-cancel-identity
Sep 3, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
aptend:fix/27261-qcloud-cancel-identity

Conversation

@aptend

@aptend aptend commented Sep 3, 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:

issue #27261

What this PR does / why we need it:

The incident path had two independent cancellation-identity loss points.

First, Tencent COS wraps an in-flight request cancellation in cos.RetryError, which does not implement Unwrap. MatrixOne therefore could not recognize the request as canceled. Normalize that wrapper for QCloud read-only operations only when the request context is already done and the wrapper contains exactly one matching context error. Active contexts, mixed errors, unrelated storage errors, and mutating operations remain unchanged.

Second, HNSW streaming waits and internal-executor result publication converted a canceled context into an internal error. Preserve context.Cause at those boundaries so StopSending remains recognizable as normal pipeline cancellation and a substantive nested stream cause is not discarded.

The regression coverage deterministically cancels requests only after they are in flight, covers every QCloud read-only adapter, exercises both HNSW wait paths and result cleanup, and retains negative controls for substantive errors. Focused tests, full owning-package tests, go vet, and repeated race tests pass.

@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 requested a review from aunjgr as a code owner September 3, 2026 09:13
@aptend aptend changed the title fix(fileservice): preserve qcloud cancellation identity fix: preserve cancellation identity across hnsw read path Sep 3, 2026
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/S Denotes a PR that changes [10,99] lines labels Sep 3, 2026

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

Deep-reviewed exact head 4967efd. No blocking findings.

Correctness/counterexamples:

  • QCloud normalization is scoped to read-only operations and only collapses an opaque single-child RetryError after the owning context is done; active contexts, unrelated errors, mixed retry errors, and mutating operations remain unchanged.
  • context.Cause preserves both ordinary cancellation identity and substantive nested causes across internal SQL publication and HNSW waits.
  • Cancellation does not leak batches or temp/index resources: unpublished results are closed by the publisher, published results are drained by the HNSW consumer, producer goroutines are joined, and error cleanup runs before checksum/usearch acceptance.
  • No new unbounded wait or accumulation path was introduced. Existing channel waits retain context/stopped wakeups and bounded buffers.

Performance: the successful storage path adds only an immediately returning nil-error check; retry policy, request count, I/O volume, locks, and buffer sizes are unchanged. The context.Cause calls are cancellation-only.

Validation:

  • CI for this exact head is green, including Linux UT, SCA, coverage, proxy BVT, and pessimistic multi-CN BVT.
  • All four changed/added concurrency tests passed individually with race, count=100.
  • Full race runs passed for pkg/fileservice, pkg/sql/compile, and pkg/vectorindex/hnsw.
  • A clean synthetic merge with current main 2112809 (including #28072) passed the combined focused race suite and the full pkg/sql/compile race suite.

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

mergify Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-03 12:26 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-09-03 13:16 UTC · at f5ea063ef45b0766ba2ba0add0ed32e0493484d1 · squash

This pull request spent 50 minutes 24 seconds in the queue, including 50 minutes 6 seconds running CI.

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

@mergify
mergify Bot merged commit f5ea063 into matrixorigin:main Sep 3, 2026
27 of 28 checks passed
@mergify mergify Bot removed the queued label Sep 3, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…in#28070)

The incident path had two independent cancellation-identity loss points.

First, Tencent COS wraps an in-flight request cancellation in cos.RetryError, which does not implement Unwrap. MatrixOne therefore could not recognize the request as canceled. Normalize that wrapper for QCloud read-only operations only when the request context is already done and the wrapper contains exactly one matching context error. Active contexts, mixed errors, unrelated storage errors, and mutating operations remain unchanged.

Second, HNSW streaming waits and internal-executor result publication converted a canceled context into an internal error. Preserve context.Cause at those boundaries so StopSending remains recognizable as normal pipeline cancellation and a substantive nested stream cause is not discarded.

The regression coverage deterministically cancels requests only after they are in flight, covers every QCloud read-only adapter, exercises both HNSW wait paths and result cleanup, and retains negative controls for substantive errors. Focused tests, full owning-package tests, go vet, and repeated race tests pass.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…in#28070)

The incident path had two independent cancellation-identity loss points.

First, Tencent COS wraps an in-flight request cancellation in cos.RetryError, which does not implement Unwrap. MatrixOne therefore could not recognize the request as canceled. Normalize that wrapper for QCloud read-only operations only when the request context is already done and the wrapper contains exactly one matching context error. Active contexts, mixed errors, unrelated storage errors, and mutating operations remain unchanged.

Second, HNSW streaming waits and internal-executor result publication converted a canceled context into an internal error. Preserve context.Cause at those boundaries so StopSending remains recognizable as normal pipeline cancellation and a substantive nested stream cause is not discarded.

The regression coverage deterministically cancels requests only after they are in flight, covers every QCloud read-only adapter, exercises both HNSW wait paths and result cleanup, and retains negative controls for substantive errors. Focused tests, full owning-package tests, go vet, and repeated race tests pass.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…in#28070)

The incident path had two independent cancellation-identity loss points.

First, Tencent COS wraps an in-flight request cancellation in cos.RetryError, which does not implement Unwrap. MatrixOne therefore could not recognize the request as canceled. Normalize that wrapper for QCloud read-only operations only when the request context is already done and the wrapper contains exactly one matching context error. Active contexts, mixed errors, unrelated storage errors, and mutating operations remain unchanged.

Second, HNSW streaming waits and internal-executor result publication converted a canceled context into an internal error. Preserve context.Cause at those boundaries so StopSending remains recognizable as normal pipeline cancellation and a substantive nested stream cause is not discarded.

The regression coverage deterministically cancels requests only after they are in flight, covers every QCloud read-only adapter, exercises both HNSW wait paths and result cleanup, and retains negative controls for substantive errors. Focused tests, full owning-package tests, go vet, and repeated race tests pass.

Approved by: @XuPeng-SH
XuPeng-SH added a commit that referenced this pull request Nov 20, 2026
…32947)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Related to #32389 and the 4.2-dev fix #32945.

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

Main already restores ordinary COS read cancellation identity through
#28070. The read-only adapter's singleton retry wrapper check can also
match a cancellation nested inside an aggregate and discard a sibling
storage failure. Walk the single-error unwrap chain to preserve pure
wrapped cancellations and retain aggregate errors.

Route matching reader context cancellations through the existing bounded
DEBUG event contract. Real reader failures use a bounded ERROR event
carrying the concrete error type and the reader context status. Derived
fields are formatted after log-level and rate checks.

The existing in-flight HTTP tests pass on main. The new wrapped
aggregate regression fails with main's original adapter and passes with
this change. The 4.2-dev nightly reproduction is related context. It has
no logged concrete Go error type and does not establish that the
aggregate occurred there.

Local race validation passed on fileservice and readutil with Go 1.27.1.
The repository SCA selector chose the full scan. Molint and
golangci-lint passed.

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 size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants