在Paxos中,Acceptor在已经接受了一个值之后还可以接受不同的值吗?
在 Multi-Paxos 算法中,从接受者的角度考虑这个消息流:
接收:Prepare(N)
回复:Promise(N, null)
接收:Accept!(N, V1)
回复:Accepted(N, V1)
接收:接受!(N+1,V2)
回复:?
根据协议,在这种情况下,接受者应该有什么反应?它应该回复 Accepted(N+1, V2),还是应该忽略第二个 Accept!?
我相信这种情况可能会发生在 Multi-Paxos 中,当第二个提议者上线并相信他是(并且一直是)领导者时,因此他在没有准备的情况下发送了 Accept。或者如果他的准备根本没有到达接受者。如果这种情况可能不会发生,您能解释一下原因吗?
In Multi-Paxos algorithm, consider this message flow from the viewpoint of an acceptor:
receive: Prepare(N)
reply: Promise(N, null)
receive: Accept!(N, V1)
reply: Accepted(N, V1)
receive: Accept!(N+1, V2)
reply: ?
What should the acceptor's reaction be in this case, according to the protocol? Should it reply with Accepted(N+1, V2), or should it ignore the second Accept!?
I believe this case may happen in Multi-Paxos when a second proposer comes online and believes he is (and always was) leader, therefore he sends his Accept without Preparing. Or if his Prepare simply did not reach the acceptor. If this case may not happen, can you explain why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不同意其他两个答案。
Multi-Paxos 并没有说 Leader 是唯一的提议者; 这会导致系统出现单点故障。即使在网络分区期间,系统也可能无法继续运行。 Multi-Paxos 是一种优化,允许单个节点(Leader)跳过一些准备阶段。其他节点认为领导者已死亡,可能会尝试代表她继续实例,但仍必须使用完整的 Basic-Paxos 协议。
对接受消息进行 Nack 违反了 Paxos 算法。 接受者应该接受所有值,除非它承诺不接受它。(允许忽略,但不推荐;这只是因为允许丢弃消息。)
那里也是一个优雅的解决方案。问题在于领导者的轮数(问题中的 N+1)。
以下是一些假设:
旁白:兼职议会 表明这是通过领导者赢得先前的 Paxos 实例来完成的(第 3.1 节),并指出只要她还活着或最富有,她就可以保持领导者身份(第 3.3.1 节)。我有一个明确的 ELECT_NEW_LEADER:
有了这些假设,解决方案就非常简单了。领导者只是为它的初始接受阶段选择一个非常低的回合 ID。这个 id(我将其称为 INITIAL_ROUND_ID)可以是任何值,只要它低于所有节点的回合 id 即可。根据您的 id 选择方案,-1、0 或 Integer.MIN_VALUE 都可以。
它之所以有效,是因为另一个节点(我称他为 Stewart)必须通过完整的 Paxos 协议才能提出任何建议,并且他的回合 id 始终大于 INITIAL_ROUND_ID。有两种情况需要考虑:Leader 的 Accept 消息是否到达 Stewart 的 Prepare 消息到达的任何节点。
当 Leader 的 Accept 阶段尚未到达任何节点时,Stewart 将不会在任何 Promise 中返回任何值,并且可以像常规 Basic-Paxos 一样继续进行。
而且,当 Leader 的 Accept 阶段已经到达一个节点时,Stewart 将在 Promise 中返回一个值,它使用该值继续算法,就像在 Basic-Paxos 中一样。
在任何一种情况下,由于 Stewart 的回合 ID 大于 INITIAL_ROUND_ID,因此节点从 Leader 接收到的任何缓慢的 Accept 消息都将始终导致 Nack。
接受者或斯图尔特都没有特殊的逻辑。 Leader 上的特殊逻辑最少(即选择一个非常低的 INITIAL_ROUND_ID)。
请注意,如果我们将 OP 的问题更改一个字符,则 OP 的自我回答是正确的:Nack。
但就目前情况而言,他的答案打破了 Paxos 算法;应该是接受!
I disagree with both other answers.
Multi-Paxos does not say that the Leader is the only proposer; this would cause the system to have a single point of failure. Even during network partitions the system may not be able to progress. Multi-Paxos is an optimization allowing a single node (the Leader) to skip some prepare phases. Other nodes, thinking the leader is dead, may attempt to continue the instance on her behalf, but must still use the full Basic-Paxos protocol.
Nacking the accept message violates the Paxos algorithm. An acceptor should accept all values unless it has promised to not accept it. (Ignoring is allowed but not recommended; it's just because dropped messages are allowed.)
There is also an elegant solution to this. The problem is with the Leader's round number (N+1 in the question).
Here are some assumptions:
Aside: The Part-time Parliament suggests this is done by the Leader winning a prior Paxos instance (Section 3.1) and points out she can stay Leader as long as she's alive or the richest (Section 3.3.1). I have an explicit ELECT_NEW_LEADER:<node> value that is proposed via Paxos.
With these assumptions, solution is very simple. The Leader merely picks a really low round id for it's initial Accept phase. This id (which I'll call it INITIAL_ROUND_ID) can be anything as long as it is lower than all the nodes' round ids. Depending on your id-choosing scheme, either -1, 0, or Integer.MIN_VALUE will work.
It works because another node (I'll call him the Stewart) has to go through the full Paxos protocol to propose anything and his round id is always greater than INITIAL_ROUND_ID. There are two cases to consider: whether or not the Leader's Accept messages reached any of the nodes the Stewart's Prepare message did.
When the Leader's Accept phase has not reaches any nodes, the Stewart will get back no value in any Promise, and can proceed just like in regular Basic-Paxos.
And, when the Leader's Accept phase has reached a node, the Stewart will get back a value in a promise, which it uses to continue the algorithm, just like in Basic-Paxos.
In either case, because the Stewart's round id is greater than INITIAL_ROUND_ID, any slow Accept messages a node receives from the Leader will always result in a Nack.
There is no special logic on either the Acceptor or the Stewart. And minimal special logic on the Leader (Viz. pick a really low INITIAL_ROUND_ID).
Notice, if we change the OP's question by one character then the OP's self answer is correct: Nack.
But as it stands, his answer breaks the Paxos Algorithm; it should be Accept!
Multi-Paxos 的正确性取决于领导者(即提议者)在连续的 Paxos 实例之间不发生变化的要求。来自兼职议会 第 3.1 节(多法令议会议定书):
因此,Multi-Paxos 做出这样的假设:您描述的情况 - 当第二个提议者上线并相信他是(而且一直是)领导者——永远不会发生。如果发生这种情况,那么就不应该使用 Multi-Paxos。对于第二种可能性——当第二个提议者的Accept!(N+1,V2) 的计数器必须小于
Prepare
没有到达接受者时——第二个提议者已经发出了一个Accept!
意味着它之前已经发出了由一定数量的接受者承诺
的Prepare
。由于接受者已经在第N
轮中向第一个提议者做出承诺,因此第二个提议者的Prepare
必须在第N
轮之前发送出去。因此,最终的N
。编辑:还应该注意的是,这个版本的协议对于拜占庭并不稳健失败:
The correctness of Multi-Paxos is conditioned on the requirement that the leader (i.e., proposer) does not change between successive Paxos instances. From The Part-Time Parliament Section 3.1 (The Protocol of the Multi-Decree Parliament):
Therefore, Multi-Paxos makes the assumption that the case which you describe—when a second proposer comes online and believes he is (and always was) leader—will never happen. If such a case can happen, then one should not use Multi-Paxos. With respect to the second possibility—when the second proposer's
Prepare
did not reach the acceptor—the fact that the second proposer already sent out anAccept!
means that it previously sent out aPrepare
that wasPromised
by a quorum of acceptors. Since the acceptors already promised to the first proposer on roundN
, then the second proposer'sPrepare
must have been sent out prior to roundN
. Therefore, the finalAccept!(N+1,V2)
must have a counter less thanN
.Edit: It should also be noted that this version of the protocol is not robust to Byzantine failure:
也许一个更简单的答案是观察这种情况,即当Prepare(N+1)命令被不包括相关接受者的大多数人接受时。
详细说明:一旦领导者知道某些大多数人已承诺(N+1),它就会向所有接受者发送Accept(N+1,x),即使一些其他大多数接受者回复接受(N+1),则达成共识。
这种情况并不罕见。
Perhaps a simpler answer is to observe that this is the case when the Prepare(N+1) command was accepted by a majority that did not include the acceptor in question.
To elaborate: Once a leader knows that some majority has Promised(N+1), it then sends Accept(N+1,x) to all acceptors, and even if some other majority of acceptors reply with Accepted(N+1) then consensus has been reached.
This is not that unusual a scenario.
(回答我自己的问题。)
我目前的理解是,我不应该接受 N+1 中的值(即根本不回答或发送 NACK),从而迫使领导者可能开始另一轮准备(如果大多数人尚未达成共识)。当我收到Prepare(N+2)后,我将回复Promise(N+2, V1)并照常继续。
(Answering my own question.)
My current understanding is that I should not to accept the value in N+1 (i.e. not answer at all or send a NACK), thus forcing the leader to possibly start another round with Prepare (if the majority hasn't reached consensus yet). After I receive Prepare(N+2), I shall reply with Promise(N+2, V1) and continue as usual.