mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
terminate leader goroutines on shutdown
Ensure that nomad steps down (and terminate leader goroutines) on shutdown, when the server is the leader. Without this change, `monitorLeadership` may handle `shutdownCh` event and exit early before handling the raft `leaderCh` event and end up leaking leadership goroutines.
This commit is contained in:
@@ -108,6 +108,9 @@ func (s *Server) monitorLeadership() {
|
||||
s.logger.Warn("cluster leadership gained and lost leadership immediately. Could indicate network issues, memory paging, or high CPU load.")
|
||||
}
|
||||
case <-s.shutdownCh:
|
||||
if weAreLeaderCh != nil {
|
||||
leaderStep(false)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user