From 87f0d4f040ff80a0770f640f32fe3d0399f9cc5f Mon Sep 17 00:00:00 2001 From: lyt122 <2747177214@qq.com> Date: Wed, 4 Sep 2024 11:22:33 +0800 Subject: [PATCH] fix Consul data race (#708) --- controller/registries/consul/config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controller/registries/consul/config.go b/controller/registries/consul/config.go index 2a18cda3..92093002 100644 --- a/controller/registries/consul/config.go +++ b/controller/registries/consul/config.go @@ -393,6 +393,8 @@ func (reg *Consul) refresh(services map[string][]string) { } } } + reg.lock.Lock() + defer reg.lock.Unlock() prevFetchServices := reg.watchingServices reg.watchingServices = serviceMap