Protect against no cluster

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2022-04-15 13:18:42 -07:00
parent aa23a91938
commit 3d9fdff315

View File

@@ -1812,8 +1812,12 @@ func (s *Server) jsStreamInfoRequest(sub *subscription, c *client, a *Account, s
// while the new members work through the election and catchup process.
// Double check for that instead of exiting here and being silent. e.g. nats stream update test --replicas=3
js.mu.RLock()
rg, ourID := sa.Group, cc.meta.ID()
bail := !rg.isMember(ourID)
rg, bail := sa.Group, true
var ourID string
if cc.meta != nil {
ourID = cc.meta.ID()
}
bail = !rg.isMember(ourID)
if !bail {
// We know we are a member here, if this group is new and we are preferred allow us to answer.
bail = rg.Preferred != ourID || time.Since(rg.node.Created()) > lostQuorumInterval