diff --git a/pkg/analyzer/process_state.go b/pkg/analyzer/process_state.go index 89220463..5d749014 100644 --- a/pkg/analyzer/process_state.go +++ b/pkg/analyzer/process_state.go @@ -16,13 +16,12 @@ import ( func (s *StateAnalyzer) runProcessState(wgProcess *sync.WaitGroup, downloadFinishedFlag *bool) { defer wgProcess.Done() - var suddenShutDown bool = false epochBatch := pgx.Batch{} log.Info("Launching Beacon State Pre-Processer") loop: for { // in case the downloads have finished, and there are no more tasks to execute - if (*downloadFinishedFlag && len(s.EpochTaskChan) == 0) || (suddenShutDown && len(s.EpochTaskChan) == 0) { + if *downloadFinishedFlag && len(s.EpochTaskChan) == 0 { log.Warn("the task channel has been closed, finishing epoch routine") if epochBatch.Len() == 0 { log.Debugf("Sending last epoch batch to be stored...") @@ -36,7 +35,7 @@ loop: select { case <-s.ctx.Done(): log.Info("context has died, closing state processer routine") - suddenShutDown = true + return case task, ok := <-s.EpochTaskChan: diff --git a/pkg/analyzer/validatorWorker.go b/pkg/analyzer/validatorWorker.go index f03bda6a..76fc8eb7 100644 --- a/pkg/analyzer/validatorWorker.go +++ b/pkg/analyzer/validatorWorker.go @@ -118,7 +118,7 @@ loop: wlog.Debugf("Validator group processed, worker freed for next group. Took %f seconds", time.Since(snapshot).Seconds()) case <-s.ctx.Done(): - log.Info("context has died, closing state Worker routine") + log.Info("context has died, closing state worker routine") return default: } diff --git a/pkg/db/postgresql/service.go b/pkg/db/postgresql/service.go index 90f5a481..10bff660 100644 --- a/pkg/db/postgresql/service.go +++ b/pkg/db/postgresql/service.go @@ -133,6 +133,7 @@ func (p *PostgresDBService) runWriters() { case <-p.ctx.Done(): wlogWriter.Info("shutdown detected, closing persister") + break loop default: }