Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
Other Environment Information
- Hardware parameters:
- OS type:
- Others: code inspection of origin/main. No open issue covers a canceled multipart upload returning success.
TestCOSMultipartInitCancellationCleansOwnedUploadalready requirescontext.CanceledandAbortMultipartUploadwhen the context is canceled afterCreateMultipartUploadreturns.
Actual Behavior
AwsSDKv2.WriteMultipartParallel (pkg/fileservice/aws_sdk_v2.go 699–821) and QCloudSDK.WriteMultipartParallel (pkg/fileservice/qcloud_sdk.go 638–760) start each part on a worker. The worker does this before UploadPart:
if ctx.Err() != nil {
releasePartBuffer(job.part)
return
}That return does not call setErr. setErr is what records firstErr and cancels siblings.
startPartUpload selects on a free slot and on ctx.Done(). When the parent context is already canceled, both arms are ready, so the slot arm can win. The worker then takes the silent return above. A parent cancel that arrives after the worker is spawned and before UploadPart does the same.
After wg.Wait, if every submitted part took that path, firstErr is still nil and len(parts) == 0. The function then return nil (aws_sdk_v2.go 798–799, qcloud_sdk.go 738–739). The named err is nil, so the defer does not AbortMultipartUpload. CompleteMultipartUpload is not called. The object is not created.
S3FS.write (s3_fs.go 611–621) treats that nil as a finished upload and returns the number of bytes already pulled from the reader. objectWriterV1.Sync (pkg/objectio/writer.go 743–756) then calls DescribeObject, which builds stats from the local buffer and returns nil. A caller that publishes on Sync's nil error publishes a name whose bytes are not in object storage.
A partial set of completed parts is still rejected by the len(parts) != partNum check, and that error does abort. The hole is only the all-parts-dropped case. Large non-seekable writes reach this function even when parallel mode is off: AwsSDKv2.Write (aws_sdk_v2.go 536–546) sends a non-seeker at or above smallObjectThreshold (64MiB) into WriteMultipartParallel. S3FS.write wraps the body in countingReader / LimitReader, which are not seekers.
TestCOSMultipartInitCancellationCleansOwnedUpload (parallel_sdk_test.go 1180–1198) cancels in the create-multipart response, before sendJob. It expects context.Canceled, aborted, and not completed. That is racy with the select-plus-silent-return path; when the slot arm wins, the test's expected error becomes a nil return and the upload is left open.
Expected Behavior
A canceled part upload should set firstErr to ctx.Err(). len(parts) == 0 after parts were submitted should be an error, not success. The existing abort defer should then abort the upload id. S3FS.write and objectWriterV1.Sync should not publish stats for an object that was never completed.
Steps to Reproduce
The production shape is a >=64MiB object flush whose context is canceled after CreateMultipartUpload returns and before UploadPart runs.
The in-tree test already sets up that window:
go test ./pkg/fileservice/ -run TestCOSMultipartInitCancellationCleansOwnedUpload -count=20- When the slot
selectwins overctx.Done(),WriteMultipartParallelreturns nil,state.abortedstays false, andstate.completedstays false.
A deterministic unit of the same hole is to cancel the parent context inside the create-multipart HTTP response (as that test's transport does) and force the worker to observe ctx.Err() before UploadPart.
Additional information
Empty readers never reach this return. They are handled before CreateMultipartUpload (aws_sdk_v2.go 640–642). This report is the non-empty upload that drops every part and still returns nil.
Activity
slyunnn commentedon Sep 28, 2026
Regression and extended verification for #29267 (2026-09-28)
Verification Environment
origin/maincommit5648ebc15aebd3ed8e57c502495ae85ae5b79542,fix(objectio): bound pooled serialization buffers (#29432).pkg/fileserviceGo/CGo test using the real COS HTTPS API and existing Nightly credentials. This issue is below the SQL and server-process layers, so no MatrixOne service binary was involved in the final reproduction.1 Log service / 1 TN / 2 CN / Proxy; Proxy6001, CN116001, and CN216002were reachable over the MySQL TCP protocol. The actual object-storage regression did not execute through those endpoints.b72087c2d64c45fd10e8e9a00030a200b452de24,fix(fileservice): abort canceled parallel multipart uploads.What Was Covered
UploadPartrequest.context.Canceled, sends exactly one successfulAbortMultipartUpload, sends0part-upload requests, sends0completion requests, and leaves no final object.Concurrency: 1, making the cancellation/worker ownership boundary deterministic.pkg/fileservicesuite: successful multipart completion; reader, part, completion, and initialization cancellation failures; abort cleanup; small-object fallback; and unknown-size multipart input.TestIssue29267RealCOSMultipartWorkerCancellationAbortspassed in0.23s;github.com/matrixorigin/matrixone/pkg/fileservicepassed in0.267s.6001, CN116001, or CN216002executed the regression itself.Findings
The fix records worker-observed cancellation in
firstErr, prevents an emptypartslist from being treated as success, and aborts the multipart upload owned by the failed call. The real COS replay confirms that the affected cancellation window returns an error and cleans up rather than reporting false success.No large-data regression is needed. The relevant boundary is the minimum multipart part plus the cancellation timing, not data volume; increasing object size would not exercise a new state transition.
MOTR / BVT Coverage
No MOTR case was added because SQL cannot deterministically cancel a fileservice multipart worker between initialization and part upload, nor inspect remote
AbortMultipartUploadversus completion. The persistent coverage is mo-nightly-regression#1750, commit4cf90a4d, using the existing Branch Nightly workflow selectorfileservice_real_cos.Final Conclusion
Fixed. The original cancellation race was reproduced against real COS on latest
origin/mainand now returnscontext.Canceled, aborts its owned multipart upload, sends no part/completion request, and publishes no final object.