Skip to content
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

Merged
merged 1 commit into from
Mar 15, 2017

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Mar 15, 2017

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.

@@ -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) {
Copy link
Contributor

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?

@heyitsanthony
Copy link
Contributor

lgtm defer to @xiang90

}
return applied, shouldstop
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no naked return please.

@xiang90
Copy link
Contributor

xiang90 commented Mar 15, 2017

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 <gyuhox@gmail.com>
@gyuho gyuho merged commit 5856c8b into etcd-io:master Mar 15, 2017
@gyuho gyuho deleted the raft-applied-term branch March 15, 2017 20:35
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@902c676). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master    #7513   +/-   ##
=========================================
  Coverage          ?   70.25%           
=========================================
  Files             ?      320           
  Lines             ?    26203           
  Branches          ?        0           
=========================================
  Hits              ?    18408           
  Misses            ?     6338           
  Partials          ?     1457
Impacted Files Coverage Δ
etcdserver/snapshot_merge.go 92.3% <100%> (ø)
etcdserver/server.go 79.6% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 902c676...80c10e1. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants