Repository navigation
[4.2] fix(fileservice): retry COS multipart init before request write - #28043
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.
Blocking correctness issue:
pkg/fileservice/qcloud_sdk.go:411treats an attempt as commit-ambiguous only whenresponse == nil && wroteRequest. A non-nil response does not prove that multipart initialization failed. The COS SDK returns a non-nil*Responseas soon as it receives a 2xx response, then can return an error while copying/decoding that response body. For example, COS may have created the upload but the body can be empty/truncated and surface as EOF/unexpected EOF;output.UploadIDis then empty, andIsRetryableErrorclassifies unexpected EOF as retryable. This branch retries and may create a second upload while losing the first UploadID, exactly the orphan state the ambiguity guard is meant to prevent.
Please classify a 2xx response without a usable UploadID as commit-ambiguous (unless there is stronger protocol evidence that the operation did not commit), and add a transport/server test for a successful init response whose body is empty/truncated. Definitive error responses such as 5xx/429 remain safe to retry.
aptend
left a comment
There was a problem hiding this comment.
Deep review on exact head 467bf7e924db176e4805a6af70c31095add75ecc found one blocking commit-ambiguity gap. The bounded pre-write retry, cancellation/terminal-error precedence, cross-instance non-adoption, and metric correction otherwise look sound. I read the complete diff and existing review history; full affected-package tests, focused race runs (-count=20), go vet, and git diff --check pass. A review-only transport counterexample for the blocker fails deterministically.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review on exact head 74f4d49dc84f041bc8a28cc2209b2d50a7aac385: no blocking findings.
The latest commit closes the prior correctness blocker: every 2xx response without a usable UploadID is now treated as commit-ambiguous, so an empty or truncated success body cannot trigger a duplicate multipart initialization. I also re-reviewed the complete diff and history with counterexamples around pre-write failure, response loss, later 403, cancellation after ownership, cross-CN non-adoption, missing LIST permission, bounded exhaustion, and malformed success bodies.
Lifecycle and performance checks are sound for this scoped fix: COS SDK retries remain disabled; outer init attempts are capped at 3 under a 30s deadline with context-aware backoff; an owned UploadID is aborted on cancellation; the normal path adds only one trace/timer/counter per multipart initialization and does not alter part concurrency or HTTP connection reuse. The unresolved ownerless-upload case is honestly scoped out, requires bucket lifecycle reclamation, and remains tracked by open issue #28028.
Exact-head validation passed: focused init tests -count=100, focused race tests -count=20, full pkg/fileservice, pkg/util/metric/v2, and git diff --check. CI is green.
…ry-pick #28043) (#28136) ## 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 #28028. This PR intentionally does not close the issue because safe client-side reclamation of a commit-ambiguous upload still requires a cross-CN ownership protocol. ## What this PR does / why we need it: - Uses `net/http/httptrace.WroteRequest` to retry Tencent COS multipart initialization only when the request did not cross the transport write boundary, or when COS returned a definitive retryable error response. - Returns the current terminal result: caller cancellation/deadline wins, and a later definitive response such as 403 is not hidden by an earlier transient error. - Counts `ambiguous` only when a request was written but no COS response or usable UploadID was returned. - Never infers UploadID ownership from bucket listings, so it cannot adopt, complete, or abort another SDK/CN's multipart upload. - Keeps the normal multipart path compatible with credentials that do not grant `cos:ListMultipartUploads`; no bucket LIST is added. - Keeps retries and backoff bounded without changing upload-part concurrency or HTTP connection reuse. Operational contract and remaining scope: - If a request was written but its response was lost, MatrixOne cannot safely identify the resulting UploadID across CNs. It fails conservatively and emits an `ambiguous` metric plus a warning. - COS buckets must configure a lifecycle rule that aborts incomplete multipart uploads to reclaim such ownerless state. - A future complete fix for response-loss reclamation requires a server-visible, cross-CN ownership mechanism; #28028 remains open for that work. Validation: - Focused COS/QCloud tests pass. - Cross-instance ownership, pre-request recovery, committed-response loss, IAM compatibility, cancellation precedence, terminal 403 precedence, and owned cleanup tests pass with focused race validation. - `pkg/util/metric/v2` tests pass. - Multipart-init helper changed-logic coverage remains above 75%. - `go vet ./pkg/fileservice ./pkg/util/metric/v2` passes with the repository CGo environment. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…ry-pick matrixorigin#28043) (matrixorigin#28136) ## 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 matrixorigin#28028. This PR intentionally does not close the issue because safe client-side reclamation of a commit-ambiguous upload still requires a cross-CN ownership protocol. ## What this PR does / why we need it: - Uses `net/http/httptrace.WroteRequest` to retry Tencent COS multipart initialization only when the request did not cross the transport write boundary, or when COS returned a definitive retryable error response. - Returns the current terminal result: caller cancellation/deadline wins, and a later definitive response such as 403 is not hidden by an earlier transient error. - Counts `ambiguous` only when a request was written but no COS response or usable UploadID was returned. - Never infers UploadID ownership from bucket listings, so it cannot adopt, complete, or abort another SDK/CN's multipart upload. - Keeps the normal multipart path compatible with credentials that do not grant `cos:ListMultipartUploads`; no bucket LIST is added. - Keeps retries and backoff bounded without changing upload-part concurrency or HTTP connection reuse. Operational contract and remaining scope: - If a request was written but its response was lost, MatrixOne cannot safely identify the resulting UploadID across CNs. It fails conservatively and emits an `ambiguous` metric plus a warning. - COS buckets must configure a lifecycle rule that aborts incomplete multipart uploads to reclaim such ownerless state. - A future complete fix for response-loss reclamation requires a server-visible, cross-CN ownership mechanism; matrixorigin#28028 remains open for that work. Validation: - Focused COS/QCloud tests pass. - Cross-instance ownership, pre-request recovery, committed-response loss, IAM compatibility, cancellation precedence, terminal 403 precedence, and owned cleanup tests pass with focused race validation. - `pkg/util/metric/v2` tests pass. - Multipart-init helper changed-logic coverage remains above 75%. - `go vet ./pkg/fileservice ./pkg/util/metric/v2` passes with the repository CGo environment. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…ry-pick matrixorigin#28043) (matrixorigin#28136) ## 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 matrixorigin#28028. This PR intentionally does not close the issue because safe client-side reclamation of a commit-ambiguous upload still requires a cross-CN ownership protocol. ## What this PR does / why we need it: - Uses `net/http/httptrace.WroteRequest` to retry Tencent COS multipart initialization only when the request did not cross the transport write boundary, or when COS returned a definitive retryable error response. - Returns the current terminal result: caller cancellation/deadline wins, and a later definitive response such as 403 is not hidden by an earlier transient error. - Counts `ambiguous` only when a request was written but no COS response or usable UploadID was returned. - Never infers UploadID ownership from bucket listings, so it cannot adopt, complete, or abort another SDK/CN's multipart upload. - Keeps the normal multipart path compatible with credentials that do not grant `cos:ListMultipartUploads`; no bucket LIST is added. - Keeps retries and backoff bounded without changing upload-part concurrency or HTTP connection reuse. Operational contract and remaining scope: - If a request was written but its response was lost, MatrixOne cannot safely identify the resulting UploadID across CNs. It fails conservatively and emits an `ambiguous` metric plus a warning. - COS buckets must configure a lifecycle rule that aborts incomplete multipart uploads to reclaim such ownerless state. - A future complete fix for response-loss reclamation requires a server-visible, cross-CN ownership mechanism; matrixorigin#28028 remains open for that work. Validation: - Focused COS/QCloud tests pass. - Cross-instance ownership, pre-request recovery, committed-response loss, IAM compatibility, cancellation precedence, terminal 403 precedence, and owned cleanup tests pass with focused race validation. - `pkg/util/metric/v2` tests pass. - Multipart-init helper changed-logic coverage remains above 75%. - `go vet ./pkg/fileservice ./pkg/util/metric/v2` passes with the repository CGo environment. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…ry-pick matrixorigin#28043) (matrixorigin#28136) ## 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 matrixorigin#28028. This PR intentionally does not close the issue because safe client-side reclamation of a commit-ambiguous upload still requires a cross-CN ownership protocol. ## What this PR does / why we need it: - Uses `net/http/httptrace.WroteRequest` to retry Tencent COS multipart initialization only when the request did not cross the transport write boundary, or when COS returned a definitive retryable error response. - Returns the current terminal result: caller cancellation/deadline wins, and a later definitive response such as 403 is not hidden by an earlier transient error. - Counts `ambiguous` only when a request was written but no COS response or usable UploadID was returned. - Never infers UploadID ownership from bucket listings, so it cannot adopt, complete, or abort another SDK/CN's multipart upload. - Keeps the normal multipart path compatible with credentials that do not grant `cos:ListMultipartUploads`; no bucket LIST is added. - Keeps retries and backoff bounded without changing upload-part concurrency or HTTP connection reuse. Operational contract and remaining scope: - If a request was written but its response was lost, MatrixOne cannot safely identify the resulting UploadID across CNs. It fails conservatively and emits an `ambiguous` metric plus a warning. - COS buckets must configure a lifecycle rule that aborts incomplete multipart uploads to reclaim such ownerless state. - A future complete fix for response-loss reclamation requires a server-visible, cross-CN ownership mechanism; matrixorigin#28028 remains open for that work. Validation: - Focused COS/QCloud tests pass. - Cross-instance ownership, pre-request recovery, committed-response loss, IAM compatibility, cancellation precedence, terminal 403 precedence, and owned cleanup tests pass with focused race validation. - `pkg/util/metric/v2` tests pass. - Multipart-init helper changed-logic coverage remains above 75%. - `go vet ./pkg/fileservice ./pkg/util/metric/v2` passes with the repository CGo environment. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Related to #28028. This PR intentionally does not close the issue because safe client-side reclamation of a commit-ambiguous upload still requires a cross-CN ownership protocol.
What this PR does / why we need it:
net/http/httptrace.WroteRequestto retry Tencent COS multipart initialization only when the request did not cross the transport write boundary, or when COS returned a definitive retryable error response.ambiguousonly when a request was written but no COS response or usable UploadID was returned.cos:ListMultipartUploads; no bucket LIST is added.Operational contract and remaining scope:
ambiguousmetric plus a warning.Validation:
pkg/util/metric/v2tests pass.go vet ./pkg/fileservice ./pkg/util/metric/v2passes with the repository CGo environment.