From 5d23be6242b013cf8264a88524b48045714dadb7 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 17 Jun 2022 08:23:47 -0700 Subject: [PATCH] fix: ignore printing io.EOF during WalkDir() on concurrently modified objects (#15100) fix: ignore print io.EOF during WalkDir() on concurrently modified objects --- cmd/metacache-walk.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/metacache-walk.go b/cmd/metacache-walk.go index 164867693..382f290b7 100644 --- a/cmd/metacache-walk.go +++ b/cmd/metacache-walk.go @@ -182,7 +182,12 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ s.walkReadMu.Unlock() diskHealthCheckOK(ctx, err) if err != nil { - logger.LogIf(ctx, err) + // It is totally possible that xl.meta was overwritten + // while being concurrently listed at the same time in + // such scenarios the 'xl.meta' might get truncated + if !IsErrIgnored(err, io.EOF, io.ErrUnexpectedEOF) { + logger.LogIf(ctx, err) + } continue } meta.name = strings.TrimSuffix(entry, xlStorageFormatFile) @@ -200,7 +205,9 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ s.walkReadMu.Unlock() diskHealthCheckOK(ctx, err) if err != nil { - logger.LogIf(ctx, err) + if !IsErrIgnored(err, io.EOF, io.ErrUnexpectedEOF) { + logger.LogIf(ctx, err) + } continue } meta.name = strings.TrimSuffix(entry, xlStorageFormatFileV1) @@ -245,7 +252,11 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ if len(opts.ForwardTo) > 0 && strings.HasPrefix(opts.ForwardTo, pop) { forward = strings.TrimPrefix(opts.ForwardTo, pop) } - logger.LogIf(ctx, scanDir(pop)) + + err := scanDir(pop) + if err != nil && !IsErrIgnored(err, context.Canceled) { + logger.LogIf(ctx, err) + } } dirStack = dirStack[:len(dirStack)-1] }