Skip to content

Commit d907ecd

Browse files
committed
Separate memory and disk snapshot indexes
Signed-off-by: Marek Siarkowicz <[email protected]>
1 parent 9d55044 commit d907ecd

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

server/etcdserver/server.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -741,10 +741,11 @@ func (s *EtcdServer) ReportSnapshot(id uint64, status raft.SnapshotStatus) {
741741
}
742742

743743
type etcdProgress struct {
744-
confState raftpb.ConfState
745-
diskSnapshotIndex uint64
746-
appliedt uint64
747-
appliedi uint64
744+
confState raftpb.ConfState
745+
diskSnapshotIndex uint64
746+
memorySnapshotIndex uint64
747+
appliedt uint64
748+
appliedi uint64
748749
}
749750

750751
// raftReadyHandler contains a set of EtcdServer operations to be called by raftNode,
@@ -809,10 +810,11 @@ func (s *EtcdServer) run() {
809810
s.r.start(rh)
810811

811812
ep := etcdProgress{
812-
confState: sn.Metadata.ConfState,
813-
diskSnapshotIndex: sn.Metadata.Index,
814-
appliedt: sn.Metadata.Term,
815-
appliedi: sn.Metadata.Index,
813+
confState: sn.Metadata.ConfState,
814+
diskSnapshotIndex: sn.Metadata.Index,
815+
memorySnapshotIndex: sn.Metadata.Index,
816+
appliedt: sn.Metadata.Term,
817+
appliedi: sn.Metadata.Index,
816818
}
817819

818820
defer func() {
@@ -1133,6 +1135,7 @@ func (s *EtcdServer) applySnapshot(ep *etcdProgress, toApply *toApply) {
11331135
ep.appliedt = toApply.snapshot.Metadata.Term
11341136
ep.appliedi = toApply.snapshot.Metadata.Index
11351137
ep.diskSnapshotIndex = ep.appliedi
1138+
ep.memorySnapshotIndex = ep.appliedi
11361139
ep.confState = toApply.snapshot.Metadata.ConfState
11371140

11381141
// As backends and implementations like alarmsStore changed, we need
@@ -2160,6 +2163,7 @@ func (s *EtcdServer) snapshot(ep *etcdProgress) {
21602163
lg.Panic("failed to save snapshot", zap.Error(err))
21612164
}
21622165
ep.diskSnapshotIndex = ep.appliedi
2166+
ep.memorySnapshotIndex = ep.appliedi
21632167
if err = s.r.storage.Release(snap); err != nil {
21642168
lg.Panic("failed to release wal", zap.Error(err))
21652169
}

server/etcdserver/server_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ func TestSnapshot(t *testing.T) {
686686
t.Errorf("no action expected on v2store. Got %d actions", len(st.Action()))
687687
}
688688
assert.Equal(t, uint64(1), ep.diskSnapshotIndex)
689+
assert.Equal(t, uint64(1), ep.memorySnapshotIndex)
689690
}
690691

691692
// TestSnapshotOrdering ensures raft persists snapshot onto disk before

0 commit comments

Comments
 (0)