distribution/registry/storage/driver
Ahmet Alp Balkan 78d0660319
azure: fix race condition in PutContent()
See #2077 for background.

The PR #1438 which was not reviewed by azure folks basically introduced
a race condition around uploads to the same blob by multiple clients
concurrently as it used the "writer" type for PutContent(), introduced in #1438.
This does chunked upload of blobs using "AppendBlob" type, which was not atomic.

Usage of "writer" type and thus AppendBlobs on metadata files is currently not
concurrency-safe and generally, they are not the right type of blob for the job.

This patch fixes PutContent() to use the atomic upload operation that works
for uploads smaller than 64 MB and creates blobs with "BlockBlob" type. To be
backwards compatible, we query the type of the blob first and if it is not
a "BlockBlob" we delete the blob first before doing an atomic PUT. This
creates a small inconsistency/race window "only once". Once the blob is made
"BlockBlob", it is overwritten with a single PUT atomicallly next time.

Therefore, going forward, PutContent() will be producing BlockBlobs and it
will silently migrate the AppendBlobs introduced in #1438 to BlockBlobs with
this patch.

Tested with existing code side by side, both registries with and without this
patch work fine without breaking each other. So this should be good from a
backwards/forward compatiblity perspective, with a cost of doing an extra
HEAD checking the blob type.

Fixes #2077.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
2016-11-30 12:40:43 -08:00
..
azure azure: fix race condition in PutContent() 2016-11-30 12:40:43 -08:00
base Implement regulator in filesystem driver 2016-05-03 09:33:22 -07:00
factory Add documentation for how to register new StorageDrivers 2016-03-29 14:42:19 -07:00
filesystem Don't wrap thead limits when using a negative int 2016-05-03 16:03:44 -07:00
gcs StorageDriver: GCS: allow Cancel on a closed FileWriter 2016-05-06 13:04:30 +01:00
inmemory Adds new storagedriver.FileWriter interface 2016-03-08 16:37:44 -08:00
middleware fix typos 2016-06-02 23:03:27 +08:00
oss oss native large file copy consume too much time which will eventually lead to client timeout because of no data transmit throughout native copy. change maxCopySize to 128MB, ensure only sm all medium size file use oss native copy to avoid connection reset by peer. And fix Move function with CopyLargeFileInParallel to optimize oss upload copy 2016-11-08 12:14:13 +08:00
s3-aws fixup! v2 signer: correctly sort headers 2016-11-02 17:07:02 +01:00
s3-goamz Fix s3-goamz Delete method's notion of subpaths 2016-10-17 09:43:15 -07:00
swift driver/swift: Fix go vet warning 2016-10-31 11:41:53 -07:00
testdriver StorageDriver: Test case for #1698 2016-05-06 13:04:30 +01:00
testsuites Fix S3 Delete method's notion of subpaths 2016-10-06 11:21:55 -07:00
fileinfo.go Move storagedriver package to registry/storage/driver 2015-02-11 12:43:04 -08:00
storagedriver.go Remove the example 2016-03-29 14:42:28 -07:00