Fix for a datarace

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2023-04-03 13:58:03 -07:00
parent b806a8e7e7
commit 59175c491f
2 changed files with 7 additions and 6 deletions

View File

@@ -3125,6 +3125,11 @@ func (s *Server) healthz(opts *HealthzOptions) *HealthStatus {
// Range across all accounts, the streams assigned to them, and the consumers.
// If they are assigned to this server check their status.
ourID := meta.ID()
// TODO(dlc) - Might be better here to not hold the lock the whole time.
js.mu.RLock()
defer js.mu.RUnlock()
for acc, asa := range cc.streams {
for stream, sa := range asa {
if sa.Group.isMember(ourID) {