From 845026e43f38298174d5d5ae8f9d13d39904baaa Mon Sep 17 00:00:00 2001 From: Silvan Date: Thu, 17 Sep 2020 09:12:56 +0200 Subject: [PATCH] fix(spooler): memory leak (#751) * fix: dependecies * fix: one of two memory leaks found * fix: remove log --- internal/eventstore/spooler/spooler.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/eventstore/spooler/spooler.go b/internal/eventstore/spooler/spooler.go index fd13d88c08..755551a9e3 100644 --- a/internal/eventstore/spooler/spooler.go +++ b/internal/eventstore/spooler/spooler.go @@ -65,6 +65,7 @@ func (s *spooledHandler) load(workerID string) { ctx, cancel := context.WithCancel(context.Background()) go s.awaitError(cancel, errs, workerID) hasLocked := s.lock(ctx, errs, workerID) + defer close(hasLocked) if <-hasLocked { go func() { @@ -166,8 +167,10 @@ func (s *spooledHandler) lock(ctx context.Context, errs chan<- error, workerID s err := s.locker.Renew(workerID, s.ViewModel(), s.MinimumCycleDuration()*2) logging.Log("SPOOL-u4j6k").WithField("view", s.ViewModel()).WithField("worker", workerID).WithError(err).Debug("renew done") if err == nil { - locked <- true - renewTimer = time.After(renewDuration) + if ctx.Err() == nil { + locked <- true + renewTimer = time.After(renewDuration) + } continue }