Skip to content

Commit

Permalink
Merge PR hashicorp#419: update peer on config change
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Sep 14, 2020
1 parent bda5e42 commit b7cd2b3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,13 @@ func (r *Raft) startStopReplication() {
if server.ID == r.localID {
continue
}

inConfig[server.ID] = true
if _, ok := r.leaderState.replState[server.ID]; !ok {

s, ok := r.leaderState.replState[server.ID]
if !ok {
r.logger.Info("added peer, starting replication", "peer", server.ID)
s := &followerReplication{
s = &followerReplication{
peer: server,
commitment: r.leaderState.commitment,
stopCh: make(chan uint64, 1),
Expand All @@ -489,10 +492,14 @@ func (r *Raft) startStopReplication() {
notifyCh: make(chan struct{}, 1),
stepDown: r.leaderState.stepDown,
}

r.leaderState.replState[server.ID] = s
r.goFunc(func() { r.replicate(s) })
asyncNotifyCh(s.triggerCh)
r.observe(PeerObservation{Peer: server, Removed: false})
} else if ok && s.peer.Address != server.Address {
r.logger.Info("updating peer", "peer", server.ID)
s.peer = server
}
}

Expand Down

0 comments on commit b7cd2b3

Please sign in to comment.