From 1109491276bced2ad1d0d1ba7a46e2b5c0e090af Mon Sep 17 00:00:00 2001 From: Succo Date: Fri, 10 Feb 2023 15:26:50 +0100 Subject: [PATCH 1/2] fix(ticker): stop all tickers to prevent goroutine leak --- pkg/config/polling_manager.go | 1 + pkg/event/processor.go | 1 + pkg/odp/event/event_manager.go | 3 +++ 3 files changed, 5 insertions(+) diff --git a/pkg/config/polling_manager.go b/pkg/config/polling_manager.go index 27fe227d..a19a7132 100644 --- a/pkg/config/polling_manager.go +++ b/pkg/config/polling_manager.go @@ -191,6 +191,7 @@ func (cm *PollingProjectConfigManager) Start(ctx context.Context) { case <-t.C: cm.SyncConfig() case <-ctx.Done(): + t.Stop() cm.logger.Debug("Polling Config Manager Stopped") return } diff --git a/pkg/event/processor.go b/pkg/event/processor.go index 8e4754ce..7fc7bac7 100644 --- a/pkg/event/processor.go +++ b/pkg/event/processor.go @@ -246,6 +246,7 @@ func (p *BatchEventProcessor) startTicker(ctx context.Context) { if ok { d.flushEvents() } + p.Ticker.Stop() return } } diff --git a/pkg/odp/event/event_manager.go b/pkg/odp/event/event_manager.go index 75853731..11a2ef8a 100644 --- a/pkg/odp/event/event_manager.go +++ b/pkg/odp/event/event_manager.go @@ -237,6 +237,9 @@ func (bm *BatchEventManager) startTicker(ctx context.Context, odpConfig config.C case <-ctx.Done(): bm.logger.Debug("BatchEventManager stopped, flushing events.") bm.FlushEvents(odpConfig.GetAPIKey(), odpConfig.GetAPIHost()) + bm.flushLock.Lock() + bm.ticker.Stop() + bm.flushLock.Unlock() return } } From d7fc8532eed504db5a5799e05d99657d0c15e5fc Mon Sep 17 00:00:00 2001 From: Succo Date: Thu, 20 Apr 2023 15:41:49 +0200 Subject: [PATCH 2/2] chore: update years in all affected files --- pkg/config/polling_manager.go | 2 +- pkg/event/processor.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/config/polling_manager.go b/pkg/config/polling_manager.go index a19a7132..32c2bee5 100644 --- a/pkg/config/polling_manager.go +++ b/pkg/config/polling_manager.go @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2020,2022 Optimizely, Inc. and contributors * + * Copyright 2019-2020,2022-2023 Optimizely, Inc. and contributors * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * diff --git a/pkg/event/processor.go b/pkg/event/processor.go index 7fc7bac7..6e89b19f 100644 --- a/pkg/event/processor.go +++ b/pkg/event/processor.go @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2020, Optimizely, Inc. and contributors * + * Copyright 2019-2020,2023 Optimizely, Inc. and contributors * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. *