mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: log only new/no leader
This commit is contained in:
parent
db8e4a2fc0
commit
f2d200a826
17
raft/node.go
17
raft/node.go
@ -3,6 +3,7 @@ package raft
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"log"
|
||||||
|
|
||||||
"code.google.com/p/go.net/context"
|
"code.google.com/p/go.net/context"
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "github.com/coreos/etcd/raft/raftpb"
|
||||||
@ -68,15 +69,17 @@ func (n *Node) run(r *raft) {
|
|||||||
propc := n.propc
|
propc := n.propc
|
||||||
readyc := n.readyc
|
readyc := n.readyc
|
||||||
|
|
||||||
|
var lead int64
|
||||||
var prev Ready
|
var prev Ready
|
||||||
for {
|
for {
|
||||||
if r.hasLeader() {
|
if lead != r.lead {
|
||||||
propc = n.propc
|
log.Printf("raft: leader changed from %#x to %#x", lead, r.lead)
|
||||||
} else {
|
lead = r.lead
|
||||||
// We cannot accept proposals because we don't know who
|
if r.hasLeader() {
|
||||||
// to send them to, so we'll apply back-pressure and
|
propc = n.propc
|
||||||
// block senders.
|
} else {
|
||||||
propc = nil
|
propc = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rd := Ready{
|
rd := Ready{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user