Questions tagged [consensus]

Consensus is the problem of reaching agreement among members of a group. Talking in terms of computing it is the agreement on a certain value that is needed for during computation by nodes that participate in a cluster. Reaching consensus in a distributed environment is a challenging task and under certain conditions not even possible. Consensus algorithms are often used for replicating a state machine as a general approach for enhancing fault-tolerance

In the context of distributed computing consensus is a fundamental problem that has received intense attention in research as problem like atomic compare-and-swap (CAS) registers or atomic transaction commit can be reduced to it. Furthermore consensus builds a foundation to realise applications like leader election, clock synchronisation and state machine replication. Although the problem can be explained in simple words, solving it is far more subtle and under certain circumstances not even possible.

In general consensus is the problem of reaching agreement among members of a group. Talking in terms of computing, it is the agreement on a certain value that is needed for during computation by nodes that participate in a cluster. This may not sound complicated but indeed gets as in a distributed system different types of unpredictable partial failures like:

  • loss of packets
  • duplication/reordering of packets
  • arbitrary delayed packet delivery
  • pause or even crash of a node

may happen and will happen, which impede solving the problem. Therefore a consensus algorithm needs to satisfy certain properties:

  • Agreement: All decisions by non faulty processors must be the same.
  • Integrity: No node decides twice.
  • Validity: If all nodes decide on value v, then v was proposed.
  • Termination: Every non-faulty node needs to eventually decide on a value.

Termination is a liveness property and requires that the algorithm is fault-tolerant. Without satisfying this property an algorithm could simply use a predefined leader that decides on values (like a 2PC). But if the leader fails the algorithm would not make progress anymore - hence the termination requirement. Agreement and integrity are safety properties and build the core of the consensus algorithm. Validity covers the trivial solution where nodes would always decide on the same pre given value and thus also reach consensus by definition.

Whether a solution, that is an actual algorithm, exist for the consensus problem, depends on the system model. Therefore one has to differentiate between a synchronous or asynchronous system model1. Since mostly, in order to send messages, we have to rely on a shared communication channel, at least the communication is asynchronous and thus our real world applications fit that model better. Unfortunately in such kind of environment there is an impossibility proof by Fischer et al. (1), known as the FLP Impossibility, that shows in a fully asynchronous model even if just one node is faulty (not even considering byzantine failures), no algorithm exist that always reaches consensus. By proving that in every possible algorithm an execution exist that would never terminate, they have shown that no algorithm would always reach the point of agreement.

Nevertheless real solutions to this problem exist. Note that the impossibility result applies on fully asynchronous environments. Although our real world applications fit that model better, it does not mean all conditions are accurate (e.g processors do maintain an internal clock). Making less stringent assumptions about the model allows circumventing the result of the FLP Impossibility. Setting for example an upper bound for message delivery as an unreliable failure detection can turn the communication channel into a partial synchronous one. A system model in which the consensus problem is solvable. (2)

Algorithms that solve the consensus problem are: Paxos, Raft, Viewstamped Replication, Zab


1 In synchronous models there are known bounds for message delivery and process execution. In an asynchronous model processors not even maintain an internal clock and hence no bounds exist.

303 questions
4
votes
1 answer

How do raft nodes learn about peers?

I just finished the raft paper and am beginning work on an implementation. However, I realized I am a bit confused on one crucial detail. How do raft nodes “know” about their peers? I didn’t see any mention of this in the paper so I assume it is…
mlz7
  • 2,067
  • 3
  • 27
  • 51
4
votes
3 answers

What kind of consensus used in Hyperledger Fabric?

I don't know if this question make sense, I know Raft is consensus algorithm and use etcd to distributed the data, and i know etcd in Raft Ordering Service have a similar job with zookeeper in Kafka Ordering Service, but what I don't understand is,…
4
votes
1 answer

Hyperledger Fabric: Add Orderer in running raft network

I want to add a new orderer node in a running hyperledger-fabric network. I've used etcdraft as consensus between the orderers. I've followed step by step process of this accepted answer. In step #15, it is mentioned that, I've to fetch the latest…
4
votes
1 answer

Why Raft should grant vote when voteFor is candidateId?

I am not sure if I understand the RequestVote RPC detail in Raft correctly. In the paper, it says Receiver implementation: 1. Reply false if term < currentTerm (§5.1) 2. If votedFor is null or candidateId, and candidate’s log is at least as…
pikatao
  • 344
  • 6
  • 12
4
votes
1 answer

consensus algorithm: what will happen if an odd cluster becomes even because of a node failure?

Consensus algorithm (e.g. raft) requires the cluster contains an odd number of nodes to avoid the split-brain problem. Say I have a cluster of 5 nodes, what will happen if only one node fails? The cluster has 4 nodes now, which breaks the odd…
zx_wing
  • 1,918
  • 3
  • 26
  • 39
4
votes
1 answer

In Raft distributed consensus, what do I set votedFor to?

I am trying to implement the Raft consensus algorithm. Here is my general understanding around all the times we set the term and votedFor attributes of a server's state: Upon startup term is 0 and votedFor is null Upon a server's election timeout,…
Ozymandias
  • 2,533
  • 29
  • 33
4
votes
1 answer

Raft leaders commit a no-op entry at the beginning of their term

Recently I have read a paper on the Raft consensus algorithm. The new leader does not know what is the current commit index. How does a no-op solves this problem?
Chuckie Li
  • 45
  • 7
4
votes
2 answers

Does the Raft consensus protocol handle nodes that lost contact to the leader but not to the other nodes?

In case of network partitions, Raft stays consistent. But what does happen if only a single node loses contact only to the leader, becomes a candidate and calls for votes? This is the setup, I adjusted the examples from…
spettekaka
  • 411
  • 3
  • 11
4
votes
1 answer

How to handle consensus in a decentralized event sourced database?

Lets say I have dynamic network of X servers (not fixed over time) with a identical copy of all events in a append only database. Now I'd like to support creating new events on any of these 10 servers and have them reach consensus, replicate the…
Andreas Zita
  • 7,232
  • 6
  • 54
  • 115
4
votes
1 answer

In RAFT is it possible to have a majority consensus on a log entry but the entry is not committed?

Consider this simulation in the official raft webpage Why is term 2 index 1 not committed despite S2 (leader) , S3 and S4 agreeing on the log? I run this multiple minutes to make sure all communication has taken place. Weirdly enough, if I add one…
Jal
  • 2,174
  • 1
  • 18
  • 37
4
votes
3 answers

What is consensus in hyperledger

On the below link, there is a paragraph that says: http://www.coindesk.com/stellar-ripple-hyperledger-rivals-bitcoin-proof-work/ “Each node publishes a public key. Any message coming through the node is signed by the node to verify its format. Once…
Saurabh
  • 1,249
  • 2
  • 13
  • 14
4
votes
2 answers

Paxos phase 2a message loss

The figure below is the message flow of basic Paxos, in the phase 2a, the Leader chooses value Vn for its proposal1 and sends Accept!(1,Vn) to every acceptor. My question is: what if two of theses three messages get lost? I mean only Acceptor 1 (not…
HuangJie
  • 1,488
  • 1
  • 16
  • 33
4
votes
4 answers

Paxos algorithm in the context of distributed database transaction

I had some confusion about paxos, specifically in the context of database transactions: In the paper "paxos made simple", it says in the second phase that the proposer needs to choose one of the values with the highest sequence number which one of…
4
votes
1 answer

Does paxos "ignore" the request for updating the value if it is not in sync with highest proposal number sent by acceptor?

Title here could be misleading. I will try my best to explain my doubt through an example. I am reading about paxos algorithm from wiki and other sources. 1) Imagine a situation where a client's request to update a value (X in below example) is…
brain storm
  • 30,124
  • 69
  • 225
  • 393
4
votes
2 answers

Consensus number of FIFO queue

What is the exact consensus number of a multi-dequeuer queue? I know that it is at least 2: queue.enq(1) queue.enq(0) Thread A and B each call queue.deq(). The thread that got 1 will return it's own value. The thread that got 0 will return the…
1 2
3
20 21