From bca7cf94709a1191c81d6eecc3568de0db66d43e Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Mon, 20 Dec 2021 11:36:24 +0300 Subject: [PATCH] [#1047] policer: Check context before job selection When application is being terminated, replicator routine might be on the object picking phase. Storage is terminated asynchronously, thus `Select()` may return corresponding error. If we don't process `context.Done()` in this case, then application freezes on shutdown. Signed-off-by: Alex Vanin --- pkg/services/policer/process.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/services/policer/process.go b/pkg/services/policer/process.go index 1f35630fd..c48f6064c 100644 --- a/pkg/services/policer/process.go +++ b/pkg/services/policer/process.go @@ -27,6 +27,12 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) { ) for { + select { + case <-ctx.Done(): + return + default: + } + addrs, cursor, err = p.jobQueue.Select(cursor, p.batchSize) if err != nil { if errors.Is(err, engine.ErrEndOfListing) {