diff --git a/pkg/services/tree/replicator.go b/pkg/services/tree/replicator.go index 8a1180289..bb20310b2 100644 --- a/pkg/services/tree/replicator.go +++ b/pkg/services/tree/replicator.go @@ -52,7 +52,7 @@ func (s *Service) localReplicationWorker() { } } -func (s *Service) replicationWorker() { +func (s *Service) replicationWorker(ctx context.Context) { for { select { case <-s.closeCh: @@ -64,13 +64,13 @@ func (s *Service) replicationWorker() { task.n.IterateNetworkEndpoints(func(addr string) bool { lastAddr = addr - c, err := s.cache.get(context.Background(), addr) + c, err := s.cache.get(ctx, addr) if err != nil { lastErr = fmt.Errorf("can't create client: %w", err) return false } - ctx, cancel := context.WithTimeout(context.Background(), s.replicatorTimeout) + ctx, cancel := context.WithTimeout(ctx, s.replicatorTimeout) _, lastErr = c.Apply(ctx, task.req) cancel() @@ -94,8 +94,7 @@ func (s *Service) replicationWorker() { func (s *Service) replicateLoop(ctx context.Context) { for i := 0; i < s.replicatorWorkerCount; i++ { - //nolint: contextcheck - go s.replicationWorker() + go s.replicationWorker(ctx) go s.localReplicationWorker() } defer func() {