Browse Source

raft: set raft.Commit too when setting raftLog.committed

Yicheng Qin 11 years ago
parent
commit
4804c45e14
2 changed files with 1 additions and 4 deletions
  1. 0 4
      etcdserver/server_test.go
  2. 1 0
      raft/node.go

+ 0 - 4
etcdserver/server_test.go

@@ -943,10 +943,6 @@ func TestTriggerSnap(t *testing.T) {
 	ctx := context.Background()
 	s := raft.NewMemoryStorage()
 	n := raft.StartNode(0xBAD0, mustMakePeerSlice(t, 0xBAD0), 10, 1, s)
-	rd := <-n.Ready()
-	s.Append(rd.Entries)
-	n.Advance()
-	n.ApplyConfChange(raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 0xBAD0})
 	n.Campaign(ctx)
 	st := &storeRecorder{}
 	p := &storageRecorder{}

+ 1 - 0
raft/node.go

@@ -150,6 +150,7 @@ func StartNode(id uint64, peers []Peer, election, heartbeat int, storage Storage
 	// TODO(bdarnell): These entries are still unstable; do we need to preserve
 	// the invariant that committed < unstable?
 	r.raftLog.committed = r.raftLog.lastIndex()
+	r.Commit = r.raftLog.committed
 	// Now apply them, mainly so that the application can call Campaign
 	// immediately after StartNode in tests. Note that these nodes will
 	// be added to raft twice: here and when the application's Ready