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.
master
Krishnan Parthasarathi 9 years ago committed by Harshavardhana
parent 812554087f
commit 64899e5197
  1. 9
      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)
}

Loading…
Cancel
Save