physical/raft: Add nil check to shutdown (#9322)

This commit is contained in:
Alexander Bezobchuk 2020-06-25 20:51:13 -04:00 committed by GitHub
parent 26177d22f5
commit 08c83d341d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -729,14 +729,25 @@ func (b *RaftBackend) TeardownCluster(clusterListener cluster.ClusterHook) error
}
b.l.Lock()
future := b.raft.Shutdown()
// Perform shutdown only if the raft object is non-nil. The object could be nil
// if the node is unsealed but has not joined the peer set.
var future raft.Future
if b.raft != nil {
future = b.raft.Shutdown()
}
b.raft = nil
// If we're tearing down, then we need to recreate the raftInitCh
b.raftInitCh = make(chan struct{})
b.l.Unlock()
return future.Error()
if future != nil {
return future.Error()
}
return nil
}
// CommittedIndex returns the latest index committed to stable storage