From 64899e51976ebc0ada4fd6e53322f7f3c8cc5064 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Thu, 30 Jun 2016 16:28:01 -0700 Subject: [PATCH] xl: Used unique tmp file to update xl.json in putObjectPart (#2043) An in-place update to xl.json amidst concurrent PutObjectPart operations lead to racy updates to xl.json making it un-parseable. To avoid this, we create a unique tmp file where updates to xl.json are staged before renaming it to the final location. --- xl-v1-multipart.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xl-v1-multipart.go b/xl-v1-multipart.go index 707c931f4..ba462b625 100644 --- a/xl-v1-multipart.go +++ b/xl-v1-multipart.go @@ -393,14 +393,15 @@ func (xl xlObjects) putObjectPart(bucket string, object string, uploadID string, } // Write all the checksum metadata. - tempUploadIDPath := path.Join(tmpMetaPrefix, uploadID) + newUUID := getUUID() + tempXLMetaPath := path.Join(tmpMetaPrefix, newUUID) // Writes a unique `xl.json` each disk carrying new checksum // related information. - if err = xl.writeUniqueXLMetadata(minioMetaBucket, tempUploadIDPath, partsMetadata); err != nil { - return "", toObjectErr(err, minioMetaBucket, tempUploadIDPath) + if err = xl.writeUniqueXLMetadata(minioMetaBucket, tempXLMetaPath, partsMetadata); err != nil { + return "", toObjectErr(err, minioMetaBucket, tempXLMetaPath) } - rErr := xl.commitXLMetadata(tempUploadIDPath, uploadIDPath) + rErr := xl.commitXLMetadata(tempXLMetaPath, uploadIDPath) if rErr != nil { return "", toObjectErr(rErr, minioMetaBucket, uploadIDPath) }