Improve multipart listing speed (#18307)

This commit is contained in:
Klaus Post 2023-10-24 12:06:06 -07:00 committed by GitHub
parent 74253e1ddc
commit 6415dec37a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -309,20 +309,21 @@ func (er erasureObjects) ListMultipartUploads(ctx context.Context, bucket, objec
if populatedUploadIds.Contains(uploadID) { if populatedUploadIds.Contains(uploadID) {
continue continue
} }
fi, err := disk.ReadVersion(ctx, minioMetaMultipartBucket, pathJoin(er.getUploadIDDir(bucket, object, uploadID)), "", false) // If present, use time stored in ID.
if err != nil { startTime := time.Now()
if !IsErrIgnored(err, errFileNotFound, errDiskNotFound) { if split := strings.Split(uploadID, "x"); len(split) == 2 {
logger.LogIf(ctx, err) t, err := strconv.ParseInt(split[1], 10, 64)
if err == nil {
startTime = time.Unix(0, t)
} }
// Ignore this invalid upload-id since we are listing here
continue
} }
populatedUploadIds.Add(uploadID)
uploads = append(uploads, MultipartInfo{ uploads = append(uploads, MultipartInfo{
Bucket: bucket,
Object: object, Object: object,
UploadID: base64.RawURLEncoding.EncodeToString([]byte(fmt.Sprintf("%s.%s", globalDeploymentID(), uploadID))), UploadID: base64.RawURLEncoding.EncodeToString([]byte(fmt.Sprintf("%s.%s", globalDeploymentID(), uploadID))),
Initiated: fi.ModTime, Initiated: startTime,
}) })
} }
sort.Slice(uploads, func(i int, j int) bool { sort.Slice(uploads, func(i int, j int) bool {
@ -635,7 +636,8 @@ func (er erasureObjects) PutObjectPart(ctx context.Context, bucket, object, uplo
// accommodate concurrent PutObjectPart requests // accommodate concurrent PutObjectPart requests
partSuffix := fmt.Sprintf("part.%d", partID) partSuffix := fmt.Sprintf("part.%d", partID)
tmpPart := mustGetUUID() // Random UUID and timestamp for temporary part file.
tmpPart := fmt.Sprintf("%sx%d", mustGetUUID(), time.Now().UnixNano())
tmpPartPath := pathJoin(tmpPart, partSuffix) tmpPartPath := pathJoin(tmpPart, partSuffix)
// Delete the temporary object part. If PutObjectPart succeeds there would be nothing to delete. // Delete the temporary object part. If PutObjectPart succeeds there would be nothing to delete.