@@ -1206,9 +1206,8 @@ func (s *EtcdServer) triggerSnapshot(ep *etcdProgress) {
1206
1206
)
1207
1207
s .forceDiskSnapshot = false
1208
1208
1209
- s .snapshot (ep . appliedi , ep . confState )
1209
+ s .snapshot (ep )
1210
1210
s .compactRaftLog (ep .appliedi )
1211
- ep .diskSnapshotIndex = ep .appliedi
1212
1211
}
1213
1212
1214
1213
func (s * EtcdServer ) shouldSnapshot (ep * etcdProgress ) bool {
@@ -2128,7 +2127,7 @@ func (s *EtcdServer) applyConfChange(cc raftpb.ConfChange, confState *raftpb.Con
2128
2127
}
2129
2128
2130
2129
// TODO: non-blocking snapshot
2131
- func (s * EtcdServer ) snapshot (snapi uint64 , confState raftpb. ConfState ) {
2130
+ func (s * EtcdServer ) snapshot (ep * etcdProgress ) {
2132
2131
d := GetMembershipInfoInV2Format (s .Logger (), s .cluster )
2133
2132
// commit kv to write metadata (for example: consistent index) to disk.
2134
2133
//
@@ -2144,7 +2143,7 @@ func (s *EtcdServer) snapshot(snapi uint64, confState raftpb.ConfState) {
2144
2143
lg := s .Logger ()
2145
2144
2146
2145
// For backward compatibility, generate v2 snapshot from v3 state.
2147
- snap , err := s .r .raftStorage .CreateSnapshot (snapi , & confState , d )
2146
+ snap , err := s .r .raftStorage .CreateSnapshot (ep . appliedi , & ep . confState , d )
2148
2147
if err != nil {
2149
2148
// the snapshot was done asynchronously with the progress of raft.
2150
2149
// raft might have already got a newer snapshot.
@@ -2160,6 +2159,7 @@ func (s *EtcdServer) snapshot(snapi uint64, confState raftpb.ConfState) {
2160
2159
if err = s .r .storage .SaveSnap (snap ); err != nil {
2161
2160
lg .Panic ("failed to save snapshot" , zap .Error (err ))
2162
2161
}
2162
+ ep .diskSnapshotIndex = ep .appliedi
2163
2163
if err = s .r .storage .Release (snap ); err != nil {
2164
2164
lg .Panic ("failed to release wal" , zap .Error (err ))
2165
2165
}
0 commit comments