Repository navigation
Description
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.
- Adds new StorageDriver.FileWriter interface #1438 first routed PutContent through the chunked AppendBlob writer, which introduced the race.
- azure: concurrent writes result in 404s or corrupted blobs #2077 reported the race and azure: fix race condition in PutContent() #2088 fixed it by uploading a single atomic "Put Blob" as a BlockBlob, deleting and migrating any pre-existing AppendBlob exactly once
- Azure driver retry fix #4576 silently reverted PutContent back to // Always create as AppendBlob plus an AppendBlock loop, re-introducing the 2016 race. I think this was a mistake when copying the code from Gitlab's container-registry as the gitlab MR did not change the code of PutContent, hence keeping the BlockBlob semantic
- recently, Release notes for v2.6.0-rc1 #2059 corrected an inverted blob-type migration check but kept the AppendBlob write path, so the underlying race remains.
Reproduce
Since this is a race condition, the bug is a bit hard to trigger reliably, the gist of it is:
- Run a registry built from current main configured with the azure storage driver.
- 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
- 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
milosgajdos commentedon Jun 5, 2026
Patch away
Fricounet commentedon Jun 5, 2026
Thanks, opened #4888