From bfc36aed8964ba2c5f9e2a020f3e1030615433c9 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Wed, 28 Oct 2020 13:19:53 -0700 Subject: [PATCH] Add update retry limit and compare error by string instead (#10776) --- cmd/metacache-server-sets.go | 2 +- cmd/metacache-set.go | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/metacache-server-sets.go b/cmd/metacache-server-sets.go index 4c03057e7..288869f65 100644 --- a/cmd/metacache-server-sets.go +++ b/cmd/metacache-server-sets.go @@ -197,7 +197,7 @@ func (z *erasureServerSets) listPath(ctx context.Context, o listPathOptions) (en allAtEOF = false continue } - if err == io.EOF { + if err.Error() == io.EOF.Error() { continue } logger.LogIf(ctx, err) diff --git a/cmd/metacache-set.go b/cmd/metacache-set.go index 21692c4a2..7de2f9c80 100644 --- a/cmd/metacache-set.go +++ b/cmd/metacache-set.go @@ -319,7 +319,7 @@ func (r *metacacheReader) filter(o listPathOptions) (entries metaCacheEntriesSor entries.o = append(entries.o, entry) return entries.len() < o.Limit }) - if err == io.EOF || pastPrefix || r.nextEOF() { + if (err != nil && err.Error() == io.EOF.Error()) || pastPrefix || r.nextEOF() { return entries, io.EOF } return entries, err @@ -632,6 +632,9 @@ func (er *erasureObjects) listPath(ctx context.Context, o listPathOptions) (entr } }() + const retryDelay = 200 * time.Millisecond + const maxTries = 10 + // Write results to disk. bw := newMetacacheBlockWriter(cacheCh, func(b *metacacheBlock) error { if debugPrint { @@ -654,13 +657,24 @@ func (er *erasureObjects) listPath(ctx context.Context, o listPathOptions) (entr return nil } // Update block 0 metadata. + var retries int for { err := er.updateObjectMeta(ctx, minioMetaBucket, o.objectPath(0), b.headerKV(), ObjectOptions{}) if err == nil { break } - logger.LogIf(ctx, err) - time.Sleep(100 * time.Millisecond) + switch err.(type) { + case ObjectNotFound: + return err + case InsufficientReadQuorum: + default: + logger.LogIf(ctx, err) + } + if retries >= maxTries { + return err + } + retries++ + time.Sleep(retryDelay) } return nil })