raft: add Ready.MustSync

Add Ready.MustSync which indicates that the hard state and raft log
entries in a Ready message must be synchronously written to persistent
storage.
This commit is contained in:
Peter Mattis
2017-02-13 15:09:54 -05:00
parent 2925f02aac
commit ab03a42f06
4 changed files with 25 additions and 10 deletions

View File

@@ -487,11 +487,13 @@ func TestNodeStart(t *testing.T) {
CommittedEntries: []raftpb.Entry{
{Type: raftpb.EntryConfChange, Term: 1, Index: 1, Data: ccdata},
},
MustSync: true,
},
{
HardState: raftpb.HardState{Term: 2, Commit: 3, Vote: 1},
Entries: []raftpb.Entry{{Term: 2, Index: 3, Data: []byte("foo")}},
CommittedEntries: []raftpb.Entry{{Term: 2, Index: 3, Data: []byte("foo")}},
MustSync: true,
},
}
storage := NewMemoryStorage()
@@ -544,6 +546,7 @@ func TestNodeRestart(t *testing.T) {
HardState: st,
// commit up to index commit index in st
CommittedEntries: entries[:st.Commit],
MustSync: true,
}
storage := NewMemoryStorage()
@@ -588,6 +591,7 @@ func TestNodeRestartFromSnapshot(t *testing.T) {
HardState: st,
// commit up to index commit index in st
CommittedEntries: entries,
MustSync: true,
}
s := NewMemoryStorage()