Skip to content

Commit

Permalink
[FAB-12709] Enable CheckQuorum
Browse files Browse the repository at this point in the history
When CheckQuorum is enabled, leader steps down if it cannot reach
the quorum of network, so that clients have a chance to disconnect
and try other nodes.

Change-Id: I901c0e3009f9d354a2b504fe16174432345055b3
Signed-off-by: Jay Guo <guojiannan1101@gmail.com>
  • Loading branch information
guoger committed Jan 29, 2019
1 parent 87397a1 commit ba2bd90
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions orderer/consensus/etcdraft/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func NewChain(
// PreVote prevents reconnected node from disturbing network.
// See etcd/raft doc for more details.
PreVote: true,
CheckQuorum: true,
DisableProposalForwarding: true, // This prevents blocks from being accidentally proposed by followers
}

Expand Down
22 changes: 22 additions & 0 deletions orderer/consensus/etcdraft/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,28 @@ var _ = Describe("Chain", func() {
})
})

When("leader is disconnected", func() {
It("proactively steps down to follower", func() {
network.disconnect(1)

By("Ticking leader until it steps down")
Eventually(func() <-chan raft.SoftState {
c1.clock.Increment(interval)
return c1.observe
}, LongEventualTimeout).Should(Receive(Equal(raft.SoftState{Lead: 0, RaftState: raft.StateFollower})))

By("Ensuring it does not accept message due to the cluster being leaderless")
err := c1.Order(env, 0)
Expect(err).To(MatchError("no Raft leader"))

network.elect(2)
network.join(1, true)

err = c1.Order(env, 0)
Expect(err).NotTo(HaveOccurred())
})
})

When("follower is disconnected", func() {
It("should return error when receiving an env", func() {
network.disconnect(2)
Expand Down

0 comments on commit ba2bd90

Please sign in to comment.