Skip to content

azure: PutContent creates AppendBlobs, reintroducing concurrent/retry duplicate-append race #4887

Closed

Description

@Fricounet

Description

The Azure storage driver's PutContent writes content using an AppendBlob (NewAppendBlobClient(...).Create followed by an AppendBlock loop). Because AppendBlock is not idempotent, any retry or concurrent write to the same path appends content again instead of overwriting it, producing a corrupted/duplicated blob. This affects the small metadata objects PutContent is used for (link files, etc.), where the correct semantics are atomic whole-object overwrite.

I think this is a regression: the project already fixed this exact race in 2016.

Reproduce

Since this is a race condition, the bug is a bit hard to trigger reliably, the gist of it is:

  1. Run a registry built from current main configured with the azure storage driver.
  2. Issue two concurrent writes to the same path via PutContent. One way I use to do it is to have the registry configured in proxy mode and have 2 different clients pull a missing blob on 2 different distribution instances so that they both attempt to replicate the missing blobs at the same time
  3. Read the blob back.

Observed: in my case, the link files contained duplicated/concatenated content rather than a single copy. The blob is an AppendBlob whose length is a multiple of the intended content. For instance the link file would have the following content:

cat /tmp/link.bin
sha256:b708172ade643851b2b21c7b543bee28f732fd76d68e550b9dab16eb007ae4c0sha256:b708172ade643851b2b21c7b543bee28f732fd76d68e550b9dab16eb007ae4c0

Expected behavior

PutContent writes are atomic whole-object overwrites: concurrent writers or retries result in exactly one copy of the content (last-writer-wins), never duplicated/appended data. This is what the BlockBlob "Put Blob" operation provides, matching the behavior restored by 78d0660 before the v2 rewrite.

registry version

v3.1.1

Additional Info

I have a patch for the issue that I'd be very happy to submit DataDog#6

Activity

  1. milosgajdos commented on Jun 5, 2026

    @milosgajdos
    Member

    Patch away

  2. Fricounet commented on Jun 5, 2026

    @Fricounet
    ContributorAuthor

    Thanks, opened #4888

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

Metadata

Metadata

Assignees

No one assigned

    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