From afd2ba9a6664bb2e2e875959b29aa4afd5f4df5b Mon Sep 17 00:00:00 2001 From: Ekaterina Lebedeva Date: Tue, 30 Jan 2024 08:39:34 +0300 Subject: [PATCH] [#110] Add check for repeated error log in policer processObject() returns 3 types of errors: container not found errors, could not get container error and placement vector building error. Every error will occur for all objects in container simultaneously, so we can log each error once and safely ignore the rest. Signed-off-by: Ekaterina Lebedeva --- pkg/services/policer/process.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/services/policer/process.go b/pkg/services/policer/process.go index c4c820200..df4f0c4c7 100644 --- a/pkg/services/policer/process.go +++ b/pkg/services/policer/process.go @@ -7,6 +7,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine" + cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" "go.uber.org/zap" ) @@ -34,6 +35,9 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) { p.log.Warn(logs.PolicerFailureAtObjectSelectForReplication, zap.Error(err)) } + // contains all errors logged in this iteration for each container + cnrErrSkip := make(map[cid.ID][]error) + for i := range addrs { select { case <-ctx.Done(): @@ -55,10 +59,12 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) { if p.objsInWork.add(addr.Address) { err := p.processObject(ctx, addr) - if err != nil { + if err != nil && !skipLog(cnrErrSkip[addr.Address.Container()], err) { p.log.Error(logs.PolicerUnableToProcessObj, zap.Stringer("object", addr.Address), zap.String("error", err.Error())) + + cnrErrSkip[addr.Address.Container()] = append(cnrErrSkip[addr.Address.Container()], err) } p.cache.Add(addr.Address, time.Now()) p.objsInWork.remove(addr.Address) @@ -72,3 +78,12 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) { } } } + +func skipLog(errs []error, err error) bool { + for _, e := range errs { + if errors.Is(err, e) { + return true + } + } + return false +}