Skip to content

Cancel the SDK upload when CreateObject input reading fails #5259

In review

Description

@singh4jitendra

CreateObject returns immediately when copying from its input reader fails. If the SDK writer has already been opened, it can remain active because that path neither closes nor cancels it. Closing it normally would be wrong because that could finalize a partial object.

I plan to give this single-object upload an owned child context and always cancel it on return. A small buffered-write regression verifies that a source error cancels the SDK writer, preserves the original error, leaves the caller context active, and does not publish the partial object. It passes 20 race-enabled repetitions and the existing bucket-adapter tests.

This is the existing CreateObject adapter, not the new unbuffered handler or its Abort work in #5232. No live GCS data or credentials are used by the regression.

Activity

  1. vipnydav commented on Nov 29, 2026

    @vipnydav
    Member

    Hi @vadlakondaswetha, Currently for staging writes we do not create a separate context for the Go SDK writer, hence we cannot cancel it if io.Copy fails mid-upload, which leaks writer resources. Creating a child context and canceling it on return looks good to me. PTAL!

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions