Stopping heartbeat timer before remove
This commit is contained in:
capone212 2018-05-24 13:15:06 +00:00
parent e40a635508
commit a0d4d4a336

View file

@ -112,7 +112,10 @@ func (s *Server) invalidateHeartbeat(id string) {
defer metrics.MeasureSince([]string{"nomad", "heartbeat", "invalidate"}, time.Now()) defer metrics.MeasureSince([]string{"nomad", "heartbeat", "invalidate"}, time.Now())
// Clear the heartbeat timer // Clear the heartbeat timer
s.heartbeatTimersLock.Lock() s.heartbeatTimersLock.Lock()
delete(s.heartbeatTimers, id) if timer, ok := s.heartbeatTimers[id]; ok {
timer.Stop()
delete(s.heartbeatTimers, id)
}
s.heartbeatTimersLock.Unlock() s.heartbeatTimersLock.Unlock()
// Do not invalidate the node since we are not the leader. This check avoids // Do not invalidate the node since we are not the leader. This check avoids