-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
etcdserver: keep a min number of entries in memory #2403
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -836,8 +836,14 @@ func (s *EtcdServer) snapshot(snapi uint64, confState raftpb.ConfState) { | |
if err := s.r.storage.SaveSnap(snap); err != nil { | ||
log.Fatalf("etcdserver: save snapshot error: %v", err) | ||
} | ||
log.Printf("etcdserver: saved snapshot at index %d", snap.Metadata.Index) | ||
|
||
err = s.r.raftStorage.Compact(snapi) | ||
// keep some in memory log entries for slow followers. | ||
compacti := uint64(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean we will always keep 1 log entry in memory? Why 1 and not say 10? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. compact 1 means do not nothing rather than keeping 1. if the snapshot index is smaller than what we should keep, we should keep all of them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we can express that fact in the comment, it's not clear what's going on here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think the code is clear enough. and we do not comment code path in general.
so it is clear that compact(1) = discard nothing. |
||
if snapi > numberOfCatchUpEntries { | ||
compacti = snapi - numberOfCatchUpEntries | ||
} | ||
err = s.r.raftStorage.Compact(compacti) | ||
if err != nil { | ||
// the compaction was done asynchronously with the progress of raft. | ||
// raft log might already been compact. | ||
|
@@ -846,7 +852,7 @@ func (s *EtcdServer) snapshot(snapi uint64, confState raftpb.ConfState) { | |
} | ||
log.Panicf("etcdserver: unexpected compaction error %v", err) | ||
} | ||
log.Printf("etcdserver: saved snapshot at index %d", snap.Metadata.Index) | ||
log.Printf("etcdserver: compacted raft log at %d", compacti) | ||
}() | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we pick 5000 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comment for why we choose 5000.