fix: parallelize getPoolIdx() for object lookup (#11547)

master
Harshavardhana 4 years ago committed by GitHub
parent 87cce344f6
commit aa8450a2a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cmd/erasure-object.go
  2. 17
      cmd/erasure-server-pool.go

@ -458,7 +458,7 @@ func (er erasureObjects) getObjectInfo(ctx context.Context, bucket, object strin
objInfo.StorageClass = sc objInfo.StorageClass = sc
} }
} }
if !fi.VersionPurgeStatus.Empty() { if !fi.VersionPurgeStatus.Empty() && opts.VersionID != "" {
// Make sure to return object info to provide extra information. // Make sure to return object info to provide extra information.
return objInfo, toObjectErr(errMethodNotAllowed, bucket, object) return objInfo, toObjectErr(errMethodNotAllowed, bucket, object)
} }

@ -250,15 +250,28 @@ func (z *erasureServerPools) getPoolIdx(ctx context.Context, bucket, object stri
if z.SinglePool() { if z.SinglePool() {
return 0, nil return 0, nil
} }
errs := make([]error, len(z.serverPools))
objInfos := make([]ObjectInfo, len(z.serverPools))
var wg sync.WaitGroup
for i, pool := range z.serverPools { for i, pool := range z.serverPools {
objInfo, err := pool.GetObjectInfo(ctx, bucket, object, ObjectOptions{}) wg.Add(1)
go func(i int, pool *erasureSets) {
defer wg.Done()
objInfos[i], errs[i] = pool.GetObjectInfo(ctx, bucket, object, ObjectOptions{})
}(i, pool)
}
wg.Wait()
for i, err := range errs {
if err != nil && !isErrObjectNotFound(err) { if err != nil && !isErrObjectNotFound(err) {
return -1, err return -1, err
} }
if isErrObjectNotFound(err) { if isErrObjectNotFound(err) {
// No object exists or its a delete marker, // No object exists or its a delete marker,
// check objInfo to confirm. // check objInfo to confirm.
if objInfo.DeleteMarker && objInfo.Name != "" { if objInfos[i].DeleteMarker && objInfos[i].Name != "" {
return i, nil return i, nil
} }
// objInfo is not valid, truly the object doesn't // objInfo is not valid, truly the object doesn't

Loading…
Cancel
Save