Save listing error async (#10922)

Since the RPC call may have to time out save an error state async 
to not hold up the listing returning.

Fixes #10919
master
Klaus Post 4 years ago committed by GitHub
parent d1b1fee080
commit e413f05397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      cmd/metacache-server-sets.go
  2. 4
      cmd/metacache-set.go

@ -22,6 +22,7 @@ import (
"io" "io"
"path" "path"
"sync" "sync"
"time"
"github.com/minio/minio/cmd/logger" "github.com/minio/minio/cmd/logger"
) )
@ -103,14 +104,18 @@ func (z *erasureServerSets) listPath(ctx context.Context, o listPathOptions) (en
// Local // Local
cache = localMetacacheMgr.findCache(ctx, o) cache = localMetacacheMgr.findCache(ctx, o)
} else { } else {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
c, err := rpc.GetMetacacheListing(ctx, o) c, err := rpc.GetMetacacheListing(ctx, o)
if err != nil { if err != nil {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { if errors.Is(err, context.Canceled) {
// Context is canceled, return at once. // Context is canceled, return at once.
// request canceled, no entries to return // request canceled, no entries to return
return entries, io.EOF return entries, io.EOF
} }
if !errors.Is(err, context.DeadlineExceeded) {
logger.LogIf(ctx, err) logger.LogIf(ctx, err)
}
o.Transient = true o.Transient = true
cache = localMetacacheMgr.findCache(ctx, o) cache = localMetacacheMgr.findCache(ctx, o)
} else { } else {
@ -176,11 +181,12 @@ func (z *erasureServerSets) listPath(ctx context.Context, o listPathOptions) (en
if isAllNotFound(errs) { if isAllNotFound(errs) {
// All sets returned not found. // All sets returned not found.
go func() {
// Update master cache with that information. // Update master cache with that information.
cache.status = scanStateSuccess cache.status = scanStateSuccess
cache.fileNotFound = true cache.fileNotFound = true
_, err := o.updateMetacacheListing(cache, globalNotificationSys.restClientFromHash(o.Bucket)) o.updateMetacacheListing(cache, globalNotificationSys.restClientFromHash(o.Bucket))
logger.LogIf(ctx, err) }()
// cache returned not found, entries truncated. // cache returned not found, entries truncated.
return entries, io.EOF return entries, io.EOF
} }

@ -560,13 +560,15 @@ func (er *erasureObjects) listPath(ctx context.Context, o listPathOptions) (entr
console.Println("listPath returning:", entries.len(), "err:", err) console.Println("listPath returning:", entries.len(), "err:", err)
} }
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
go func(err string) {
metaMu.Lock() metaMu.Lock()
if meta.status != scanStateError { if meta.status != scanStateError {
meta.error = err.Error() meta.error = err
meta.status = scanStateError meta.status = scanStateError
} }
meta, _ = o.updateMetacacheListing(meta, rpc) meta, _ = o.updateMetacacheListing(meta, rpc)
metaMu.Unlock() metaMu.Unlock()
}(err.Error())
cancel() cancel()
} }
}() }()

Loading…
Cancel
Save