-
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: remove possibly compacted entry look-up #7513
Conversation
etcdserver/server.go
Outdated
@@ -1254,8 +1257,9 @@ func (s *EtcdServer) sendMergedSnap(merged snap.Message) { | |||
// apply takes entries received from Raft (after it has been committed) and | |||
// applies them to the current state of the EtcdServer. | |||
// The given entries should not be empty. | |||
func (s *EtcdServer) apply(es []raftpb.Entry, confState *raftpb.ConfState) (uint64, bool) { | |||
var applied uint64 | |||
func (s *EtcdServer) apply(es []raftpb.Entry, confState *raftpb.ConfState) (uint64, uint64, bool) { |
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.
func (s *EtcdServer) apply(es []raftpb.Entry, confState *raftpb.ConfState) (appliedt uint64, appliedi uint64, shouldStop bool) {
to make the return values clearer?
lgtm defer to @xiang90 |
aa157f7
to
8671fb8
Compare
etcdserver/server.go
Outdated
} | ||
return applied, shouldstop | ||
return |
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.
no naked return please.
LGTM. Great analysis. |
Fix etcd-io#7470. This patch removes unnecessary term look-up in 'createMergedSnapshotMessage', which can trigger panic if raft entry at etcdProgress.appliedi got compacted by subsequent 'MsgSnap' messages--if a follower is being (in this case, network latency spikes), it could receive subsequent 'MsgSnap' requests from leader. etcd server-side 'applyAll' routine and raft's Ready processing routine becomes asynchronous after raft entries are persisted. And given that raft Ready routine takes less time to finish, it is possible that second 'MsgSnap' is being handled, while the slow 'applyAll' is still processing the first(old) 'MsgSnap'. Then raft Ready routine can compact the log entries at future index to 'applyAll'. That is how 'createMergedSnapshotMessage' tried to look up raft term with outdated etcdProgress.appliedi. Signed-off-by: Gyu-Ho Lee <[email protected]>
8671fb8
to
80c10e1
Compare
Codecov Report
@@ Coverage Diff @@
## master #7513 +/- ##
=========================================
Coverage ? 70.25%
=========================================
Files ? 320
Lines ? 26203
Branches ? 0
=========================================
Hits ? 18408
Misses ? 6338
Partials ? 1457
Continue to review full report at Codecov.
|
Fix #7470.
This patch removes unnecessary term look-up in
'createMergedSnapshotMessage', which can trigger panic
if raft entry at etcdProgress.appliedi got compacted
by subsequent 'MsgSnap' messages--if a follower is
being (in this case, network latency spikes) slow, it
could receive subsequent 'MsgSnap' requests from leader.
etcd server-side 'applyAll' routine and raft's Ready
processing routine becomes asynchronous after raft
entries are persisted. And given that raft Ready routine
takes less time to finish, it is possible that second
'MsgSnap' is being handled, while the slow 'applyAll'
is still processing the first(old) 'MsgSnap'. Then raft
Ready routine can compact the log entries at future
index to 'applyAll'. That is how 'createMergedSnapshotMessage'
tried to look up raft term with outdated etcdProgress.appliedi.