Repository navigation
fix: preserve cancellation identity across hnsw read path - #28070
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
Merge Queue Status
This pull request spent 50 minutes 24 seconds in the queue, including 50 minutes 6 seconds running CI. Required conditions to merge
|
…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
…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
…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
…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.
What type of PR is this?
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.