mirror of
https://github.com/minio/minio.git
synced 2024-12-25 22:55:54 -05:00
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.
This commit is contained in:
parent
812554087f
commit
64899e5197
@ -393,14 +393,15 @@ func (xl xlObjects) putObjectPart(bucket string, object string, uploadID string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write all the checksum metadata.
|
// 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
|
// Writes a unique `xl.json` each disk carrying new checksum
|
||||||
// related information.
|
// related information.
|
||||||
if err = xl.writeUniqueXLMetadata(minioMetaBucket, tempUploadIDPath, partsMetadata); err != nil {
|
if err = xl.writeUniqueXLMetadata(minioMetaBucket, tempXLMetaPath, partsMetadata); err != nil {
|
||||||
return "", toObjectErr(err, minioMetaBucket, tempUploadIDPath)
|
return "", toObjectErr(err, minioMetaBucket, tempXLMetaPath)
|
||||||
}
|
}
|
||||||
rErr := xl.commitXLMetadata(tempUploadIDPath, uploadIDPath)
|
rErr := xl.commitXLMetadata(tempXLMetaPath, uploadIDPath)
|
||||||
if rErr != nil {
|
if rErr != nil {
|
||||||
return "", toObjectErr(rErr, minioMetaBucket, uploadIDPath)
|
return "", toObjectErr(rErr, minioMetaBucket, uploadIDPath)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user