Skip to content

[Bug]: canceled parallel multipart upload can return success and skip abort #29267

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

66da387

Other Environment Information

  • Hardware parameters:
  • OS type:
  • Others: code inspection of origin/main. No open issue covers a canceled multipart upload returning success. TestCOSMultipartInitCancellationCleansOwnedUpload already requires context.Canceled and AbortMultipartUpload when the context is canceled after CreateMultipartUpload returns.

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:

  1. go test ./pkg/fileservice/ -run TestCOSMultipartInitCancellationCleansOwnedUpload -count=20
  2. When the slot select wins over ctx.Done(), WriteMultipartParallel returns nil, state.aborted stays false, and state.completed stays 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

  1. added
    kind/bug
    on Sep 22, 2026
  2. added theissue type on Sep 23, 2026
  3. added this to the MO-202609 milestone on Sep 23, 2026
  4. added
    severity/s0
    and removed on Sep 24, 2026
  5. assigned and unassigned on Sep 24, 2026
  6. slyunnn commented on Sep 28, 2026

    @slyunnn

    Regression and extended verification for #29267 (2026-09-28)

    Verification Environment

    • MatrixOne target: latest origin/main commit 5648ebc15aebd3ed8e57c502495ae85ae5b79542, fix(objectio): bound pooled serialization buffers (#29432).
    • The final verifier was a direct pkg/fileservice Go/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.
    • Local SQL health topology was 1 Log service / 1 TN / 2 CN / Proxy; Proxy 6001, CN1 16001, and CN2 16002 were reachable over the MySQL TCP protocol. The actual object-storage regression did not execute through those endpoints.
    • Related fix: #29312, b72087c2d64c45fd10e8e9a00030a200b452de24, fix(fileservice): abort canceled parallel multipart uploads.

    What Was Covered

    • OK Original real COS scenario: cancellation occurs after multipart initialization and when the worker has consumed the sole minimum-size part, before any UploadPart request.
    • OK Real COS assertions: the call returns context.Canceled, sends exactly one successful AbortMultipartUpload, sends 0 part-upload requests, sends 0 completion requests, and leaves no final object.
    • OK Boundary: the test uses the minimum multipart part size and Concurrency: 1, making the cancellation/worker ownership boundary deterministic.
    • OK Happy path and broader unhappy-path behavior were covered by the existing deterministic AWS/COS pkg/fileservice suite: successful multipart completion; reader, part, completion, and initialization cancellation failures; abort cleanup; small-object fallback; and unknown-size multipart input.
    • OK The direct cancellation regression was replayed against real COS on the exact target commit: TestIssue29267RealCOSMultipartWorkerCancellationAborts passed in 0.23s; github.com/matrixorigin/matrixone/pkg/fileservice passed in 0.267s.
    • Not covered A live AWS S3 account was not used. AWS and COS share the cancellation/abort contract, and real COS plus deterministic AWS/COS coverage provides the relevant protocol comparison.
    • Not covered This is not a SQL or client-protocol issue; no SQL statement, prepared statement, Proxy 6001, CN1 16001, or CN2 16002 executed the regression itself.

    Findings

    The fix records worker-observed cancellation in firstErr, prevents an empty parts list 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 AbortMultipartUpload versus completion. The persistent coverage is mo-nightly-regression#1750, commit 4cf90a4d, using the existing Branch Nightly workflow selector fileservice_real_cos.

    Final Conclusion

    Fixed. The original cancellation race was reproduced against real COS on latest origin/main and now returns context.Canceled, aborts its owned multipart upload, sends no part/completion request, and publishes no final object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions