From 301e0b71418583ac94373000c5c7ebb425e9c607 Mon Sep 17 00:00:00 2001 From: Henry Robinson Date: Wed, 24 Jul 2024 13:09:38 +0100 Subject: [PATCH] Don't lock across update() Signed-off-by: Henry Robinson --- go/vt/vtgateproxy/discovery.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/go/vt/vtgateproxy/discovery.go b/go/vt/vtgateproxy/discovery.go index 7a019e49030..1bf40ae4a58 100644 --- a/go/vt/vtgateproxy/discovery.go +++ b/go/vt/vtgateproxy/discovery.go @@ -211,14 +211,16 @@ func (b *JSONGateResolverBuilder) start() error { parseCount.Add("changed", 1) b.mu.RLock() + resolvers := b.resolvers + b.mu.RUnlock() + // notify all the resolvers that the targets changed - for _, r := range b.resolvers { + for _, r := range resolvers { err = b.update(r) if err != nil { log.Errorf("Failed to update resolver: %v", err) } } - b.mu.RUnlock() } }()