[FIXED] JetStream: possible panic on peer remove on server shutdown

This was discovered by new test TestJetStreamClusterRemovePeerByID.
I saw this on Travis and repeating the test locally with -count=10
I was able to reproduce. The issue is cc.meta being nil but accessing
cc.meta.ID() directly.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2022-09-16 15:06:58 -06:00
parent dc2e4b714a
commit 378fed164d

View File

@@ -1299,6 +1299,10 @@ func (js *jetStream) processAddPeer(peer string) {
func (js *jetStream) processRemovePeer(peer string) {
js.mu.Lock()
s, cc := js.srv, js.cluster
if cc.meta == nil {
js.mu.Unlock()
return
}
isLeader := cc.isLeader()
// All nodes will check if this is them.
isUs := cc.meta.ID() == peer