Skip to content

Commit

Permalink
fix: persist Entries first, then HardState (vanus-labs#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifplusor authored May 26, 2022
1 parent 708bab9 commit 7efd88d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/store/block/replica/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,16 @@ func (r *Replica) run() {
case <-t.C:
r.node.Tick()
case rd := <-r.node.Ready():
if err := r.log.Append(rd.Entries); err != nil {
panic(err)
}

if !raft.IsEmptyHardState(rd.HardState) {
if err := r.log.SetHardState(rd.HardState); err != nil {
panic(err)
}
}

if err := r.log.Append(rd.Entries); err != nil {
panic(err)
}

if rd.SoftState != nil {
r.leaderID = vanus.NewIDFromUint64(rd.SoftState.Lead)
if rd.SoftState.RaftState == raft.StateLeader {
Expand Down

0 comments on commit 7efd88d

Please sign in to comment.