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. 20
      cmd/metacache-server-sets.go
  2. 16
      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
} }
logger.LogIf(ctx, err) if !errors.Is(err, context.DeadlineExceeded) {
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.
// Update master cache with that information. go func() {
cache.status = scanStateSuccess // Update master cache with that information.
cache.fileNotFound = true cache.status = scanStateSuccess
_, err := o.updateMetacacheListing(cache, globalNotificationSys.restClientFromHash(o.Bucket)) cache.fileNotFound = true
logger.LogIf(ctx, err) o.updateMetacacheListing(cache, globalNotificationSys.restClientFromHash(o.Bucket))
}()
// 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 {
metaMu.Lock() go func(err string) {
if meta.status != scanStateError { metaMu.Lock()
meta.error = err.Error() if meta.status != scanStateError {
meta.status = scanStateError meta.error = err
} meta.status = scanStateError
meta, _ = o.updateMetacacheListing(meta, rpc) }
metaMu.Unlock() meta, _ = o.updateMetacacheListing(meta, rpc)
metaMu.Unlock()
}(err.Error())
cancel() cancel()
} }
}() }()

Loading…
Cancel
Save