Paxos --- learning notes

Source: Internet
Author: User

From Wikipedia: node communication in a distributed system has two models: Shared Memory and messages passing ). In a distributed system based on the message transmission communication model, the following errors are inevitable: the process may be slow, crashed, or restarted, and the message may be delayed, lost, or duplicated, in the Basic paxos scenario, we do not consider the possibility of message tampering, that is, the Byzantine error. The paxos algorithm solves the problem of how to reach an agreement on a value in a distributed system that may encounter the above exceptions, so as to ensure that no matter any of the above exceptions occurs, the consistency of resolutions will not be damaged. A typical scenario is that, in a distributed database system, if the initial status of each node is consistent and each node executes the same operation sequence, they can finally get a consistent state. To ensure that each node executes the same command sequence, a "consistency algorithm" must be executed on each command to ensure that the commands seen by each node are consistent. A general consistency algorithm can be used in many scenarios and is an important issue in distributed computing.

Paxos is designed to solve distributed consistency problems.

Problems After algorithm Division role description:

  1. A resolution (value) can be approved only after it is proposed by Proposers (an unapproved resolution is called a proposal (proposal )」);
  2. In the execution instance of a paxos algorithm, only one value (chosen) is approved;
  3. Learners can only obtain the value of chosen.

When you understand these three problems, you may have questions about the definition of the "one-time paxos algorithm.

During value approval, proposers first sends the value to the acceptors, and then the acceptors accept the value (accept ). To meet the constraint that only one value is allowedMajority )」The accepted value becomes the formal resolution (called the "approve" Resolution ). This is because, whether by number of people or by weight, the two "majority" groups have at least one public acceptor. If each acceptor can only accept one value, constraint 2 is guaranteed.

Then, to ensure the above three problems, the constraints are as follows:

P1: an acceptor must accept the proposal received for the first time.
P2: Once a proposal with value V is approved (chosen), then the later approved (chosen) proposal must have value v.
P2a: Once a proposal with value V is approved (chosen), then any acceptor accepts the proposal again (accept) must have value v.
P2b: Once a proposal with value V is approved (chosen), any proposal proposed by proposer in the future must have value v.

P2c: if a proposal numbered N has value V, there is a majority, or none of them accept any proposal numbered less than N, either they have accepted (accept) All proposals with numbers less than n that have the largest number have value v.

If I did not accept the proposal, how did the value V proposal come into being?

Algorithm content

To satisfy P2c constraints, Proposer must first communicate with the acceptors that are sufficient to form a majority to obtain the most recent acceptance proposal (prepare process) from them ), then, the value of this proposal will be determined based on the collected information to form a proposal and start voting. After receiving the majority of acceptors for acceptance (accept), the proposal is approved (chosen) and the proposer notifies learner of the message. This simple process is further refined to form the paxos algorithm.

In a paxos instance, each proposal must have different numbers and there must be a full-order relationship between numbers. You can use multiple methods to achieve this, such as splicing the ordinal number and Proposer name. How to do this is not covered by the paxos algorithm.

If an acceptor with the ID m of the last accept (accept) proposal answers a proposer's question about proposal n (n> m) during the prepare process, however, before starting to vote for N, I accept another proposal (such as N-1) whose number is less than n. If N-1 and M have different values, this vote will violate P2c. Therefore, in the prepare process, the answer provided by the acceptor should also contain a commitment that the proposal with the accept number less than N will not be accepted. This is an enhancement to P1:

P1a: When and only when the acceptor has not responded to a prepare request with a serial number greater than N, the acceptor accepts a proposal with the serial number n.


Proposal and approval of resolutions

The adoption of a resolution is divided into two phases:

  1. Prepare stage:
    1. Proposer selects a proposal number N and sends the prepare request to a majority in the acceptors;
    2. After the acceptor receives the prepare message, if the number of the proposal is greater than all the Prepare messages it has replied to, the acceptor replies the proposal it received to the proposer and promises not to reply to the proposal smaller than N;
  2. Approval phase:
    1. When a proposer receives a response from most acceptors to prepare, it enters the approval stage. It sends an accept request to the acceptors that reply to the prepare request, including the value number N and the value determined based on P2c (if P2c does not have the accepted value, it can determine the value freely ).
    2. If the acceptor does not violate its commitment to other proposer, the acceptor accepts this request upon receiving the accept request.

This process can be interrupted at any time to ensure correctness. For example, if a proposer finds that other proposers have proposed a higher number proposal, it is necessary to interrupt this process. Therefore, for optimization, if an acceptor finds a proposal with a higher number in the prepare process, it must notify proposer to suspend the proposal.

 

Paxos --- learning notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.