From aa8450a2a1c6c8267b63d71060374ff60adac5c5 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 16 Feb 2021 19:36:15 -0800 Subject: [PATCH] fix: parallelize getPoolIdx() for object lookup (#11547) --- cmd/erasure-object.go | 2 +- cmd/erasure-server-pool.go | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index fb9aee6c7..2c77e39c1 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -458,7 +458,7 @@ func (er erasureObjects) getObjectInfo(ctx context.Context, bucket, object strin objInfo.StorageClass = sc } } - if !fi.VersionPurgeStatus.Empty() { + if !fi.VersionPurgeStatus.Empty() && opts.VersionID != "" { // Make sure to return object info to provide extra information. return objInfo, toObjectErr(errMethodNotAllowed, bucket, object) } diff --git a/cmd/erasure-server-pool.go b/cmd/erasure-server-pool.go index cb95e4dc2..3d6b3bc68 100644 --- a/cmd/erasure-server-pool.go +++ b/cmd/erasure-server-pool.go @@ -250,15 +250,28 @@ func (z *erasureServerPools) getPoolIdx(ctx context.Context, bucket, object stri if z.SinglePool() { 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 { - 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) { return -1, err } if isErrObjectNotFound(err) { // No object exists or its a delete marker, // check objInfo to confirm. - if objInfo.DeleteMarker && objInfo.Name != "" { + if objInfos[i].DeleteMarker && objInfos[i].Name != "" { return i, nil } // objInfo is not valid, truly the object doesn't