Skip to content

Commit

Permalink
when promoted, election timeout should be stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed Jul 2, 2013
1 parent 24fe106 commit c9ce5b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func NewServer(name string, path string, transporter Transporter, stateMachine S
state: Stopped,
peers: make(map[string]*Peer),
log: NewLog(),
stepDown: make(chan uint64),
electionTimer: NewTimer(DefaultElectionTimeout, DefaultElectionTimeout*2),
heartbeatTimeout: DefaultHeartbeatTimeout,
}
Expand Down Expand Up @@ -644,7 +645,6 @@ func (s *Server) promote() (bool, error) {
continue
}

// must be stepdown
return false, fmt.Errorf("raft.Server: Term changed during election, stepping down: (%v > %v)", s.currentTerm, term)

// TODO: is this still needed?
Expand Down Expand Up @@ -830,7 +830,7 @@ func (s *Server) electionTimeout() {

// TODO race condition with unload
if s.electionTimer.Start() {
s.promote()
go s.promote()
return

} else {
Expand Down

0 comments on commit c9ce5b4

Please sign in to comment.