From 46dab77705f230a12a0293942fc3911adfbc1c20 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 23 Nov 2020 15:23:32 +0300 Subject: [PATCH] [#195] services/object: Write debug log messages on worker pool errors Signed-off-by: Leonard Lyubich --- pkg/services/object/head/distributed.go | 4 +++- pkg/services/object/put/distributed.go | 4 +++- pkg/services/object/range/streamer.go | 4 +++- pkg/services/object/rangehash/distributed.go | 4 +++- pkg/services/object/search/streamer.go | 10 ++++++---- pkg/services/object/util/log.go | 8 ++++++++ 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/pkg/services/object/head/distributed.go b/pkg/services/object/head/distributed.go index 7922490fd..dbff3eaa3 100644 --- a/pkg/services/object/head/distributed.go +++ b/pkg/services/object/head/distributed.go @@ -125,7 +125,9 @@ loop: h.w.write(head) }); err != nil { wg.Done() - // TODO: log error + + svcutil.LogWorkerPoolError(h.log, "HEAD", err) + break loop } } diff --git a/pkg/services/object/put/distributed.go b/pkg/services/object/put/distributed.go index c53401fe8..f20885e1d 100644 --- a/pkg/services/object/put/distributed.go +++ b/pkg/services/object/put/distributed.go @@ -103,7 +103,9 @@ loop: traverser.SubmitSuccess() }); err != nil { wg.Done() - // TODO: log error + + svcutil.LogWorkerPoolError(t.log, "PUT", err) + break loop } } diff --git a/pkg/services/object/range/streamer.go b/pkg/services/object/range/streamer.go index 02b202d61..1d557877a 100644 --- a/pkg/services/object/range/streamer.go +++ b/pkg/services/object/range/streamer.go @@ -205,7 +205,9 @@ loop: nextRange.SetOffset(nextRange.GetOffset() + uw) }); err != nil { wg.Done() - // TODO: log error + + svcutil.LogWorkerPoolError(p.log, "RANGE", err) + break loop } diff --git a/pkg/services/object/rangehash/distributed.go b/pkg/services/object/rangehash/distributed.go index f74eac57c..e4171680e 100644 --- a/pkg/services/object/rangehash/distributed.go +++ b/pkg/services/object/rangehash/distributed.go @@ -125,7 +125,9 @@ loop: } }); err != nil { wg.Done() - // TODO: log error + + svcutil.LogWorkerPoolError(h.log, "RANGEHASH", err) + break loop } } diff --git a/pkg/services/object/search/streamer.go b/pkg/services/object/search/streamer.go index fb3d288e7..7be5bdee2 100644 --- a/pkg/services/object/search/streamer.go +++ b/pkg/services/object/search/streamer.go @@ -8,7 +8,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/network" - "github.com/nspcc-dev/neofs-node/pkg/services/object/util" + svcutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/pkg/errors" ) @@ -113,7 +113,7 @@ func (p *Streamer) preparePrm(prm *Prm) error { traverseOpts = append(traverseOpts, placement.SuccessAfter(1)) // use local-only placement builder - builder = util.NewLocalPlacement(builder, p.localAddrSrc) + builder = svcutil.NewLocalPlacement(builder, p.localAddrSrc) } // set placement builder @@ -169,11 +169,13 @@ loop: } if err := streamer.stream(p.ctx, p.ch); err != nil { - util.LogServiceError(p.log, "SEARCH", addr, err) + svcutil.LogServiceError(p.log, "SEARCH", addr, err) } }); err != nil { wg.Done() - // TODO: log error + + svcutil.LogWorkerPoolError(p.log, "SEARCH", err) + break loop } } diff --git a/pkg/services/object/util/log.go b/pkg/services/object/util/log.go index 1ea5bbbc2..e01503b38 100644 --- a/pkg/services/object/util/log.go +++ b/pkg/services/object/util/log.go @@ -14,3 +14,11 @@ func LogServiceError(l *logger.Logger, req string, node *network.Address, err er zap.String("error", err.Error()), ) } + +// LogWorkerPoolError writes debug error message of object worker pool to provided logger. +func LogWorkerPoolError(l *logger.Logger, req string, err error) { + l.Debug("could not push task to worker pool", + zap.String("request", req), + zap.String("error", err.Error()), + ) +}