Skip to content

Commit

Permalink
A bit more cleanup, plus now we wait for the transfer to complete or …
Browse files Browse the repository at this point in the history
…fail before responding to the transfer request.
  • Loading branch information
ncabatoff committed Nov 24, 2023
1 parent 2b715ac commit 04fdca6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/hashicorp/go-hclog v1.5.0
github.com/hashicorp/go-msgpack/v2 v2.1.1
github.com/stretchr/testify v1.8.4
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
)

require (
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
11 changes: 5 additions & 6 deletions raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,19 +692,19 @@ func (r *Raft) leaderLoop() {
case err := <-doneCh:
if err != nil {
r.logger.Debug(err.Error())
}
future.respond(err)
if err == nil {
future.respond(err)
} else {
// Wait for up to ElectionTimeout before flagging the
// leadership transfer as done and unblocking applies in
// the leaderLoop.
select {
case <-time.After(r.config().ElectionTimeout):
err := fmt.Errorf("leadership transfer timeout")
r.logger.Debug(err.Error())
future.respond(err)
case <-leftLeaderLoop:
err := fmt.Errorf("lost leadership during transfer (expected)")
r.logger.Debug(err.Error())
r.logger.Debug("lost leadership during transfer (expected)")
future.respond(nil)
}
}
}
Expand Down Expand Up @@ -861,7 +861,6 @@ func (r *Raft) leaderLoop() {
newLog.respond(ErrLeadershipTransferInProgress)
continue
}

// Group commit, gather all the ready commits
ready := []*logFuture{newLog}
GROUP_COMMIT_LOOP:
Expand Down

0 comments on commit 04fdca6

Please sign in to comment.