Fix for leaked subs on non-leader change

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2021-03-02 07:19:18 -08:00
parent 2e7fdf2ef8
commit 27090975d9

View File

@@ -613,13 +613,9 @@ func (o *consumer) setLeader(isLeader bool) {
isRunning := o.ackSub != nil
o.mu.RUnlock()
if mset == nil {
return
}
// If we are here we have a change in leader status.
if isLeader {
if isRunning {
if mset == nil || isRunning {
return
}
@@ -684,9 +680,6 @@ func (o *consumer) setLeader(isLeader bool) {
} else {
// Shutdown the go routines and the subscriptions.
if !isRunning {
return
}
o.mu.Lock()
o.unsubscribe(o.ackSub)
o.unsubscribe(o.reqSub)