From 78219a27b32fa9c383ba4f2811e41478328df889 Mon Sep 17 00:00:00 2001 From: Miccah Date: Fri, 24 Nov 2023 13:22:08 -0800 Subject: [PATCH] Call Finish in SourceManager after the semaphore is released (#2121) --- pkg/sources/source_manager.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/sources/source_manager.go b/pkg/sources/source_manager.go index f261ac259..4dde84813 100644 --- a/pkg/sources/source_manager.go +++ b/pkg/sources/source_manager.go @@ -123,6 +123,8 @@ func (s *SourceManager) asyncRun(ctx context.Context, sourceName string, source } s.wg.Add(1) go func() { + // Call Finish after the semaphore has been released. + defer progress.Finish() defer s.sem.Release(1) defer s.wg.Done() ctx := context.WithValues(ctx, @@ -216,7 +218,6 @@ func (s *SourceManager) preflightChecks(ctx context.Context) error { // acquired resources. An error is returned if there was a fatal error during // the run. This information is also recorded in the JobProgress. func (s *SourceManager) run(ctx context.Context, source Source, report *JobProgress) error { - defer report.Finish() report.Start(time.Now()) defer func() { report.End(time.Now()) }()