Skip to content

Commit

Permalink
Missing mutex rlock
Browse files Browse the repository at this point in the history
  • Loading branch information
kevburnsjr committed Jan 26, 2025
1 parent 68038ed commit 3887b05
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions shard_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 3887b05

Please sign in to comment.