Cleanup timers on consumer leader change

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2022-04-16 13:37:46 -06:00
parent 80de35169e
commit eb4856e4a7
2 changed files with 8 additions and 1 deletions

View File

@@ -962,6 +962,11 @@ func (o *consumer) setLeader(isLeader bool) {
// Reset waiting if we are in pull mode.
if o.isPullMode() {
o.waiting = newWaitQueue(o.cfg.MaxWaiting)
if !o.isDurable() {
stopAndClearTimer(&o.dtmr)
}
} else if o.srv.gateway.enabled {
stopAndClearTimer(&o.gwdtmr)
}
o.mu.Unlock()
}

View File

@@ -2085,7 +2085,9 @@ func (s *Server) jsConsumerLeaderStepDownRequest(sub *subscription, c *client, _
}
// Call actual stepdown.
o.raftNode().StepDown()
if n := o.raftNode(); n != nil {
n.StepDown()
}
resp.Success = true
s.sendAPIResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(resp))