From 79d4a35a3d4433f4e2768c8b6e0ef18417c25ba0 Mon Sep 17 00:00:00 2001 From: Al Arafat Tanin | rng70-or Date: Thu, 21 Mar 2024 15:11:35 +0600 Subject: [PATCH] fix: capturing wrong references to loop variables from a goroutine --- pkg/query/endpointset.go | 1 + pkg/rules/manager.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/query/endpointset.go b/pkg/query/endpointset.go index a8005c571d..ade3e593cb 100644 --- a/pkg/query/endpointset.go +++ b/pkg/query/endpointset.go @@ -612,6 +612,7 @@ func (e *EndpointSet) GetEndpointStatus() []EndpointStatus { statuses := make([]EndpointStatus, 0, len(e.endpoints)) for _, v := range e.endpoints { + v := v v.mtx.RLock() defer v.mtx.RUnlock() diff --git a/pkg/rules/manager.go b/pkg/rules/manager.go index 870b782732..ab83159250 100644 --- a/pkg/rules/manager.go +++ b/pkg/rules/manager.go @@ -159,6 +159,7 @@ func NewManager( // Run is non blocking, in opposite to TSDB manager, which is blocking. func (m *Manager) Run() { for _, mgr := range m.mgrs { + mgr := mgr go mgr.Run() } }