Skip to content

Commit a018168

Browse files
committed
avoid possible nil due to race condition
fix https://github.com/chrislusf/seaweedfs/issues/1974
1 parent 47c7317 commit a018168

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,8 @@ func (s *server) saveSnapshot() error {
12961296
s.snapshot = s.pendingSnapshot
12971297

12981298
// Delete the previous snapshot if there is any change
1299-
if tmp != nil && !(tmp.LastIndex == s.snapshot.LastIndex && tmp.LastTerm == s.snapshot.LastTerm) {
1299+
currentSnapshot := s.snapshot
1300+
if tmp != nil && currentSnapshot != nil && !(tmp.LastIndex == currentSnapshot.LastIndex && tmp.LastTerm == currentSnapshot.LastTerm) {
13001301
tmp.remove()
13011302
}
13021303
s.pendingSnapshot = nil

0 commit comments

Comments
 (0)