Wait for follower and leader loops to finish

This commit is contained in:
Ingo Oppermann 2024-08-19 15:22:24 +02:00
parent 1650b17e05
commit 0b1601542d
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E
2 changed files with 16 additions and 4 deletions

View File

@ -648,10 +648,6 @@ func (c *cluster) Shutdown() error {
c.raft.Shutdown()
}
// TODO: here might some situations, where the manager is still need from the synchronize loop and will run into a panic
c.manager = nil
c.raft = nil
return nil
}

View File

@ -180,6 +180,22 @@ func (c *cluster) monitorLeadership() {
c.leaderLock.Unlock()
}
case <-c.shutdownCh:
if weAreFollowerCh != nil {
close(weAreFollowerCh)
}
if weAreLeaderCh != nil {
close(weAreLeaderCh)
}
if weAreEmergencyLeaderCh != nil {
close(weAreEmergencyLeaderCh)
}
leaderLoop.Wait()
emergencyLeaderLoop.Wait()
followerLoop.Wait()
return
}
}