distribution/registry/storage
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
..
cache Satisfy the latest go lint rules 2016-10-14 17:03:08 -07:00
driver azure: fix race condition in PutContent() 2016-11-30 12:40:43 -08:00
blob_test.go Merge pull request #1706 from aibaars/registry-size-close 2016-06-13 16:29:35 -07:00
blobcachemetrics.go Open cache interface 2015-05-15 17:56:28 -07:00
blobserver.go Serve blobs when a storage driver supports redirects but are disabled 2015-12-28 11:08:39 -08:00
blobstore.go registry: avoid formatting errors with %#v 2016-07-01 11:30:58 -03:00
blobwriter.go If resumable digest support is disabled, detct this when closing the blobwriter 2016-06-13 17:35:06 -07:00
blobwriter_nonresumable.go If resumable digest support is disabled, detct this when closing the blobwriter 2016-06-13 17:35:06 -07:00
blobwriter_resumable.go Adds new storagedriver.FileWriter interface 2016-03-08 16:37:44 -08:00
catalog.go Improve catalog enumerate runtime by an order of magnitude 2016-08-09 17:42:26 -07:00
catalog_test.go Satisfy the latest go lint rules 2016-10-14 17:03:08 -07:00
doc.go Move storage package under registry package 2015-02-11 12:43:04 -08:00
filereader.go Adds new storagedriver.FileWriter interface 2016-03-08 16:37:44 -08:00
filereader_test.go testutil, storage: use math/rand.Read where possible 2016-08-10 14:26:12 -07:00
garbagecollect.go Remove newlines from end of error strings 2016-11-14 14:03:01 -08:00
garbagecollect_test.go Fix unit test 2016-10-10 11:37:30 +08:00
linkedblobstore.go Provide stat descriptor for Create method during cross-repo mount (#1857) 2016-08-01 19:07:11 -07:00
linkedblobstore_test.go Provide stat descriptor for Create method during cross-repo mount (#1857) 2016-08-01 19:07:11 -07:00
manifestlisthandler.go Decouple storage components by redefining dependencies as interfaces instead of concrete types 2016-07-20 15:09:11 -07:00
manifeststore.go fix typos 2016-06-22 12:40:21 +08:00
manifeststore_test.go Remove signature store from registry. Return a generated signature for manifest 2016-05-27 13:19:26 -07:00
paths.go Remove signature store from registry. Return a generated signature for manifest 2016-05-27 13:19:26 -07:00
paths_test.go Remove signature store from registry. Return a generated signature for manifest 2016-05-27 13:19:26 -07:00
purgeuploads.go Remove pathMapper object 2015-08-17 18:51:05 -07:00
purgeuploads_test.go Remove pathMapper object 2015-08-17 18:51:05 -07:00
registry.go Fix the build. 2016-07-21 17:16:47 -07:00
schema2manifesthandler.go manifest: references should cover all children 2016-10-18 11:43:33 -07:00
schema2manifesthandler_test.go manifest: references should cover all children 2016-10-18 11:43:33 -07:00
signedmanifesthandler.go Decouple storage components by redefining dependencies as interfaces instead of concrete types 2016-07-20 15:09:11 -07:00
tagstore.go Rename Name method of Repository to Named 2016-02-04 09:55:36 -08:00
tagstore_test.go compare error output in tagstore unit test 2016-02-22 17:34:22 +08:00
util.go Refactor Blob Service API 2015-05-15 17:05:18 -07:00
vacuum.go Implements garbage collection subcommand 2016-02-29 14:15:21 -08:00
walk.go storage: enforce sorted traversal during Walk 2015-12-01 16:25:30 -08:00
walk_test.go Fix some typos in comments and strings 2016-02-23 22:33:38 +01:00