From d87b3ad2b1f39b6174e3ebb68789dc41e64ade34 Mon Sep 17 00:00:00 2001 From: Michael Nairn Date: Thu, 24 Oct 2024 13:52:20 +0100 Subject: [PATCH] fix: topology all can cause race Topology.All() was incorrectly modifying the existing topology map instead of copying it which can cause a race `fatal error: concurrent map read and map write` under normal usage. Signed-off-by: Michael Nairn --- machinery/topology.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/machinery/topology.go b/machinery/topology.go index aa46578..63ebf95 100644 --- a/machinery/topology.go +++ b/machinery/topology.go @@ -166,7 +166,10 @@ func (t *Topology) Objects() *collection[Object] { // All returns all object nodes in the topology. func (t *Topology) All() *collection[Object] { - allObjects := t.objects + allObjects := map[string]Object{} + for k, v := range t.objects { + allObjects[k] = v + } for k, v := range t.targetables { allObjects[k] = v }