Repository navigation
fix: retry QCloud PUT with seekable reader - #24917
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.
I found one high-confidence correctness issue here. The new non-seekable large-write fallback routes known-size streams into WriteMultipartParallel, but that path no longer preserves the original sizeHint contract when the reader ends early: an empty reader can now succeed with no upload, and a short reader can be rewritten to the shorter actual size and uploaded successfully. Before this PR, the putObject path passed ContentLength=sizeHint and could surface truncated bodies as a size-mismatch error. This means a truncated known-size stream can now turn into a silent short write, which is a real blocker. Also, the added retry test uses bytes.NewReader, which is already seekable and already retried by the COS SDK itself, so it does not prove the new wrapper logic.
b1dfe9a to
c1d47a0
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
I re-checked the latest update. The earlier sizeHint/truncation issue is fixed now, but I still see one substantive problem in the current version. The new seekable PUT retry path in pkg/fileservice/qcloud_sdk.go wraps putObject in MatrixOne's outer DoWithRetry, but the COS SDK still has its own built-in retry for seekable Put requests enabled by default. In production that means one transient failure is retried twice: once by the COS SDK itself, and then again by MatrixOne's outer loop. That multiplies request count and can stretch failure latency significantly. The strongest evidence is in the new test itself: it explicitly sets client.Conf.RetryOpt.Count = 0 before exercising the new logic, which avoids the production configuration. In the actual constructor path, NewQCloudSDK does not disable the SDK retry, and the COS SDK default is still RetryOpt.Count = 3. I think this should be resolved before approval: either disable the COS SDK retry for this PUT path when using the outer retry wrapper, or remove the outer retry and rely on the SDK's existing seekable-body retry behavior.
The COS SDK enables retry by default (RetryOpt.Count = 3). MatrixOne wraps all operations in its own DoWithRetry, so one transient failure was retried twice — first by the SDK and then by MatrixOne's outer loop — multiplying request count and stretching failure latency. Set client.Conf.RetryOpt.Count = 0 in NewQCloudSDK so only MatrixOne's DoWithRetry handles retries. Co-Authored-By: Claude Fable 5 <[email protected]>
XuPeng-SH
left a comment
There was a problem hiding this comment.
I re-checked the latest update. The previous retry-layering issue is fixed now: the PR correctly disables COS SDK built-in retry so the new seekable PUT retry path no longer stacks two retry systems. However, that global change introduces a new issue: client.Conf.RetryOpt.Count = 0 disables COS retries for the entire client, including paths that are not wrapped in MatrixOne's DoWithRetry. In particular: client.Bucket.Head during initialization and AbortMultipartUpload during multipart cleanup. Both are still direct SDK calls, so with this patch they become single-shot network operations. A transient COS failure can now fail service startup or cause multipart abort cleanup to be dropped, even though those paths previously had the SDK's default retries. I think the fix should be scoped more narrowly: disable SDK retries only for the raw PUT path that now has an outer retry wrapper, or add explicit DoWithRetry around the other unwrapped COS operations.
client.Conf.RetryOpt.Count = 0 disables COS SDK built-in retries globally, but two direct SDK calls were not wrapped in MatrixOne's DoWithRetry: - client.Bucket.Head during NewQCloudSDK initialization - AbortMultipartUpload during WriteMultipartParallel error cleanup Both are now wrapped so transient COS failures won't fail startup or drop cleanup. Co-Authored-By: Claude Fable 5 <[email protected]>
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the fileservice changes with a focus on retry semantics, size-mismatch handling, and multipart cleanup on unhappy paths. I do not see a blocking correctness issue in the seekable PUT retry flow, the non-seekable multipart fallback, or the abort-on-error handling, so this looks good to merge.
Merge Queue Status
This pull request spent 1 hour 4 minutes 15 seconds in the queue, including 1 hour 3 minutes 55 seconds running CI. Required conditions to merge
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Follow-up after a deeper unhappy-path pass: I found two blocking issues.
-
pkg/fileservice/qcloud_sdk.go:112disables the COS SDK retry loop, butIsRetryableErrorstill does not treat COS HTTP 5xx responses as retryable. That drops existing retry coverage for body-less operations likeBucket.Head,Object.Head, list/delete, and multipart init, so transient 503/500 responses now fail immediately. -
pkg/fileservice/io.go:64-69letsexactSizeReaderreturn(0, nil)whenExpected == 0and the wrapped reader returns(0, nil). Callers that useio.ReadFull/ReadAtLeastcan spin instead of getting EOF. This should normalize toio.EOFonce the expected byte count is exhausted.
What type of PR is this?
Which issue(s) does this PR fix or relate to?
Fixes #24916
What this PR does / why we need it:
connection reset by peerafter the first body readFixes #24916
Tests
go test ./pkg/fileservice -run '^TestQCloudSDKWriteRetriesSeekablePut$' -count=1 -v\n-go test ./pkg/fileservice -run 'TestQCloudSDKWriteRetriesSeekablePut|TestCOSParallelMultipart'\n\nNote:go test ./pkg/fileservicecurrently fails locally inTestMinioSDK/file_service/basicwithAccess Denied.fromlocalhost:9007, unrelated to this QCloud change.