Skip to content

Commit

Permalink
[FIXED] Fix for data race accessing consumer assignment (#4547)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Collison <derek@nats.io>
  • Loading branch information
derekcollison committed Sep 15, 2023
2 parents a5344c0 + 9781025 commit 7df0e42
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/jetstream_api.go
Expand Up @@ -4231,14 +4231,18 @@ func (s *Server) jsConsumerInfoRequest(sub *subscription, c *client, _ *Account,
// We have been assigned but have not created a node yet. If we are a member return
// our config and defaults for state and no cluster info.
if isMember {
// Since we access consumerAssignment, need js lock.
js.mu.RLock()
resp.ConsumerInfo = &ConsumerInfo{
Stream: ca.Stream,
Name: ca.Name,
Created: ca.Created,
Config: ca.Config,
TimeStamp: time.Now().UTC(),
}
s.sendAPIResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(resp))
b := s.jsonResponse(resp)
js.mu.RUnlock()
s.sendAPIResponse(ci, acc, subject, reply, string(msg), b)
}
return
}
Expand Down

0 comments on commit 7df0e42

Please sign in to comment.