Skip to content

Instantly share code, notes, and snippets.

@sttts
Created July 14, 2016 12:50
Show Gist options
  • Save sttts/cfdc7c89cb7bfbef6c8e7ec0c80274e7 to your computer and use it in GitHub Desktop.
Save sttts/cfdc7c89cb7bfbef6c8e7ec0c80274e7 to your computer and use it in GitHub Desktop.
diff --git a/raft/raft.go b/raft/raft.go
index 281ea01..60733b6 100644
--- a/raft/raft.go
+++ b/raft/raft.go
@@ -275,6 +275,13 @@ func (r *raft) sendAppend(to uint64) {
pr.becomeSnapshot(sindex)
r.logger.Debugf("%x paused sending replication messages to %x [%s]", r.id, to, pr)
} else {
+ start := pr.Next
+ if len(ents) != 0 {
+ start = ents[0].Index
+ }
+ r.logger.Debugf("%x [firstindex: %d, commit: %d] send append[index: %d - %d, term: %d] to %x [%s]",
+ r.id, r.raftLog.firstIndex(), r.Commit, start, start + uint64(len(ents)), term, to, pr)
+
m.Type = pb.MsgApp
m.Index = pr.Next - 1
m.LogTerm = term
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment