1

I have pasted pseudocode for a paxos algorithm here:

What is a "view" in the Paxos consensus algorithm?

and was wondering if someone could point me in the right direction.

The algorithm says that each node has a "state" which contains a bunch of information the node should keep track of.

Suppose we have two nodes: Node #1 and Node #2. In the simplest case Node #2 joins Node #1 and they both play paxos. What exactly happens to the states of Node #1 and Node #2 after 2 joins 1? When does the "views" data structure change and what does it contain? If someone can explain to me this simple case of two nodes playing paxos, then I think I can figure out multiple node case.

My current understanding (which I'm pretty sure is not correct) is as follows:

  1. Node #2 sends a message to join Node #1.
  2. Node #1 receives message from Node #2 asking to join.
  3. Node #1 assumes leadership and kicks into phase 1, computes my_num = max(0,0) + 1 = 1
  4. Node #1 sends all nodes in views[0] (which is empty) prepare(1,1)
  5. Node #1 sends initial contact node (Node #2) prepare(1,1)
  6. Node #1 sends Node #1 (itself) prepare(1,1)
  7. Node #2 receives prepare(1,1). It sets its num_h=1 and returns to leader PROMISE(0,{empty list})
  8. Node #1 receives prepare(1,1) and sets its num_h=1 and returns itself PROMISE(0,{empty list}).

now we get to phase 2

This is where I am quite confused.

Node #1 is the leader and it receives two PROMISE(0,{empty list}) messages. According to the algorithm, if the leader gets a majority of promises in views[0] then it can set a value for "v" and send the ACCEPT message to all responders.

What I am confused about is currently the views[0] for the leader is empty so how can you compute the majority of an empty list?

Also, let's assume the leader has received a majority of promises and proceeds to set v = set of pingable nodes (including self). What exactly are pingable nodes? Is it just Node #1 and Node #2?

Would appreciate all / any help and will definitely award points to those that help.

Community
  • 1
  • 1
user1068636
  • 1,871
  • 7
  • 33
  • 57
  • Maybe the pseudocode listing is not very good. I looked at the Paxos page on Wikipedia and it looked much clearer than the pseudocode... Anyway, views[...] in the pseudocode is never a set. views is a map from view number to the chosen value in that view. I think the majority statement just means that the node receives enough PROMISEs in the current phase of its local execution. It looks like the pseudocode actually tries somehow to decide on a set of nodes. But Paxos can be used to decide on any value(s), not only sets of nodes. Is the pseudocode specialized for a particular problem? – Antti Huima May 12 '12 at 05:24
  • Have you read [the original paper?](http://research.microsoft.com/en-us/um/people/lamport/pubs/lamport-paxos.pdf) It's super easy to follow and quite enjoyable; unlike any other computer science research you'll ever read. Subsequent papers have suggested a few changes to simplify and/or extend Paxos, but reading that original paper will give you a firm grasp of the principles behind it all. – erickson May 12 '12 at 14:20
  • Ok thanks guys. I think this has helped me. But I guess neither of you have posted an answer so I cannot award points. – user1068636 May 13 '12 at 15:53

1 Answers1

0

The pseudocode is not specialized for a particular problem. In fact, the professor said we don't need to use pseudocode if we don't want to and said we can look at other Paxos papers (i.e. paxos made simple, paxos made live,etc..) for guidance on implementing this algorithm. Maybe you are right, I should probably look at Wikipedia to implement this algorithm. So the views[..] is simply a hash map of and a node can choose any value it wishes to. If I understand you correctly, you say the majority statement just checks if it received "enough" PROMISE messages. But the only way to know if we have enough is if the node keeps track of who its group members are. Which means that I need a different data structure for this.

Also, I cannot award points to you because you made a comment. If you post an answer then I can give you points.

user1068636
  • 1,871
  • 7
  • 33
  • 57