diff --git a/pkg/scaling/cache/scalers_cache.go b/pkg/scaling/cache/scalers_cache.go index 58a8c41ac3e..332a419b504 100644 --- a/pkg/scaling/cache/scalers_cache.go +++ b/pkg/scaling/cache/scalers_cache.go @@ -89,10 +89,10 @@ func (c *ScalersCache) GetPushScalers() []scalers.PushScaler { // Close closes all scalers in the cache func (c *ScalersCache) Close(ctx context.Context) { - c.mutex.RLock() - defer c.mutex.RUnlock() + c.mutex.Lock() scalers := c.Scalers c.Scalers = nil + c.mutex.Unlock() for _, s := range scalers { err := s.Scaler.Close(ctx) if err != nil {