Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Commit

Permalink
Ensure we skip all raft logs we've already processed (#77)
Browse files Browse the repository at this point in the history
This commit modifies the check for the last applied index to be a less than or
equal to comparison. Otherwise, the very last item in the raft log could be
replayed, leading to a duplicate message.

Signed-off-by: David Bond <[email protected]>
  • Loading branch information
davidsbond authored Apr 28, 2022
1 parent 7851bd0 commit 54a2511
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist/
*.upx
serf.key
/licenses
_example/
2 changes: 1 addition & 1 deletion internal/server/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (svr *Server) Apply(log *raft.Log) interface{} {
// the state so if the log index is less than the last known index sent to the FSM then we do nothing. We can't
// fully rely on the raft mechanism to know exactly the last log index that the FSM successfully handled, so we
// also track that manually.
if log.Index < lastAppliedIndex && lastAppliedIndex != 0 {
if log.Index <= lastAppliedIndex && lastAppliedIndex != 0 {
return nil
}

Expand Down

0 comments on commit 54a2511

Please sign in to comment.