From 3887b0531dcb6cc2ef5e2c741a1019b312b18340 Mon Sep 17 00:00:00 2001 From: kevburnsjr Date: Sun, 26 Jan 2025 13:26:36 -0800 Subject: [PATCH] Missing mutex rlock --- shard_client.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/shard_client.go b/shard_client.go index 17ae49f..86a321d 100644 --- a/shard_client.go +++ b/shard_client.go @@ -139,7 +139,10 @@ func (c *client) Read(ctx context.Context, query []byte, stale bool) (value uint } } if c.writeToLeader { - if leader, ok := c.manager.clientLeader[c.shardID]; ok { + c.manager.mutex.RLock() + leader, ok := c.manager.clientLeader[c.shardID] + c.manager.mutex.RUnlock() + if ok { return leader.client.Read(ctx, c.shardID, query, stale) } } @@ -183,7 +186,10 @@ func (c *client) Watch(ctx context.Context, query []byte, results chan<- *Result } } if c.writeToLeader { - if leader, ok := c.manager.clientLeader[c.shardID]; ok { + c.manager.mutex.RLock() + leader, ok := c.manager.clientLeader[c.shardID] + c.manager.mutex.RUnlock() + if ok { return leader.client.Watch(ctx, c.shardID, query, results, stale) } }