Skip to content

[4.2] fix(fileservice): retry COS multipart init before request write - #28043

Merged
XuPeng-SH merged 4 commits into
matrixorigin:4.2-devfrom
ck89119:issue-28028-4.2-dev
Sep 3, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:4.2-devfrom
ck89119:issue-28028-4.2-dev

Conversation

@ck89119

@ck89119 ck89119 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:

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; [Bug]: LOAD DATA fails on transient COS multipart-init idle-connection close without safe recovery #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.

@ck89119 ck89119 changed the title [4.2] fix(fileservice): recover ambiguous COS multipart init [4.2] fix(fileservice): safely retry COS multipart init Sep 3, 2026
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/L Denotes a PR that changes [500,999] lines labels Sep 3, 2026
@ck89119
ck89119 marked this pull request as ready for review September 3, 2026 06:24
@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 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.

Blocking correctness issue:

  • pkg/fileservice/qcloud_sdk.go:411 treats an attempt as commit-ambiguous only when response == nil && wroteRequest. A non-nil response does not prove that multipart initialization failed. The COS SDK returns a non-nil *Response as 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.UploadID is then empty, and IsRetryableError classifies 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 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.

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.

Comment thread pkg/fileservice/qcloud_sdk.go Resolved

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

@XuPeng-SH
XuPeng-SH merged commit 4f62825 into matrixorigin:4.2-dev Sep 3, 2026
27 checks passed
@ck89119
ck89119 deleted the issue-28028-4.2-dev branch September 3, 2026 16:27
XuPeng-SH pushed a commit that referenced this pull request Sep 4, 2026
…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>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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>

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.

4 participants