论文:The Part-Time Parliament
本篇整理 Leslie Lamport 的《The Part-Time Parliament》。每一页保留官方 PDF 的原始页面图;页面图是原文排版、Figure、脚注、附录伪代码和参考文献的原始副本,下面按 PDF 页序给出完整中文译文。Paxos、ballot、quorum、decree、ledger、Synod、state machine 等专用词按语境保留 English 或中英并列,不把约定俗成的术语生硬翻译。
论文:The Part-Time Parliament
相关文章:论文:Paxos Made Simple · 6.5840:Lecture 04 Fault-Tolerant Agreement and Paxos · 论文:Raft 可理解的共识算法(扩展版) · 论文:The Chubby Lock Service for Loosely-Coupled Distributed Systems
TL;DR
- 基本比喻:Paxos 岛上不愿全职工作的议员,对应 asynchronous distributed system 中随时可能 crash、恢复或离开的 process。
- 核心结论:通过 ballot number、相交的 quorum,以及“新 ballot 必须继承此前 quorum 中最高编号 vote 对应 decree”的约束,可以保证不同 successful ballot 不会选择冲突的 decree。
- Synod 到 Parliament:单个 decree 的 Synod 协议是 Paxos 的基础;multi-decree Parliament 为每个 decree number 运行一个逻辑上的 Synod instance,同时把前两个阶段合并复用。
- Safety 与 liveness 分离:消息丢失、重复、议员离开不会制造 inconsistency,但可能阻碍 progress;要保证 progress,需要稳定的 majority、超时、总统(president)选举,以及不频繁启动新 ballot 的规则。
- 计算机科学意义:这篇论文把 Paxos 与 replicated state machine 联系起来:分布式系统的通用部分负责让所有 server 获得相同的 command sequence,而具体应用只需要定义 state machine。
名词解释
| 名词 | 含义 | 本文译法 |
|---|---|---|
| ballot | 针对一个 decree 的一次投票及其编号、quorum、voters | ballot;必要处译为投票轮次 |
| quorum | ballot 关联的非空 priest 集合;ballot 成功要求 quorum 中所有人投票 | quorum;不强译成法定人数 |
| majority set | 任意两个该集合至少相交一个成员的集合族中的成员 | majority set |
| decree | 被 Synod/Parliament 选择的法令或 state-machine command | decree;例子中译为法令 |
| ledger | 议员携带、不可修改的 decree 记录 | ledger;例子中译为账簿 |
| Synod | 早期一次只选择一个 decree 的仪式性协议 | Synod |
| president | 负责发起 ballot 的单一协调者 | president;必要处译为总统/协调者 |
| state machine | 由 command/state 决定 response/state 的抽象机器 | state machine;状态机 |
| fail-stop | 节点停止工作且可被检测的故障模型 | fail-stop |
目录
| 章节 | 内容 |
|---|---|
| 版本与来源 | 官方 Microsoft Research 版本、固定文件和翻译边界 |
| 原文页面与逐页翻译 | 33 个 PDF 页面按原页保留、逐段翻译 |
| 机制索引 | ballot safety、progress、multi-decree 和 state-machine approach |
| 本篇验收 | 页面、图片、术语和覆盖范围检查 |
版本与来源
- 论文标题:The Part-Time Parliament。
- 作者:Leslie Lamport,Digital Equipment Corporation。
- 发表信息:ACM Transactions on Computer Systems 16(2),1998 年 5 月,pp. 133–169;PDF 首页注明 2000 年 8 月 29 日作过 minor corrections。
- 官方来源:Microsoft Research publication page;official PDF。
- 本地固定文件:
source/part-time-parliament.pdf。 - PDF 固定信息:33 页,每页 612×792 points;SHA-256:
93de820af20267fa2f227849fd7c5bc314cc867e6b88732c834cab9a24216f42。 - 附件处理:每页渲染为 1224×1584 PNG,存放于
assets/43 The Part-Time Parliament/,正文以600宽度嵌入。Figure 1、Figure 2、协议伪代码、附录 proof 和 References 均以原页图保留。 - 翻译边界:按原文段落、定义、定理、证明步骤、协议步骤、脚注和参考文献逐页翻译。原文 PDF 的 ACM copyright notice 保留在第 1 页原图中,并在译文中说明其含义;本笔记不把页面图中的版权文字省略。
原文页面与逐页翻译
第 1 页:标题与发表信息

标题与作者
《The Part-Time Parliament》
作者:Leslie Lamport。
本文发表于 ACM Transactions on Computer Systems 16(2),1998 年 5 月,pp. 133–169。2000 年 8 月 29 日进行了 minor corrections。
第 2 页:Abstract、编辑说明与版权声明

Abstract
最近在 Paxos 岛上的考古发现表明:尽管那些 part-time legislators 经常四处游走,Paxon Parliament 仍然能够正常运作。尽管议员经常离开 Chamber,messenger 又健忘,他们仍维护了彼此一致的 parliamentary record 副本。Paxon Parliament 的 protocol 为在 distributed system 设计中实现 state-machine approach 提供了一种新方法。
分类与主题词:C2.4「Computer-Communications Networks:Distributed Systems—Network operating systems」;D4.5「Operating Systems:Reliability—Fault-tolerance」;J.1「Administrative Data Processing:Government」。
General Terms:Design、Reliability。
Additional Key Words and Phrases:State machines、three-phase commit、voting。
编辑说明
这篇投稿最近在 TOCS editorial office 的 filing cabinet 后面被发现。尽管它年代久远,editor-in-chief 仍认为值得发表。由于作者目前正在 Greek isles 做 field work,无法联系到他,因此请我为它准备出版稿。
作者似乎是一位只对 computer science 有浅尝辄止兴趣的 archeologist。这很遗憾;虽然他描述的、神秘的古代 Paxon civilization 对大多数 computer scientist 兴趣不大,但其中的 legislative system 却是如何在 asynchronous environment 中实现 distributed computer system 的优秀模型。
事实上,Paxons 对 protocol 做出的一些 refinement 似乎在 systems literature 中都还没有出现。
作者确实在 Section 4 简短讨论了 Paxon Parliament 与 distributed computing 的关系。computer scientist 可能会想先读那一节;甚至在此之前,他们可能还想阅读 Lampson [1996] 对该 algorithm 面向 computer scientist 的解释。De Prisco 等人 [1997] 也给出了更 formal 的描述。我在 Section 4 末尾补充了一些关于 ancient protocol 与较新工作的评论。
Keith Marzullo
University of California, San Diego
版权说明译注:ACM 页面允许在不收取费用的情况下复制全部或部分材料,但副本不能用于直接商业利益;必须出现 ACM copyright notice、出版物标题和日期,并声明复制获得 Association for Computing Machinery 许可。其他复制或重新发表需要支付费用和/或取得具体许可。页面图中保留了原始 copyright notice。
第 3 页:The Problem、Island of Paxos 与 Requirements 开始

1 The Problem
1.1 The Island of Paxos
在这个 millennium 早期,Aegean Sea 上的 Paxos 岛是一个繁荣的 mercantile center。财富带来了政治上的成熟,Paxons 用 parliamentary form of government 取代了古老的 theocracy。但贸易优先于 civic duty,Paxos 没有人愿意把一生献给 Parliament。因此,即使 legislators 不断进出 parliamentary Chamber,Paxon Parliament 也必须继续运转。
治理一个 part-time parliament 的问题,与今天 fault-tolerant distributed system 面对的问题有惊人的对应关系:legislator 对应 process,而离开 Chamber 对应 failure。因此,Paxons 的解决方案可能会让 computer scientist 感兴趣。下面先介绍 Paxos Parliament protocol 的简短历史,再用更短的篇幅讨论它对 distributed system 的意义。
Paxon civilization 被 foreign invasion 摧毁,archeologist 直到最近才开始发掘它的历史。因此我们对 Paxon Parliament 的了解是零碎的。虽然 basic protocol 已经为人所知,但很多细节仍然未知。在这些细节有意义的地方,我会推测 Paxons 可能采取了什么做法。
1.2 Requirements
Parliament 的主要任务是确定国家法律;国家法律由它通过的 decree sequence 定义。现代 parliament 会雇用 secretary 记录行动,但在 Paxos,没有人愿意整个 session 都留在 Chamber 中担任 secretary。于是,每名 Paxon legislator 都维护一本 ledger,记录已经通过的、带编号的 decree sequence。例如,legislator Λ˘ινχ∂ 的 ledger 中有如下条目:
155: The olive tax is 3 drachmas per ton
这表示她相信 Parliament 通过的第 155 条 decree 把 olive tax 设为每吨 3 drachmas。ledger 用 indelible ink 书写,条目不能修改。
parliamentary protocol 的第一个要求是 ledger consistency,即任意两本 ledger 都不能包含互相矛盾的信息。如果 legislator Φισ∂ϵρ 的 ledger 有:
132: Lamps must use only olive oil
那么其他任何 legislator 的 ledger 都不能对 decree 132 记录不同内容。不过,如果另一位 legislator 尚未得知 decree 132 已通过,那么他的 ledger 可以没有该条目。
仅有 ledger consistency 还不够,因为把所有 ledger 都留空就能平凡地满足它。还需要某种要求,保证 decree 最终会被通过并记录到 ledger 中。
第 4 页:Requirements 完成与 Assumptions 开始

现代 parliament 中,通过 decree 会受到 legislators disagreement 的阻碍。Paxos 并非如此:那里存在 mutual trust 的氛围,Paxon legislators 愿意通过任何被提出的 decree。然而,他们四处游走的习惯造成了问题。
如果一组 legislators 通过了:
37: Painting on temple walls is forbidden
然后他们离开去参加 banquet,另一组完全不知道刚才发生了什么的 legislators 进入 Chamber,并通过互相冲突的:
37: Freedom of artistic expression is guaranteed
那么 consistency 就会丢失。
如果没有足够的 legislators 在 Chamber 中停留足够长时间,就无法保证 progress。Paxon legislators 不愿限制自己的外部活动,所以不可能保证任何 decree 一定会被通过。不过,他们愿意保证:只要在 Chamber 中,他们和 aides 就会及时处理所有 parliamentary matter。这一保证使 Paxons 能够设计出满足如下 progress condition 的 parliamentary protocol:
如果 legislators 的 majority 在 Chamber 中,并且在足够长的时间内没有人进入或离开 Chamber,那么在 Chamber 中由 legislator 提出的任何 decree 都会被通过;所有已经通过的 decree 都会出现在 Chamber 中每名 legislator 的 ledger 中。
1.3 Assumptions
只有为 legislators 提供必要资源,parliamentary protocol 的要求才有可能实现。每名 legislator 都得到一本结实的 ledger、一支 pen 和一批 indelible ink。legislators 离开 Chamber 后可能忘记自己之前做过什么,因此会在 ledger 背面写 notes,提醒自己重要的 parliamentary task。decree list 中的条目永远不能修改,但 notes 可以划掉。
要满足 progress condition,legislators 必须能够测量时间流逝,因此他们得到简单的 hourglass timer。
legislators 始终携带 ledger,并且随时可以阅读 decree list 和任何尚未被划掉的 note。ledger 用最好的 parchment 制作,只用于最重要的 notes。其他 notes 会写在 slip of paper 上;legislator 离开 Chamber 时可能会丢失它。
Chamber 的 acoustics 很差,无法进行 oratory。legislators 只能通过 messenger 通信,并得到经费来雇用任意数量的 messenger。messenger 不会把消息传错,但可能忘记自己已经送过某条消息,又把它送一遍。和他们服务的 legislators 一样,messenger 也只把部分时间用于 parliamentary duty;messenger 可能离开 Chamber 去办事——也许会进行一次为期六个月的 voyage——然后才交付消息;他甚至可能永远离开,使得消息永远无法送达。
第 5 页:Assumptions 完成与 Single-Decree Synod

legislators 和 messengers 可以随时进入和离开 Chamber;但在 Chamber 内时,他们会专注于 Parliament 的事务。只要他们留在 Chamber 中,messenger 就会及时交付消息,legislator 也会迅速响应收到的消息。
Paxos 的官方记录声称 legislators 和 messengers 都极其诚实,并严格遵守 parliamentary protocol。大多数学者认为这是 propaganda,目的是把 Paxos 描绘得比 eastern neighbors 更有道德。dishonesty 虽然罕见,但肯定发生过。然而,因为官方文档从不提及它,我们几乎不知道 Parliament 如何应对 dishonest legislators 或 messengers。现有证据将在 Section 3.3.5 讨论。
2 The Single-Decree Synod
Paxon Parliament 源自更早的、每 19 年召开一次、用于选择单个 symbolic decree 的 ceremonial Synod。几个世纪以来,Synod 使用要求所有 priests 到场的 conventional procedure 选择 decree。但随着 commerce 繁荣,priests 开始在 Synod 进行期间进出 Chamber。最终,旧 protocol 失效,Synod 结束时没有选出 decree。
为防止这场 theological disaster 重演,Paxon religious leaders 请 mathematicians 制定选择 Synod decree 的 protocol。它的 requirements 和 assumptions 与后来的 Parliament 基本相同,区别是 ledger 最多只包含一个 decree,而不是 decree sequence。这里描述得到的 Synod protocol;Parliament protocol 在 Section 3 描述。
mathematicians 分几个步骤推导 Synod protocol。首先,他们证明了一些结果:满足特定 constraints 的 protocol 将保证 consistency 且允许 progress。随后直接从这些 constraints 推导出 preliminary protocol。preliminary protocol 的 restricted version 提供了保证 consistency、但不保证 progress 的 basic protocol。再通过进一步 restrict basic protocol,得到同时满足 consistency 和 progress requirements 的 complete Synod protocol。数学结果见 Section 2.1,protocol 的 informal description 见 Sections 2.2–2.4,basic protocol 的更 formal description 和 correctness proof 见 appendix。
脚注 4:Synod protocol 被发现的完整历史未知。和现代 computer scientist 一样,Paxon mathematicians 会描述优雅、逻辑严密的 derivation,但那通常与 algorithm 实际被推导出来的过程毫无相似之处。不过已知数学结果(Section 2.1 的 Theorems 1 和 2)确实先于 protocol 被发现;mathematicians 当时正试图证明 satisfactory protocol 不可能,于是发现了这些结果。
第 6 页:Ballot 定义与 B1–B3

2.1 Mathematical Results
Synod 的 decree 通过一系列带编号的 ballot 选择。一个 ballot 是针对单个 decree 的 referendum。在每个 ballot 中,priest 只有两个选择:投票支持 decree,或者不投票。
一个 ballot 关联一个称为 quorum 的 priest 集合。一个 ballot 成功,当且仅当 quorum 中每名 priest 都投票支持 decree。形式上,ballot B 由如下四个部分组成(除非另有说明,set 表示 finite set):
Bdec:decree,即本 ballot 投票的对象;Bqrm:非空 priest set,即 ballot 的 quorum;Bvot:投票支持 decree 的 priest set;Bbal:ballot number。
当 Bqrm ⊆ Bvot 时,称 ballot B successful,即 quorum 的每个成员都投了票。
ballot number 从一个无界的 ordered set 中选择。如果 B′bal > Bbal,则称 ballot B′ later than ballot B。但这并不表示实际执行顺序:later ballot 可能实际上在 earlier ballot 之前发生。
Paxon mathematicians 对 ballot set B 定义了三个 condition,并证明:如果已经发生的 ballot set 满足这些条件,就能保证 consistency 且 progress 是可能的。前两个条件很简单,可以 informal 地表述如下:
B1(B):B 中每个 ballot 都有 unique ballot number。
B2(B):B 中任意两个 ballot 的 quorum 至少包含一个共同 priest。
第三个条件更复杂。某份 Paxon manuscript 中这样写道:
B3(B):对于 B 中每个 ballot B,如果 B 的 quorum 中有任何 priest 在 B 之前的 ballot 中投过票,那么 B 的 decree 等于那些 earlier ballot 中编号最大的那个 ballot 的 decree。
Figure 1 中的 manuscript 帮助解释了 B3(B)。它展示了一个由五个 ballot 组成的 set B,Synod 有五名 priest:A、B、Γ、∆、E。对每个 ballot,quorum 中名字被方框圈出的 priest 构成 voters。
例如,ballot 14 的 decree 是 α,quorum 包含三名 priest,而 voter 有两名。B3(B) 的形式是“对 B 中每个 B:……”,其中省略部分是关于该 ballot B 的 condition。Figure 1 中五个 ballot 的具体条件在下一页解释。
脚注:像一些 modern nation 一样,Paxos 还没有完全理解 Athenian democracy 的本质。
脚注:虽然 Paxon mathematicians 在当时非常先进,但显然还不知道 set theory。我把 Paxons 更原始的 notation 翻译成现代 set theory 的语言。
脚注:实际上只有 quorum 中的 priests 投票,但 Paxon mathematicians 发现,在 proof 中允许任意 priest 在任意 ballot 中投票,更容易让人相信 protocol 是正确的。
第 7 页:Figure 1 与形式化 notation

Figure 1. Paxon manuscript 展示了满足 B1(B)–B3(B) 的五个 ballot 构成的 set B。解释性 column heading 是后来加上的。
对 Figure 1 的五个 ballot,B3 的条件如下:
- 2:ballot number 2 是最早的 ballot,因此该 ballot 上的 condition 平凡为真。
- 5:ballot 5 的四名 quorum member 没有人在 earlier ballot 中投票,所以该 condition 也平凡为真。
- 14:ballot 14 的 quorum 中,唯一在 earlier ballot 中投过票的成员是 ∆;他在 ballot 2 中投票。因此条件要求 ballot 14 的 decree 必须等于 ballot 2 的 decree。
- 27:这是一个 successful ballot。它的 quorum member 是 A、Γ、∆。A 没有在 earlier ballot 中投票;Γ 投过票的唯一 earlier ballot 是 5;∆ 投过票的唯一 earlier ballot 是 2。这两个 earlier ballot 中较晚的是 ballot 5,因此条件要求 ballot 27 的 decree 必须等于 ballot 5 的 decree。
- 29:ballot 29 的 quorum member 是 B、Γ、∆。B 参加过的唯一 earlier ballot 是 14;Γ 参加过 5 和 27;∆ 参加过 2 和 27。这四个 earlier ballot 中最晚的是 27,因此条件要求 ballot 29 的 decree 必须等于 ballot 27 的 decree。
要形式化表达 B1(B)–B3(B),还需要更多 notation。一个 vote v 是由三部分组成的 quantity:priest vpst、ballot number vbal 和 decree vdec。它表示 priest vpst 在 ballot number vbal 中为 decree vdec 投票。
Paxons 还定义了 null vote:如果 vbal = −∞ 且 vdec = blank,则 v 是 null vote,其中对任意 ballot number b 都有 −∞ < b < ∞,而 blank 不是一个 decree。对每个 priest p,nullp 表示 vpst = p 的唯一 null vote。
Paxon mathematicians 为所有 vote 定义了 total ordering,但包含定义的 manuscript 部分遗失了。残存部分表明:如果 vbal < v′bal,那么 v < v′。当 vbal = v′bal 时,v 和 v′ 的相对顺序如何定义,已经无人知晓。
对于 ballot set B,Votes(B) 是其中所有 vote 的集合:存在某个 B ∈ B,使得 vpst ∈ Bvot、vbal = Bbal 且 vdec = Bdec。
如果 p 是 priest,b 是 ballot number 或 ±∞,那么 MaxVote(b, p, B) 定义为:B 中由 p 投出的、且 vbal < b 的最大 vote;若不存在这样的 vote,则为 nullp。
如果 Q 是非空 priest set,则 MaxVote(b, Q, B) 定义为所有 Q 中 priest 的 MaxVote(b, p, B) 的 maximum。
第 8 页:B1–B3 形式化与 Lemma proof

B1(B)–B3(B) 的形式化表达如下:
B1(B) ≜ ∀B, B′ ∈ B : (B ≠ B′) ⇒ (Bbal ≠ B′bal)
B2(B) ≜ ∀B, B′ ∈ B : Bqrm ∩ B′qrm ≠ ∅
B3(B) ≜ ∀B ∈ B : (MaxVote(Bbal, Bqrm, B)bal ≠ −∞) ⇒
(Bdec = MaxVote(Bbal, Bqrm, B)dec)
虽然 MaxVote 的定义依赖于 vote ordering,但 B1(B) 保证 MaxVote(b, Q, B)dec 不依赖于如何排列 ballot number 相同的 vote。
为证明这些 condition 能推出 consistency,Paxons 首先证明:如果 B ∈ B successful,那么 B 之后的 B′ ∈ B 必须使用相同 decree。
Lemma:若 B1(B)、B2(B) 和 B3(B) 成立,则对任意 B、B′ ∈ B:
((Bqrm ⊆ Bvot) ∧ (B′bal > Bbal)) ⇒ (B′dec = Bdec)
Lemma proof:对于 B ∈ B,定义 Ψ(B, B) 为 B 之后、且 decree 与 B 不同的 ballot 集合:
Ψ(B, B) ≜ {B′ ∈ B : (B′bal > Bbal) ∧ (B′dec ≠ Bdec)}
要证明 lemma,只需证明当 Bqrm ⊆ Bvot 时 Ψ(B, B) 为空。Paxons 采用 contradiction proof。假设存在一个 successful B,且 Ψ(B, B) ≠ ∅,然后如下得到矛盾:
- 选择
C ∈ Ψ(B, B),使Cbal = min{B′bal : B′ ∈ Ψ(B, B)}。因为Ψ(B, B)非空且 finite,所以这样的C存在。 - 由于
Bqrm与Cqrm都是 majority set,根据 B2(B),选择q ∈ Bqrm ∩ Cqrm。 - 因为
Bqrm ⊆ Bvot,q在B中投票;所以MaxVote(Cbal, q, B)bal ≥ Bbal。 - 根据第 2、3 步以及
MaxVote的定义,MaxVote(Cbal, Cqrm, B)bal ≥ Bbal。 - 该
MaxVote属于Votes(B);因为第 4 步表明它不是 null vote。 - 根据 B3(B),
MaxVote(Cbal, Cqrm, B)dec = Cdec。 - 根据第 6 步、第 1 步以及
Ψ(B, B)的定义,有MaxVote(Cbal, Cqrm, B)dec ≠ Bdec。 - 根据第 4 步,且 B1(B) 和第 7 步表明 ballot number 不相等,有
MaxVote(Cbal, Cqrm, B)bal > Bbal。 - 根据第 7、8 步和
Ψ(B, B)的定义,MaxVote(Cbal, Cqrm, B) ∈ Votes(Ψ(B, B))。 - 根据
MaxVote的定义,MaxVote(Cbal, Cqrm, B)bal < Cbal。 - 但第 9、10 步与第 1 步矛盾:第 1 步选择了
Ψ(B, B)中 ballot number 最小的 ballot。
Lemma 得证。
第 9 页:Theorem 1 与 Theorem 2

由该 lemma 很容易证明:如果 B1–B3 成立,任意两个 successful ballot 都使用相同的 decree。
Theorem 1:若 B1(B)、B2(B) 和 B3(B) 成立,则对任意 B, B′ ∈ B:
((Bqrm ⊆ Bvot) ∧ (B′qrm ⊆ B′vot)) ⇒ (B′dec = Bdec)
Proof:如果 B′bal = Bbal,B1(B) 说明 B′ = B。如果 B′bal ≠ Bbal,定理立即由 lemma 得出。
Paxons 接着证明了另一个 theorem:如果 Chamber 中有足够多的 priests,就可以在维护 B1–B3 的情况下执行一个 successful ballot。虽然这不能保证 progress,但至少说明基于 B1–B3 的 balloting protocol 不会 deadlock。
Theorem 2:设 b 是 ballot number,Q 是 priest set,满足 b > Bbal 且对所有 B ∈ B 有 Q ∩ Bqrm ≠ ∅。如果 B1(B)、B2(B) 和 B3(B) 成立,那么存在 ballot B′,使:
B′bal = b
B′qrm = B′vot = Q
并且 B1、B2、B3 在 B ∪ {B′} 上仍成立。
Proof:B1(B ∪ {B′}) 由 B1(B)、B′bal 的选择和关于 b 的假设推出。B2(B ∪ {B′}) 由 B2(B)、B′qrm 的选择以及 Q 的假设推出。如果 MaxVote(b, Q, B)bal = −∞,令 B′dec 为任意 decree;否则令它等于 MaxVote(b, Q, B)dec。于是 B3(B ∪ {B′}) 由 B3(B) 推出。
第 10 页:Preliminary Protocol 的推导

2.2 The Preliminary Protocol
Paxons 从“必须保持 ballot set B 的 B1(B)–B3(B) 成立”这一要求推导 preliminary protocol。B 是所有已经或正在进行的 ballot 集合。protocol 定义了 B 如何变化,但从未显式计算它。Paxons 称 B 是只有 gods 才能观察到的 quantity,因为任何 mortal 可能永远不知道它的完整内容。
每个 ballot 由一名 priest 发起,他选择 ballot number、decree 和 quorum。quorum 中每名 priest 再决定是否为该 ballot 投票。initiator 如何选择 ballot number、decree 和 quorum,以及 priest 如何决定是否投票,均直接从保持 B1(B)–B3(B) 的需要推导出来。
要保持 B1,每个 ballot 必须获得 unique number。priest 可以用 ledger 中的 notes 记住自己过去发起过哪些 ballot,从而轻易避免用相同 number 发起两个不同 ballot。为避免不同 priest 发起相同 number 的 ballot,possible ballot number 被 partition 给各个 priest。虽然不知道 Paxons 具体如何做,但明显的方法是把 ballot number 设为由 integer 和 priest 组成的 pair,并使用 lexicographical ordering。例如,若 Γ 在 Paxon alphabet 中排在 Λ 前面,则:
(13, Γρα˘ι) < (13, Λινσϵ˘ι) < (15, Γρα˘ι)
不管具体方法如何,已知每名 priest 都拥有一组无界的 ballot number,专供自己使用。
要保持 B2,一个 ballot 的 quorum 必须包含一个 µαδζ∂ωριτ˘ισϵτ。最初这个词只表示 simple majority。后来人们注意到 fat priest 移动得更慢、在 Chamber 中停留更久,因此它改为表示任意一个 priest set,只要这些 priest 的 total weight 超过所有 priest 总 weight 的一半,而不是简单的 priest 数量 majority。thin priest group 抱怨这不公平后,actual weight 又被替换成根据 attendance record 得到的 symbolic weight。
µαδζ∂ωριτ˘ισϵτ 的主要要求是:任意两个包含它的 priest set 至少有一个共同 priest。为保持 B2,initiating priest 选择 Bqrm 为 majority set。
Condition B3 要求:如果 MaxVote(b, Q, B)dec 不为 blank,那么 ballot number 为 b、quorum 为 Q 的 ballot 必须使用 decree MaxVote(b, Q, B)dec;如果它为 blank,该 ballot 可以使用任意 decree。
因此,在用 ballot number b 和 quorum Q 发起新 ballot 之前,priest p 必须找到 MaxVote(b, Q, B)dec。为此,p 要为 Q 中每名 priest q 找到 MaxVote(b, q, B)。
回顾一下:MaxVote(b, q, B) 是 q 在 ballot number 小于 b 的所有 ballot 中投出的、拥有最大 ballot number 的 vote;若 q 没在任何小于 b 的 ballot 中投票,则为 nullq。priest p 通过 message exchange 从 q 获取它。因此,单个 ballot protocol 的前两步是:
- priest
p选择新的 ballot numberb,并向某个 priest set 发送NextBallot(b)message; - priest
q收到NextBallot(b)后,向p发送LastVote(b, v),其中v是q投出的、ballot number 小于b的 vote 中最大者;如果不存在这样的 vote,则发送nullq。
脚注:priests
p和q可以是同一个 priest。为了简单起见,protocol 在这种情况下描述为p向自己发送 message;现实中 priest 可以直接与自己交谈,不需要 messenger。
第 11 页:Preliminary Protocol 的四步

当 q 发送 LastVote(b, v) 时,v = MaxVote(b, q, B)。但 ballot set B 会随着新 ballot 发起和新 vote 投出而改变。由于 priest p 将使用 v 作为选择 decree 时的 MaxVote(b, q, B),为了维持 B3(B),必须保证 q 发送 message 后 MaxVote(b, q, B) 不再变化。
为防止变化,q 不能在 vbal 与 b 之间的 ballot number 中投出新 vote。通过发送 LastVote(b, v),q 承诺不在该区间投票。为履行承诺,q 必须把必要信息记录在 ledger 中。
balloting protocol 的后两步是:
- priest
p从某个 majority setQ的每名 priest 收到LastVote(b, v)后,发起 number 为b、quorum 为Q、decree 为d的新 ballot;d按 B3 选择。然后把 ballot 记录在 ledger 背面,并向Q中每名 priest 发送BeginBallot(b, d)。 - priest
q收到BeginBallot(b, d)后,决定是否在 ballotb中投票。如果这样做会违反它此前为其他 ballot 发送的LastVote(b′, v′)所隐含的 promise,则不能投票。如果决定投票,则向p发送Voted(b, q),并把 vote 记录在 ledger 背面。
执行第 3 步被视为向 B 添加 ballot B:Bbal = b、Bqrm = Q、Bvot = ∅(还没有人投票)、Bdec = d。在第 4 步中,如果 q 决定投票,则执行该步骤被视为把 q 加入 Bvot。
即使投票不会违反此前 promise,priest 也可以选择不投票。事实上,该 protocol 的所有步骤都是 optional。例如,priest q 可以忽略 NextBallot(b),不执行第 2 步。不采取 action 可能阻止 progress,但不能造成 inconsistency,因为它不会使 B1(B)–B3(B) 变为 false。类似地,未收到消息的唯一效果是阻止 action 发生,因此 message loss 也不会造成 inconsistency。于是,即使 priests 离开 Chamber 或消息丢失,protocol 仍保证 consistency。
收到同一 message 的多个副本可能使 action 重复执行。除第 3 步外,重复执行 action 没有影响。例如,第 4 步发送多次 Voted(b, q) 与只发送一次的效果相同。第 3 步的重复通过 ledger 背面执行时写入的 entry 防止。因此,即使 messenger 多次投递同一 message,consistency 仍然保持。
步骤 1–4 描述了发起 ballot 并进行投票的完整 protocol。
第 12 页:Preliminary Protocol 结束与 Basic Protocol

剩下的问题是确定 balloting result,并宣布 decree 何时被选中。回顾:当且仅当 quorum 中每名 priest 都投票时,ballot successful。successful ballot 的 decree 就是 Synod 选择的 decree。
其余 protocol 是:
- 如果
p已从Q(ballotb的 quorum)中每名 priestq收到Voted(b, q),那么他把该 ballot 的 decreed写入 ledger,并向每名 priest 发送Success(d)。 - priest 收到
Success(d)后,把 decreed写入 ledger。
步骤 1–6 描述单个 ballot 如何进行。preliminary protocol 允许任意 priest 在任意时刻发起新 ballot。每一步都保持 B1(B)–B3(B),因此整个 protocol 也保持这些条件。由于 priest 只会在 successful ballot 的 decree 是什么时才把 decree 写入 ledger,Theorem 1 说明所有 priest 的 ledger 都一致。protocol 尚未处理 progress 问题。
在第 3 步,如果 decree d 由 B3 确定,那么它可能已经写在某个 priest 的 ledger 中。该 priest 不必属于 quorum Q,他可能已经离开 Chamber。因此,如果第 3 步允许在选择 d 时拥有更大自由度,就无法保证 consistency。
2.3 The Basic Protocol
在 preliminary protocol 中,priest 必须记录:(i)自己发起过的每个 ballot 的 number;(ii)自己投过的每个 vote;(iii)自己发送过的每条 LastVote message。对忙碌的 priests 来说,维护这些信息很困难。因此 Paxons 把 preliminary protocol restrict 成更实用的 basic protocol;其中每名 priest p 只需在 ledger 背面维护:
lastTried[p]:p最后尝试发起的 ballot number;如果没有,则为−∞。prevVote[p]:p投过票的、number 最大的 ballot 中的 vote;如果从未投过票,则为−∞。nextBal[p]:p发送过LastVote(b, v)message 的最大b;如果从未发送,则为−∞。
preliminary protocol 的步骤 1–6 描述 initiator p 如何执行单个 ballot。preliminary protocol 允许 p 并发执行任意多个 ballot;basic protocol 中,p 一次只执行一个 ballot,即 ballot number lastTried[p]。p 发起该 ballot 后,会忽略与此前发起的其他 ballot 有关的消息。p 把当前 ballot 的进展信息都保存在 slip of paper 上;如果丢失该纸条,就停止执行这个 ballot。
在 preliminary protocol 中,priest q 发送的每条 LastVote(b, v) 表示:不会在 vbal 与 b 之间的 ballot number 中投出新 vote。在 basic protocol 中,它表示更强的 promise:不会在小于 b 的任何 ballot 中投出新 vote。更强的 promise 可能阻止 q 在 basic protocol 的第 4 步投出一个 preliminary protocol 原本允许的 vote;但由于 preliminary protocol 总是允许 q 不投票,basic protocol 并没有要求 q 做任何 preliminary protocol 不允许的事情。
第 13 页:Basic Protocol 六步与 Complete Protocol 开始

basic protocol 执行 ballot 的六步如下(除 lastTried[p]、prevVote[p] 和 nextBal[p] 外,p 执行 ballot 所需的其他信息都在 slip of paper 上):
- priest
p选择一个大于lastTried[p]的新 ballot numberb,把lastTried[p]设为b,并向某个 priest set 发送NextBallot(b)。 - priest
q收到p发来的NextBallot(b),且b > nextBal[q]时,把nextBal[q]设为b,并向p发送LastVote(b, v),其中v = prevVote[q]。如果b ≤ nextBal[q],忽略NextBallot(b)。 p从某个 majority setQ的每名 priest 收到LastVote(b, v),且b = lastTried[p]时,发起 number 为b、quorum 为Q、decree 为d的 ballot;d按 B3 选择。随后向Q的每名 priest 发送BeginBallot(b, d)。q收到BeginBallot(b, d)且b = nextBal[q]时,在 ballotb中投票,把prevVote[q]设置为该 vote,并向p发送Voted(b, q)。如果b ≠ nextBal[q],忽略该 message。p收到Q中每名q发来的Voted(b, q),且b = lastTried[p]时,把该 ballot 的 decreed写入 ledger,并向每名 priest 发送Success(d)。- priest 收到
Success(d)后,把 decreed写入 ledger。
basic protocol 是 preliminary protocol 的 restricted version:basic protocol 允许的每个 action,preliminary protocol 也允许。因为 preliminary protocol 满足 consistency,basic protocol 也满足。和 preliminary protocol 一样,basic protocol 不要求任何 action 必须执行,所以没有涉及 progress。
从 B1–B3 推导 basic protocol 的过程让 consistency 看起来很“显然”。但一些同样“显然”的古代 wisdom 后来被证明是错的,skeptical citizens 要求更严格的 proof。因此 Paxon mathematicians 对 basic protocol consistency 的 proof 被保存在 appendix 中。
2.4 The Complete Synod Protocol
basic protocol 保持 consistency,但不能确保 progress,因为它只说明 priest 可以做什么,并不要求 priest 做任何事。complete protocol 仍使用 basic protocol 的六步;为帮助 achieve progress,它增加了 priests 尽快执行步骤 2–6 的要求。
然而,为满足 progress condition,还必须要求某个 priest 执行发起 ballot 的第 1 步。complete protocol 的关键是确定 priest 什么时候应该发起 ballot。
永远不发起 ballot 当然会阻止 progress。但发起太多 ballot 也可能阻止 progress。如果 b 大于其他所有 ballot number,那么 priest q 在第 2 步收到 NextBallot(b) 时,可能会作出一个 promise,使它无法在此前已发起的 ballot 中执行第 4 步投票。
第 14 页:Complete Synod Protocol 的时间分析

因此,如果在前一个 ballot 有机会成功前不断发起递增 ballot,可能一个 decree 都无法通过。
实现 progress condition 要求不断发起新 ballot,直到某一个成功;但又不能发起得太频繁。Paxons 首先测量 messenger 传递 message 和 priest 响应所需的时间:只要 messenger 不离开 Chamber,它总能在 4 分钟内传递 message;只要 priest 留在 Chamber,它总能在触发 action 的 event 后 7 分钟内执行 action。
因此,如果 event 发生时 p 和 q 都在 Chamber 中,p 向 q 发 message,q 回应 p,并且两个 messenger 都没有离开 Chamber,那么 p 会在 22 分钟内收到 reply:p 最多 7 分钟后发出 message,q 最多 4 分钟后收到,最多 7 分钟后响应,reply 再最多 4 分钟送回。
假设只有一个 priest p 发起 ballot,并在第 1 步向每名 priest 发 message。如果 p 在一个 majority set 的 priests 都在 Chamber 时发起 ballot,那么他可以预计在 22 分钟内执行第 3 步,再过 22 分钟执行第 5 步。如果没有在这些时间内执行成功,要么某个 priest 或 messenger 在 p 发起 ballot 后离开了 Chamber,要么在 p 成为唯一 initiator 前,另一个 priest 已经发起了更高 number 的 ballot。
为处理后一种情况,p 必须知道其他 priest 使用的、比 lastTried[p] 更大的 ballot number。可以把 protocol 扩展为:如果 priest q 从 p 收到 b < nextBal[q] 的 NextBallot(b) 或 BeginBallot(b, d),就向 p 发送包含 nextBal[q] 的 message。于是 p 能发起更大的 ballot。
仍假设 p 是唯一发起 ballot 的 priest。假设要求他仅当以下条件之一成立时发起新 ballot:(i)过去 22 分钟内没有执行第 3 步或第 5 步;(ii)得知另一个 priest 发起了更高 number 的 ballot。
如果 Chamber door 锁上时 p 和一个 majority set 的 priests 都在里面,那么 99 分钟内会有 decree 被通过并写入 Chamber 内所有 priest 的 ledger:可能先花 22 分钟让 p 开始下一个 ballot,再花 22 分钟得知更大 ballot,之后花 55 分钟完成 successful ballot 的步骤 1–6。因此,只要由一个没有离开 Chamber 的 priest 发起 ballot,就能满足 progress condition。
于是 complete protocol 包含一个选择单个 priest(称为 president)的 procedure,由他发起 ballot。在大多数 government 中,选 president 可能很难;但困难来自“任何时刻必须恰好有一个 president”的要求。在 United States,如果一些人认为 Bush 是 president,而另一些人认为 Dukakis 是 president,可能会导致 chaos,因为其中一个可能决定签署 bill,另一个则决定否决它。但在 Paxon Synod 中,多个 president 只会阻碍 progress,不会造成 inconsistency。
脚注 11:这里假设
δζ∂ιφ˘ι(Paxon time unit)为 30 秒。这个数值在对 hourglass shard 的研究所确定的范围内。priest 的 reaction time 很长,是因为即使多个 message 同时到达,他们也必须在 7 分钟(14 个δζ∂ιφ˘ι)内响应每条 message。
第 15 页:President selection 与 Complete Protocol 结论

要使 complete protocol 满足 progress condition,president selection method 只需满足:
如果没有人进入或离开 Chamber,那么在
T分钟之后,Chamber 中恰好有一名 priest 认为自己是 president。
如果满足该 presidential selection requirement,那么 complete protocol 具备如下性质:如果 majority set 的 priests 在 Chamber 中,并且在 T + 99 分钟内无人进出 Chamber,那么在这段时间结束时,Chamber 内每名 priest 的 ledger 都会写入一个 decree。
Paxons 选择 Chamber 中名字按 alphabetic order 排在最后的 priest 作为 president,但我们不知道具体如何实现。只要在 Chamber 中的 priest 至少每 T − 11 分钟向其他每名 priest 发送一次包含自己名字的 message,并且 priest 在 T 分钟内没有收到名字更高的 priest 的 message 时认为自己是 president,该 selection requirement 就能满足。
complete Synod protocol 从 basic protocol 得到:要求 priests 及时执行步骤 2–6,增加选择 president 的 method 以发起 ballot,并要求 president 在适当时间发起 ballot。protocol 的许多细节未知。上面描述了选择 president 和决定何时发起新 ballot 的简单方法,但它们肯定不是 Paxos 实际使用的方法。
上述规则会让 president 在 decree 选出后仍持续发起 ballot,以确保刚进入 Chamber 的 priests 得知已选择的 decree。显然还有更好的方式让 priests 得知 decree。并且,在选 president 的过程中,每名 priest 可能已经向其他 priests 发送了 lastTried[p],这样 president 就能在第一次尝试时选择足够大的 ballot number。
Paxons 意识到,任何满足 progress condition 的 protocol 都必须涉及时间流逝的测量。不过,未来还要过许多世纪,Fischer 等人 [1985] 才严格证明这一点。
上述选择 president 和发起 ballot 的 protocol 很容易写成精确 algorithm:设置 timer,并在 timeout 时执行 action——前提是假设 timer 完全准确。更仔细的分析表明,只要知道 timer accuracy 的 bound,protocol 仍可工作。Paxos 熟练的 glass blower 能够制造合适的 hourglass timer。
鉴于 Paxon mathematicians 的 sophistication,人们普遍相信他们一定找到了满足 presidential selection requirement 的 optimal algorithm。我们只能希望,未来 Paxos 的 excavation 能发现这个 algorithm。
脚注 12:不过,直到 Fischer 等人 [1985] 才给出该结果的 rigorous proof。
第 16 页:Multi-Decree Parliament 的协议推导

3 The Multi-Decree Parliament
Parliament 建立后,从 Synod protocol 推导出满足 consistency 和 progress requirements 的 protocol。原始 parliamentary protocol 的 derivation 和 properties 在 Sections 3.1、3.2 描述;Section 3.3 讨论 protocol 后续的 evolution。
3.1 The Protocol
Parliament 不只通过一个 decree,而是必须通过一系列编号 decree。和 Synod protocol 一样,它选出一个 president。任何希望通过 decree 的人都会通知 president,president 为 decree 分配 number 并尝试通过它。
从逻辑上说,parliamentary protocol 为每个 decree number 使用 complete Synod protocol 的一个独立 instance。但所有 instance 共享一个 president,并且 president 只执行 Synod protocol 的前两步一次。
推导 parliamentary protocol 的关键观察是:在 Synod protocol 中,president 要到第 3 步才选择 decree 和 quorum。新选出的 president p 可以向某个 priest set 发送一条 message,作为所有 Synod instance 的 NextBallot(b) message;instance 数量是无限的,每个 decree number 对应一个 instance。
legislator q 可以用一条 message 回复,作为所有 Synod instance 第 2 步的 LastVote message。由于 q 只可能在有限多个 instance 中投过票,所以这条 message 只需要包含有限信息。
新 president 从某个 majority set 的每名成员收到 reply 后,就准备好为每个 Synod instance 执行第 3 步。对于有限多个 instance(decree number),第 3 步中的 decree 选择会被 B3 确定。president 立即为这些 instance 执行第 3 步,尝试通过这些 decree。
此后,每当收到通过 decree 的 request,他就选择自己仍可自由选择的最低 decree number,并为该 number 对应的 Synod instance 执行第 3 步,尝试通过该 decree。
以下对 simple protocol 的 modification 得到实际 Paxon Parliament protocol:
-
对 outcome 已知的 decree number 没有必要再走 Synod protocol。因此,如果新选出的 president
p的 ledger 已写有所有≤ n的 decree,他就发送NextBallot(b, n)。这条 message 作为所有 decree number 大于n的 Synod instance 的NextBallot(b)message。legislatorq回复时,除了发送对于不在 ledger 中的 decree 所需的 usualLastVoteinformation 外,还会告知p自己 ledger 中已经出现的、大于n的所有 decree,并要求p把≤ n中自己缺少的 decree 发给他。 -
假设周五下午很晚时引入 decrees 125 和 126,decree 126 已通过并写入一两本 ledger,但在其他事情发生前所有 legislators 都回家过周末。下周一,新 president ∆φωρκ 得知 decree 126,却不知道 decree 125,因为上一任 president 以及所有投票支持它的 legislators 仍不在 Chamber。她会发起一个通过 decree 126 的 ballot,导致 ledger 出现 gap。
第 17 页:Gap filling 与 decree ordering

把 number 125 分配给新 decree,会使它出现在 ledger 中已于上一周通过的 decree 126 之前。这样 out-of-order 地通过 decree 可能造成 confusion,例如,提出新 decree 的 citizen 可能正是因为知道 decree 126 已经通过才提出它。
因此 ∆φωρκ 会尝试通过如下 traditional decree,它实际上对 Paxos 的任何人都没有影响:
125: The ides of February is national olive day
一般而言,新 president 会通过“olive-day” decree 填补 ledger 中的 gap。
parliamentary protocol 的 consistency 和 progress properties 直接由它所派生的 Synod protocol 对应 properties 得出。就我们所知,Paxons 从未为 parliamentary protocol 写过精确描述,因为它很容易从 Synod protocol 推导出来。
3.2 Properties of the Protocol
3.2.1 The Ordering of Decrees
不同 decree number 的 balloting 可以并发进行;不同 legislator 也可能在以为自己是 president 时发起 ballot。尤其在不知道 president 如何选择的情况下,我们无法精确说出 decree 会按什么顺序通过。但可以推导出一个关于 decree ordering 的重要 property。
当某个 decree 在对应 Synod instance 的第 3 步被 president 选中时,称它 proposed;当它第一次写入某本 ledger 时,称它 passed。
在 president 能提出任何新 decree 之前,他必须从某个 majority set 的所有成员那里得知他们投过哪些 decree。任何已经 passed 的 decree,至少被该 majority set 中的一名 legislator 投过票。因此 president 必须在发起任何新 decree 前得知所有已经 passed 的 decree。
president 不会用重要 decree 填补 ledger gap,即不会填入除“olive-day”外的 decree;也不会 out of order 地 propose decree。因此 protocol 满足:
如果重要 decree A 在重要 decree B proposed 之前 passed,那么 A 的 decree number 小于 B 的 decree number。
3.2.2 Behind Closed Doors
尽管不知道新 president 的选举细节,但可以准确描述:president 已选出且没有人进出 Chamber 时 Parliament 如何运行。
收到通过 decree 的 request 后——request 可以直接来自 citizen,也可以由另一名 legislator 转交——president 分配 decree number,并通过如下 message exchange(括号中的数字对应 Synod protocol 步骤):
第 18 页:Closed-door message cost 与 protocol evolution

-
president 向 quorum 中的每名 legislator 发送
BeginBallotmessage。 -
quorum 中每名 legislator 向 president 发送
Votedmessage。 -
president 向每名 legislator 发送
Successmessage。
假设 Parliament 有 N 名 legislators,quorum 大约为 N/2,这总共需要三个 message delay 和约 3N 条 message。而且,如果 Parliament 很忙,president 可以把一个 decree 的 BeginBallot message 与前一个 decree 的 Success message 合并发送,因此每个 decree 只需约 2N 条 message。
3.3 Further Developments
治理 Paxos 岛比 Paxons 原先想象得更复杂。许多问题出现了,解决这些问题需要修改 protocol。下面描述最重要的变化。
3.3.1 Picking a President
Parliament 最初沿用 Synod 的 president 选择方法,完全依据名字的 alphabetic ordering。因此,当 legislator Ωκι 从六个月 vacation 返回时,立即被任命为 president——尽管他完全不知道自己离开期间发生了什么。Parliament activity 停止了,因为 Ωκι 写字很慢,只能辛苦地抄写六个月的 decree 来更新 ledger。
这次 incident 引发了关于如何选择 president 的 debate。一些 Paxons 建议:legislator 一旦成为 president,就应该一直担任到离开 Chamber。一个有影响力的 citizen group 希望由 Chamber 中最富有的 legislator 担任 president,因为他能负担更多 scribes 和 servants,协助履行 presidential duty。他们认为,富有的 legislator 一旦更新好 ledger,就没有理由不担任 presidency。另一些人则认为,无论财富如何,都应选择最 upstanding 的 citizen。upstanding 可能表示不太可能 dishonest,但没有 Paxon 会公开承认 official malfeasance 的可能性。
遗憾的是,我们不知道这场 debate 的结果;没有记录说明最终使用了哪一种 presidential selection protocol。
3.3.2 Long Ledgers
随着年份流逝、Parliament 通过越来越多的 decree,Paxons 必须在越来越长的 list 中查找当前 olive tax 或允许出售什么颜色的 goat。一次长途 voyage 后回到 Chamber 的 legislator,也必须复制相当多内容才能更新 ledger。
最终,legislators 不得不把 ledger 从 decree list 改成 law book:其中只保存当前 law state,以及最后一条已反映到该 state 的 decree number。
要了解当前 olive tax,就在 law book 的“taxes”下查找;要了解允许出售的 goat 颜色,就在“mercantile law”下查找。如果 legislator 的 ledger 已经记录到 decree 1298,而得知 decree 1299 把 olive tax 设为每吨 6 drachmas,那么只需修改 olive-tax law 的条目,并记下 ledger 已完整到 decree 1299。如果随后得知 decree 1302,就把它写在 ledger 背面,等得知 decrees 1300 和 1301 后再把 1302 合并到 law book。
第 19 页:Long Ledgers、Bureaucrats 与时间顺序

为了让短暂离开的 legislator 不必抄写整个 law book 就能追赶进度,legislators 在 book 背面保留过去一周的 decree list。他们本可以把 list 写在 slip of paper 上,但把 decree 直接录入 ledger 背面更方便;这样可以先记录 decree,每周更新 law book 两三次。
3.3.3 Bureaucrats
Paxos 繁荣后,legislators 变得非常忙。Parliament 无法再处理所有 government detail,于是建立了 bureaucracy。Parliament 不再为每一块 cheese 是否适合销售通过一条 decree,而是通过一条 decree 任命 cheese inspector,由他做决定。
很快发现,选择 bureaucrat 并不像一开始那么简单。Parliament 通过 decree 任命 ∆˘ικστρα 为第一任 cheese inspector。几个月后,merchants 抱怨 ∆˘ικστρα 太严格,连完全合格的 cheese 也拒绝。Parliament 随后通过:
1375: Γωυδα is the new cheese inspector
但 ∆˘ικστρα 没有密切关注 Parliament 的行动,因此没有立即得知这条 decree。在一段混乱时期,∆˘ικστρα 和 Γωυδα 同时检查 cheese,并做出冲突的决定。
为防止这种 confusion,Paxons 必须保证一个 position 在任意时刻最多由一个 bureaucrat 持有。于是 president 在每条 decree 中加入 proposal 的 time 和 date。一条任命 ∆˘ικστρα 为 cheese inspector 的 decree 可能是:
2716: 8:30 15 Jan 72—∆˘ικστρα is cheese inspector for 3 months
这表示他的任期要么从 1 月 15 日 8:30 开始,要么从前一任 inspector 任期结束时开始,以较晚者为准。除非他显式辞职(例如要求 president 通过 2834: 9:15 3 Mar 72—∆˘ικστρα resigns as cheese inspector),否则任期会在 3 月 15 日 8:30 结束。
为便于快速替换 bureaucrat,任期设置得很短,例如 bureaucrat 离开岛时可以迅速替换;如果表现良好,Parliament 会通过 decree 延长其任期。
要判断当前是否担任某个职位,bureaucrat 必须知道时间。Paxos 尚不知道 mechanical clock,但通过 sun 或 stars 的位置可以在 15 分钟内准确判断时间。如果 ∆˘ικστρα 的任期在 8:30 开始,那么要等 celestial observation 显示时间为 8:45,他才开始检查 cheese。
如果 higher-numbered decree 总是在 later proposal time 提出,这种任命方法很容易工作。但如果 Parliament 通过如下两个 decree 呢?
2854: 9:45 9 Apr 78—Φρανσϵζ is wine taster for 2 months
2855: 9:20 9 Apr 78—Πνυϵλ˘ι is wine taster for 1 month
脚注 13:Paxos 气候温和,阴天很少。
第 20 页:Proposal ordering 与 Monotonicity

如果不同 legislator 都以为自己是 president,并提出了 9:30 到 9:35 之间的 decree,导致 proposal time out of order,该怎么办?这种 out-of-order proposal time 很容易避免,因为 parliamentary protocol 满足:
如果两个 decree 由不同 president passed,那么其中一个 president 是在得知另一个 decree 已 proposed 后才提出自己的 decree。
证明如下:假设 ballot number b 对 decree D successful,ballot number b′ 对 decree D′ successful,且 b < b′。令 q 为在两个 ballot 中都投过票的 legislator。D′ 的 balloting 从 NextBallot(b′, n) message 开始。如果发送该 message 的人事先不知道 D,那么 n 小于 D 的 decree number;而 q 对 NextBallot 的 reply 必须说明它为 D 投过票。
3.3.4 Learning the Law
普通 citizen 除了请求通过 decree,还需要询问当前 law。Paxons 起初认为 citizen 只需查看任意 legislator 的 ledger,但下面的事件表明需要更复杂的方法。
几个世纪以来,只有白色 goat 可以合法出售。农民 ∆ωλϵφ 让 Parliament 通过:
77: The sale of black goats is permitted
然后 ∆ωλϵφ 要求 goatherd 把黑色 goats 卖给商人 Σκϵϵν。作为遵守法律的 citizen,Σκϵϵν 向 legislator Στωκµϵ˘ιρ 询问这次销售是否合法。但 Στωκµϵ˘ιρ 一直不在 Chamber,ledger 只记录到 decree 76。他告诉 Σκϵϵν,根据 current law 这次销售违法,于是 Σκϵϵν 拒绝购买 goats。
这次事件促成了如下关于 law inquiry 的 monotonicity condition:
如果一次 inquiry 先于第二次 inquiry,那么第二次 inquiry 不能揭示比第一次 inquiry 更早的 law state。
如果 citizen 得知某个 decree 已经通过,那么获取该知识的过程被视为一次 implicit inquiry,同样适用这一 condition。下面会看到,monotonicity condition 的解释随着时间改变了。
最初,Paxons 为每次 inquiry 通过一条 decree 来实现 monotonicity。如果 Σ∂ν˘ιδϵρ 想知道 current olive tax,就让 Parliament 通过:
87: Citizen Σ∂ν˘ιδϵρ is reading the law
然后,他查看任何至少完整记录到 decree 86 的 ledger,就能了解截至该 decree 的 olive tax。如果 citizen Γρϵϵς 随后 inquiry olive tax,那么他的 inquiry 对应的 decree 在 decree 87 passed 后才 proposed,根据 decree-ordering property(Section 3.2.1),它获得的 decree number 大于 87。因此,Γρϵϵς 不可能获得早于 Σ∂ν˘ιδϵρ 的 olive-tax value。
第 21 页:Causal precedence 与 law specialists

这种读取 law 的方法满足 monotonicity condition,但前提是把“precedes”解释为:inquiry A 完成时间早于 inquiry B 开始时间。
为每次 inquiry 通过 decree 很快变得过于繁琐。Paxons 发现,如果弱化 monotonicity condition,并改变 precedes 的解释,就可以使用更简单的方法:一个 event 要 precede 另一个 event,不仅要在时间上更早,而且必须能够对第二个 event 产生 causal effect。
较弱的 monotonicity condition 能避免农民 ∆ωλϵφ 和商人 Σκϵϵν 首次遇到的问题,因为从 ∆ωλϵφ 的 implicit inquiry 结束到 Σκϵϵν 的 inquiry 开始之间存在 causal chain of events。
Paxons 在所有 business transaction 和 inquiry 中使用 decree number,从而满足较弱的 monotonicity condition。例如,农民 ∆ωλϵφ 的 flock 中有许多非白色 goats,于是让 Parliament 通过:
277: The sale of brown goats is permitted
向 Σκϵϵν 出售 brown goats 时,他告诉商人:截至 decree 277,该销售是合法的。Σκϵϵν 随后询问 legislator Στωκµϵ˘ιρ:在至少完整到 decree 277 的 law 下,这次销售是否合法?如果 Στωκµϵ˘ιρ 的 ledger 尚未完整到 277,他要么等到 ledger 完成,要么告诉 Σκϵϵν 去问别人。如果 ledger 已经到 decree 298,他就告诉 Σκϵϵν:截至 decree 298,该销售是合法的。商人记住 298,之后 business transaction 或 law inquiry 会继续使用这个 number。
Paxons 满足了 monotonicity condition,但普通 citizens 不喜欢记忆 decree number。于是 Paxons 再次通过重新解释 monotonicity condition 来解决问题,这次改变的是 law state 的含义。
他们把 law 分成不同 area,并为每个 area 选择一名 specialist。每个 area 的 current law state 由对应 specialist 的 ledger 决定。例如,假设 decree 1517 修改 tariff law,decree 1518 修改 tax law。如果 tax-law specialist 在 tariff-law specialist 得知任何 decree 前就得知两条 decree,那么 tax law 会先改变;这会产生一个无法通过按 decree number 顺序 enact decree 得到的 law state。
为避免 current state 出现冲突定义,Paxons 要求每个 area 同一时刻最多有一名 specialist。这沿用了选择 bureaucrat 的方法。如果每次 inquiry 只涉及一个 area,就把 inquiry 发给该 area 的 specialist,由他根据自己的 ledger 回答,从而得到 monotonicity。
由于得知 law passed 也构成 implicit inquiry,Paxons 要求一条 decree 最多改变一个 area,并且 decree passed 的 notification 只能来自该 area 的 specialist。
涉及多个 area 的 inquiry 不难处理。当商人 Λισκωφ 询问 imported golden fleece 的 tariff 是否高于当地购买时的 sales tax,tax-law specialist 可以先向 tariff specialist 询问 tariff,只要他在收到 reply 前不改变自己的 ledger。
第 22 页:多个 law area、dishonesty 与 self-stabilization

这种方法在需要同时大范围修改多个 law area 时遇到问题。Paxons 于是认识到,维护 monotonicity 所需的并不是一条 decree 只影响一个 area,而是它影响的所有 area 必须拥有同一个 specialist。
Parliament 可以先任命同一个 legislator 作为这些 area 的 specialist,再用一条 decree 同时修改多个 area。一个 area 也可以同时有多个 specialists,只要不允许该 area 的 law 发生变化。income tax 到期之前,Parliament 就会任命若干 tax-law specialist,应对关于 tax law 的季节性 inquiry 洪峰。
3.3.5 Dishonest Legislators and Honest Mistakes
尽管官方声明与此相反,Paxos 历史上肯定有少数 dishonest legislator。他们被抓到后很可能会被 exiled。恶意 legislator 可以通过发送相互矛盾的 message,使不同 legislator 的 ledger 不一致。诚实 legislator 或 messenger 的 memory lapse 也可能造成 inconsistency。
当 inconsistency 被发现时,可以很容易通过通过新 decree 来纠正。例如,关于 current olive tax 的 disagreement,可以通过一条新 decree 宣布 tax 的确定值。困难的问题是:即使没人意识到存在 inconsistency,也要纠正不一致的 ledger。
Parliament 建立数年后,ledger 中开始出现 redundant decree,这说明可能存在 dishonesty 或 mistake。例如:
2605: The olive tax is 9 drachmas per ton
尽管 decree 2155 已把 olive tax 设为每吨 9 drachmas,且中间没有任何 decree 改变它,2605 仍被通过。显然,Parliament 大约每六个月 cycle through laws 一次,因此即使 legislators 的 ledger 最初不一致,所有 legislator 也会在六个月内对 current law 达成一致。人们相信,Paxons 通过这些 redundant decree 使 Parliament 具备 self-stabilizing 能力。(self-stabilizing 是 Dijkstra [1974] 引入的 modern term。)
目前还不清楚,在 legislator 随意进出的 Parliament 中,self-stabilization 究竟意味着什么。Paxons 不会满意于这样一种定义:必须所有 legislator 同时在 Chamber 中,才能保证 consistency。要 achieve consistency,至少必须保证:如果一个 legislator 的 ledger 有某个 decree number 的 entry,而另一个没有,那么第二个最终会补上该 entry。
遗憾的是,我们不知道 Paxon Parliament 拥有什么 self-stabilization property,或者如何实现它。Paxon mathematicians 肯定处理过这个问题,但他们的工作尚未被发现。我希望未来去 Paxos 的 archaeological expedition 会优先寻找关于 self-stabilization 的 manuscript。
第 23 页:新议员与 State Machine Approach

3.3.6 Choosing New Legislators
最初,Parliament membership 是 hereditary 的,由 parent 传给 child。当 elder statesman Παρνας retired 时,他把 ledger 交给儿子,后者可以无中断地继续工作。对其他 legislators 来说,他们与哪一个 Παρνας 通信没有区别。
随着 old families emigrated、new families immigrated,这套 system 必须改变。Paxons 决定通过 decree 增加和移除 Parliament member。这造成了 circularity problem:Parliament membership 由已经通过的 decree 决定,但通过 decree 又需要知道 majority set 是什么,而 majority set 又取决于 Parliament 的 membership。
Paxons 通过让“通过 decree n 时使用的 Parliament membership”由 decree n − 3 时的 law 指定,打破了 circularity。president 直到知道所有 ≤ 3252 的 decree 前,都不能尝试通过 decree 3255。实际上,在通过:
3252: Στρωνγ is now a legislator
后,president 会立即把“olive-day” decree 作为 decrees 3253 和 3254 通过。
以这种方式改变 Parliament composition 很危险,必须小心处理。consistency 和 progress condition 总会保持,但 progress condition 只有在 majority set 位于 Chamber 时才能保证 progress;它不保证 majority set 一定会出现。
事实上,选择 legislator 的 mechanism 导致了 Paxos parliamentary system 的 downfall。由于 scribe 的 error,一条原本要纪念在 shipwreck 中遇难 sailors 的 decree,错误地声明这些 sailors 是 Parliament 的唯一 members。它的通过阻止了任何新 decree——包括用于纠正错误的 decree——被通过。government 在 Paxos 停摆。
一名名叫 Λαµπσων 的 general 利用混乱发动 coup,建立 military dictatorship,结束了持续数世纪的 progressive government。Paxos 在一系列 corrupt dictator 下变弱,无法抵御来自 east 的 invasion,最终导致其 civilization 被摧毁。
4 Relevance to Computer Science
4.1 The State Machine Approach
虽然 Paxos Parliament 在几百年前已经毁灭,但它的 protocol 仍然有用。例如,考虑一个简单的 distributed database system,它可以用作 name server。database state 是 name 到 value 的 assignment。多个 server 维护 database 的副本。client program 可以向任意 server 发出 read 或 change 某个 name value 的 request。
这里有两类 read request:slow read 返回 name 当前 assigned value;fast read 更快,但可能不反映 database 最近的 change。
这个 database system 与 Paxon Parliament 有如下明显对应关系:
| Parliament | Distributed Database |
|---|---|
| legislator | server |
| citizen | client program |
| current law | database state |
第 24 页:State machine 示例与通用算法

Figure 2 中的 state machine 定义如下:
| 项目 | read(name, client) | update(name, val, client) |
|---|---|---|
| response | (client, value of name) | (client, "ok") |
| new state | 与 current state 相同 | 与 current state 相同,但 name 的 value 改为 val |
Figure 2. 简单 database 的 state machine。
client 修改 value 的 request 通过一条 decree 执行。slow read 按 Section 3.3.4 的方法通过 decree。fast read 则直接读取 server 的 current database version。Paxon Parliament protocol 提供了该 database system 的 distributed、fault-tolerant implementation。
这种实现 distributed database 的方法,是 state-machine approach 的一个实例。该 approach 首先定义一个 state machine,它包括:state set、command set、response set,以及一个把每个 command/state pair 映射到 response/state pair 的 function。
直观地说,state machine 通过产生 response 并改变 state 来执行 command;command 和 machine current state 决定它的 response 与 new state。对于 distributed database,state-machine state 就是 database state。Figure 2 描述了 state-machine command 以及定义 response 和 new state 的 function。
在 state-machine approach 中,system 由一组 networked server process 实现。server 把 client request 转为 state-machine command,执行 command,再把 state-machine response 转为 client reply。
一个 general algorithm 确保所有 server 获得相同的 command sequence,从而保证它们产生相同的 response sequence 和 state change——前提是它们从同一个 initial state 开始。
在 database example 中,执行 slow read 或 change value 的 client request 被转换为 state-machine read 或 update command。该 command 被执行,state-machine response 被转换为 client reply,由接收 request 的 server 发回 client。
由于所有 server 执行相同的 state-machine command sequence,它们维护一致的 database version。不过任意时刻,一些 server 可能仍处于 earlier version,因为 state-machine command 不必在所有 server 上同时执行。server 可以使用自己当前的 state version 回复 fast read,而无需执行 state-machine command。
system 的 functionality 由 state machine 表达,它只是从 command/state pair 到 response/state pair 的 function。synchronization 和 fault-tolerance 问题由 server 获取 command sequence 时使用的 general algorithm 处理。设计新 system 时,只有 state machine 是新的;server 使用已经证明正确的 standard distributed algorithm 获取 state-machine command。相比 distributed algorithm,function 更容易设计,也更容易做正确。
第一个用于实现 arbitrary state machine 的 algorithm 出现在 [Lamport 1978]。后来又出现了能够容忍任意固定数量 f 个 arbitrary failure 的 algorithm [Lamport 1984]。这些 algorithm 保证:如果少于 f 个 process failure,state-machine command 会在固定时间内执行,因此适合需要 real-time response 的 application。
第 25 页:State machine 的可靠性边界与 Commit Protocol

但如果 failure 数超过 f,不同 server 可能拥有不一致的 state-machine copy。而且,两个 server 无法互相通信,等价于其中一个 server failure。
要让 system 丢失 consistency 的概率很低,就必须使用 f 很大的 algorithm;这又意味着更高的 redundant hardware、communication bandwidth 和 response-time cost。
Paxon Parliament protocol 提供了另一种实现 arbitrary state machine 的方法。legislator 的 law book 对应 machine state,passing a decree 对应执行 state-machine command。生成的 algorithm 比早期 algorithm 更不 robust、成本也更低。它不能容忍 arbitrary、malicious failure,也不保证 bounded-time response;但即使任意数量的 process 和 communication path 发生 benign failure,也能维护 consistency。Paxon algorithm 适合 reliability requirement moderate、不值得使用极端 fault-tolerant、real-time implementation 的 system。
如果使用保证 bounded-time response 的 algorithm 执行 state machine,那么可以把 time 放入 state,并让 machine action 由时间流逝触发。例如,可以设计一个 resource ownership system:state 包含 client 获得 resource 的时间,state machine 自动执行 command,在 client 持有 resource 过久时 revoke ownership。
使用 Paxon algorithm 时,无法如此自然地把 time 作为 state 的一部分。发生 failure 后,执行 command(通过 decree)可能任意延迟;一个较早发出的 command 可能在另一个 command 之后才执行,因而出现在 decree sequence 更后面。
不过,state machine 仍能像 Paxon Parliament 一样使用 real time。例如,Section 3.3.3 介绍的判定 current cheese inspector 的方法,也可以用来判定 resource 的 current owner。
4.2 Commit Protocols
Paxon Synod protocol 与 standard three-phase commit protocol 相似 [Bernstein et al. 1987; Skeen 1982]。Paxon ballot 和 three-phase commit 都涉及 coordinator(president)与其他 quorum member(legislator)之间的五条 message exchange。
commit protocol 在 commit 与 abort 两个 value 中选择一个,而 Synod protocol 选择 arbitrary decree。要把 commit protocol 转成 Synod protocol,只需在 initial round message 中发送 decree。commit decision 表示该 decree 被 passed;abort decision 表示“olive-day” decree 被 passed。
Synod protocol 与转换后的 commit protocol 的区别是:decree 要到第二 phase 才发送。这使得对应的 parliamentary protocol 可以对所有 decree 只执行一次 first phase,因此每个 individual decree 只需三次 message exchange。
脚注 14:这些 algorithm 源自另一个 Mediterranean state 的 military protocol。
第 26 页:相关工作与附录开始

Synod protocol 所依赖的 theorems 与 Dwork、Lynch 和 Stockmeyer [1988] 得到的结果相似。不过,他们的 algorithm 在 separate round 中 sequentially 执行 ballot,看起来与 Synod protocol 无关。
自这篇文章写成以来,该领域已经开展了大量 research。Schneider [1990] 对 state-machine approach 做了 survey。Keidar 和 Dolev [1996] 的 recovery protocol,以及 Fekete 等人 [1997] 的 totally-ordered broadcast algorithm,都与这里描述的 Paxon protocol 很相似。作者显然也不知道 Oki 和 Liskov [1988] 的 view management protocol;它看起来与 Paxon protocol 等价。
这篇投稿中介绍的许多 refinement 也曾出现在同期或后来的文章中。Section 3.3.3 的 delegation method 与 Gray 和 Cheriton [1989] 的 leases mechanism 非常相似。Section 3.3.4 中 Paxons 通过 decree number 满足 monotonicity condition 的技术,Ladin 等人 [1992] 也有描述。Section 3.3.6 中增加新 legislator 的技术,Schneider [1990] 也给出过。
K. M.
Appendix: Proof of Consistency of the Synodic Protocol
A1 The Basic Protocol
这里用现代 algorithmic notation 表述 Section 2.3 中 informal 描述的 Synod basic protocol。先从 priest p 必须维护的 variables 开始。
首先是代表 ledger 中信息的 variables。为方便起见,Section 2.3 使用的 vote prevVote[p] 在这里拆成 prevBal[p] 和 prevDec[p] 两个 component。
outcome[p]:写入p的 ledger 的 decree;如果还没有写入,则为blank。lastTried[p]:p最后尝试发起的 ballot number;如果从未尝试,则为−∞。prevBal[p]:p最后投票的 ballot number;如果从未投票,则为−∞。prevDec[p]:p最后投票支持的 decree;如果从未投票,则为blank。nextBal[p]:p同意参与的最后一个 ballot number;如果从未同意参与,则为−∞。
下面是 priest p 可以保存在 slip of paper 上的 variables:
status[p]:取以下值之一:idle:没有 conducting 或 trying to begin ballot;trying:正在尝试 begin ballotlastTried[p];polling:正在 conduct ballotlastTried[p]。
- 如果
p丢失 slip of paper,则假设status[p] = idle,下面四个 variables 的值无关紧要。 prevVotes[p]:当前 ballot(ballot number 为lastTried[p])收到的LastVotemessage 中的 vote set。
第 27 页:Basic Protocol 的变量与 action

quorum[p]:若status[p] = polling,则为 current ballot 的 quorum priest set;否则无意义。voters[p]:若status[p] = polling,则为 current ballot 中已收到Votedmessage 的 quorum member set;否则无意义。decree[p]:若status[p] = polling,则为 current ballot 的 decree;否则无意义。
还有一个 history variable B,它是已经 started 的 ballot 及其 progress 的集合,即哪些 priest 已经投票。history variable 用于 algorithm 的 development 和 proof,但不会真正实现。
接下来是 priest p 可以执行的 actions。这些 action 被假设为 atomic:一旦开始执行,必须完成后 p 才能开始另一个 action。一个 action 由 enabling condition 和 effect list 描述。enabling condition 描述何时可执行;接收 message 的 action 在 messenger 带着相应 message 到达时 enabled。effect list 描述 action 如何改变 algorithm variables,以及发送什么 message(如果有)。每个 action 最多发送一条 message。
回顾:ballot number 被 partition 给各 priest。对于任意 ballot number b,Paxons 定义 owner(b) 为被允许使用该 number 的 priest。
basic protocol 中的 action 是 allowed action;protocol 不要求 priest 必须做任何事。它没有试图优化效率,因此允许 p 做一些 silly action,例如向已经发送过 LastVote message 的 priest 再发送一条 BeginBallot message。
Try New Ballot
始终 enabled。
- 把
lastTried[p]设为任意 ballot numberb,其中b大于旧值且owner(b) = p。 - 把
status[p]设为trying。 - 把
prevVotes[p]设为∅。
Send NextBallot Message
当 status[p] = trying 时 enabled。
- 向任意 priest 发送
NextBallot(lastTried[p])message。
Receive NextBallot(b) Message
如果 b ≥ nextBal[p]:
- 把
nextBal[p]设为b。
Send LastVote Message
当 nextBal[p] > prevBal[p] 时 enabled。
- 向
owner(nextBal[p])发送LastVote(nextBal[p], v),其中vpst = p、vbal = prevBal[p]、vdec = prevDec[p]。
第 28 页:Basic Protocol action 完成

Receive LastVote(b, v) Message
如果 b = lastTried[p] 且 status[p] = trying:
- 把
prevVotes[p]更新为旧值与{v}的 union。
Start Polling Majority Set Q
当 status[p] = trying 且 Q ⊆ {vpst : v ∈ prevVotes[p]} 时 enabled,其中 Q 是 majority set。
- 把
status[p]设为polling。 - 把
quorum[p]设为Q。 - 把
voters[p]设为∅。 - 按如下方式把
decree[p]设为 decreed:令v为prevVotes[p]的 maximum element。如果vbal ≠ −∞,则d = vdec;否则d可以是任意 decree。 - 把
B更新为旧值与新 ballot 的 union,其中Bdec = d、Bqrm = Q、Bvot = ∅、Bbal = lastTried[p]。
Send BeginBallot Message
当 status[p] = polling 时 enabled。
- 向
quorum[p]中任意 priest 发送BeginBallot(lastTried[p], decree[p])。
Receive BeginBallot(b, d) Message
如果 b = nextBal[p] > prevBal[p]:
- 把
prevBal[p]设为b。 - 把
prevDec[p]设为d。 - 如果
B中存在Bbal = b的 ballot(一定存在),就选择这个 ballot(一定只有一个),把它的新值设为旧值与{p}的 union,即把p加入Bvot。
Send Voted Message
当 prevBal[p] ≠ −∞ 时 enabled。
- 向
owner(prevBal[p])发送Voted(prevBal[p], p)。
Receive Voted(b, q) Message
如果 b = lastTried[p] 且 status[p] = polling:
- 把
voters[p]更新为旧值与{q}的 union。
Succeed
当 status[p] = polling、quorum[p] ⊆ voters[p] 且 outcome[p] = blank 时 enabled。
- 把
outcome[p]设为decree[p]。
Send Success Message
当 outcome[p] ≠ blank 时 enabled。
- 向任意 priest 发送
Success(outcome[p])。
Receive Success(d) Message
如果 outcome[p] = blank:
- 把
outcome[p]设为d。
第 29 页:Action model 与 invariant proof 开始

这个 algorithm 是 Paxon priests 实际执行的 real protocol 的 abstract description。algorithm 的 actions 是否准确 model 了真实 priest 的 action?priest 有三种可以“atomic”执行的 action:接收 message、写 note 或 ledger entry、发送 message。algorithm 中各自对应一个 action,只是 Receive action 同时接收 message 并设置 variable。
我们可以假装:priest 实际处理 message 时才算收到该 message;如果他在处理前离开 Chamber,就假装 message 从未收到。因为这种假设不影响 consistency condition,所以可以从 algorithm consistency 推出 basic Synod protocol consistency。
A2 Proof of Consistency
要证明 consistency condition,必须说明:只要 outcome[p] 和 outcome[q] 都不是 blank,它们就相等。严谨 correctness proof 需要 algorithm 的完整描述;上面的描述几乎完整,但还缺少一个 variable M,它是所有 in-transit message 的 multiset。
每个 Send action 都向该 multiset 加一条 message,每个 Receive action 都移除一条。还需要表示 message loss、message duplication,以及 priest 丢失 slip of paper 的 Forget action。
加入这些内容后,我们得到一个定义 possible behavior 的 algorithm;每次 state change 都对应一个 allowed action。Paxons 通过寻找 predicate I 证明 correctness,使其满足:
I初始为 true;I蕴含 desired correctness condition;- 每个 allowed action 执行后
I仍为 true。
predicate I 写成 I1 ∧ … ∧ I7。其中 I1–I5 又分别是所有 priest 的 I1(p)–I5(p) 的 conjunction。虽然多个 conjunct 可能提到同一 variable,但除 status[p] 外,每个 variable 都自然归属于某个 conjunct;每个 conjunct 可以看作对其关联 variables 的 constraint。
下面给出 I 的 individual conjunct。与 conjunct 关联的 variables 写在 bracketed comment 中,其中列出的以 ∧ 开头的 item 表示 conjunction。
I1(p) ≜ [Associated variable: outcome[p] ]
(outcome[p] ≠ blank) ⇒ ∃B ∈ B : (Bqrm ⊆ Bvot) ∧ (Bdec = outcome[p])
I2(p) ≜ [Associated variable: lastTried[p] ]
∧ owner(lastTried[p]) = p
∧ ∀B ∈ B : (owner(Bbal) = p) ⇒ Bbal ≤ lastTried[p]
∧ (status[p] = trying) ⇒ (Bbal < lastTried[p])
I3(p) ≜ [Associated variables: prevBal[p], prevDec[p], nextBal[p] ]
∧ prevBal[p] = MaxVote(∞, p, B)bal
∧ prevDec[p] = MaxVote(∞, p, B)dec
∧ nextBal[p] ≥ prevBal[p]
第 30 页:I4–I7 与 invariant proof

I4(p) ≜ [Associated variable: prevVotes[p] ]
(status[p] ≠ idle) ⇒
∀v ∈ prevVotes[p] : v = MaxVote(lastTried[p], vpst, B)
∧ nextBal[vpst] ≥ lastTried[p]
I5(p) ≜ [Associated variables: quorum[p], voters[p], decree[p] ]
(status[p] = polling) ⇒
∧ quorum[p] ⊆ {vpst : v ∈ prevVotes[p]}
∧ ∃B ∈ B : quorum[p] = Bqrm
∧ decree[p] = Bdec
∧ voters[p] ⊆ Bvot
∧ lastTried[p] = Bbal
I6 ≜ [Associated variable: B ]
∧ B1(B) ∧ B2(B) ∧ B3(B)
∧ ∀B ∈ B : Bqrm is a majority set
I7 ≜ [Associated variable: M ]
∧ ∀NextBallot(b) ∈ M : b ≤ lastTried[owner(b)]
∧ ∀LastVote(b, v) ∈ M : v = MaxVote(b, vpst, B) ∧ nextBal[vpst] ≥ b
∧ ∀BeginBallot(b, d) ∈ M : ∃B ∈ B : (Bbal = b) ∧ (Bdec = d)
∧ ∀Voted(b, p) ∈ M : ∃B ∈ B : (Bbal = b) ∧ (p ∈ Bvot)
∧ ∀Success(d) ∈ M : ∃p : outcome[p] = d ≠ blank
Paxons 必须证明 I 满足上面三个 condition。第一个 condition,即 I 初始成立,需要检查所有 variables 的初始值;虽然没有显式写出,但可以从 variable description 推断这些初始值,检查很直接。
第二个 condition,即 I 蕴含 consistency,来自 I1、I6 的第一个 conjunct,以及 Theorem 1。
真正困难的是第三个 condition:I 的 invariance,即证明每个 action 执行后 I 仍为 true。方法是:对 I 的每个 conjunct,证明在 I 为 true 时执行任意 action,不会破坏该 conjunct。下面给出 proof sketch。
I1(p)
只有向 B 增加新 ballot,或向某个 B ∈ B 的 Bvot 增加新 priest,才会改变 B;这两种变化都不能 falsify I1(p)。outcome[p] 只由 Succeed 和 Receive Success Message action 改变。
I5(p) 与 enabling condition 保证 Succeed action 执行后 I1(p) 仍成立。Receive Success Message action 则由 enabling condition、I1(p) 和 I7 的最后一个 conjunct 保持 I1(p)。
I2(p)
该 conjunct 只依赖 lastTried[p]、status[p] 和 B。只有 Try New Ballot 会改变 lastTried[p],也只有它能把 status[p] 设为 trying。由于 action 把 lastTried[p] 增大到 owner 为 p 的 b,所以 I2(p) 保持为 true。
只有 Start Polling 会向 B 加入全新的 element;I2(p) 的第一个 conjunct 和 action specification 保证新增 element 不会破坏第二个 conjunct。其他改变 B 的方式只是给已有 ballot 的 Bvot 添加 priest,不影响 I2(p)。
第 31 页:I3–I5 的不变量保持

I3(p)
由于 vote 不会从 B 移除,唯一会改变 MaxVote(∞, p, B) 的 action 是向 B 添加一条由 p 投出的 vote。只有 Receive BeginBallot Message 能做这件事,而且只有它会改变 prevBal[p] 和 prevDec[p]。
I7 的 BeginBallot conjunct 说明该 action 确实把 vote 加入 B;I6 的 B1 conjunct 说明它只能加入唯一一个 ballot。enabling condition、action 执行前的 I3(p) 和 MaxVote 定义共同说明 action 执行后 I3(p) 的前两个 conjunct 仍成立。第三个 conjunct 之所以保持,是因为 prevBal[p] 只会被设为 nextBal[p],而 nextBal[p] 从不减少。
I4(p)
该 conjunct 依赖 status[p]、prevVotes[p]、lastTried[p]、若干 nextBal[q] 以及 B。status[p] 从 idle 变为 not idle 只由 Try New Ballot 触发;它把 prevVotes[p] 设为 ∅,因此 I4(p) 空真。
之后唯一改变 prevVotes[p] 的 action 是 Forget 和 Receive LastVote Message。Forget 把 status 设为 idle,因此保留 I4(p);后者则由 enabling condition 与 I7 的 LastVote conjunct 保留。
lastTried[p] 也只由 Try New Ballot 改变,该 action 把 status 设为 trying,仍保留 I4(p)。nextBal[q] 只能增加,因而不会使 I4(p) 变为 false。
MaxVote(lastTried[p], vpst, B) 只有在某个 B ∈ B 满足 Bbal < lastTried[p],且把 vpst 加入 Bvot 时才可能改变。但 vpst 只有在 nextBal[vpst] = Bbal 时才会被 Receive BeginBallot Message 加入;这时 I4(p) 已蕴含 Bbal ≥ lastTried[p]。
I5(p)
只有 Start Polling 会把 status 设为 polling。该 action 的 enabling condition 保证第一个 conjunct 成立,并把使第二个 conjunct 成立的 ballot 加入 B。在 status 保持 polling 时,没有其他 action 会改变 quorum[p]、decree[p] 或 lastTried[p]。
当 status 为 polling 时,prevVotes[p] 不会改变;B 只会添加新 element 或给 Bvot 添加新 priest。剩下唯一可能 falsify I5(p) 的方式,是 Receive Voted Message 给 voters[p] 添加 element。
I7 的 Voted conjunct、I6 的 B1 conjunct 以及 action 的 enabling condition 共同保证:添加到 voters[p] 的 element 属于 Bvot,其中 B 正是 I5(p) 所断言存在的 ballot。
第 32 页:I6、I7 与 References 开始

I6
由于任意 B ∈ B 的 Bbal 和 Bqrm 永不改变,能 falsify B1(B)、B2(B) 以及 I6 第二个 conjunct 的唯一方式,是向 B 添加新的 ballot。只有当 status[p] = trying 时,Start Polling Majority Set Q 才会做这件事。
I2(p) 的第二个 conjunct 说明该 action 保持 B1(B);enabling condition 中的断言 Q 是 majority set,则说明 action 保持 B2(B) 和 I6 第二个 conjunct。
有两种方式可以 falsify B3(B):通过向 B 添加新 vote 改变 MaxVote(Bbal, Bqrm, B);或者添加新 ballot。
新 vote 只由 Receive BeginBallot Message 添加;I3(p) 说明该 action 添加的 vote 比 p 在 B 中投出的任何其他 vote 都 later,因此不会改变任何 B 的 MaxVote(Bbal, Bqrm, B)。
I4(p) 说明 Start Polling 添加的新 ballot 不会 falsify B3(B)。
I7
I7 可能因向 M 添加新 message,或因改变 I7 所依赖的其他 variable 而被 falsify。lastTried[p] 和 nextBal[p] 从不减少,因此改变它们不会使 I7 变 false。outcome[p] 一旦不是 blank 就不会再改变,因此改变它也不会 falsify I7。
B 只通过添加 ballot 和添加 vote 改变;能让 I7 变 false 的唯一变化,是某个 vpst 添加 vote 后,使 LastVote(b, v) conjunct 因 MaxVote(b, vpst, B) 改变而不成立。
这只有在 vpst 投票到一个 Bbal < b 的 ballot 时才会发生。但 vpst 只能在 nextBal[vpst] 对应的 ballot 中投票,而该 conjunct 初始成立的假设已经给出 nextBal[vpst] ≥ b。因此,只需要检查每种 sent message 是否满足 I7 对应 conjunct 的 condition:
- NextBallot:由
Send NextBallot Message的定义和 I2(p) 的第一个 conjunct 得出。 - LastVote:
Send LastVote Message的 enabling condition 与 I3(p) 蕴含MaxVote(nextBal[p], p, B) = MaxVote(∞, p, B),因此该 action 发送的 LastVote 满足 I7。 - BeginBallot:由 I5(p) 和
Send BeginBallot Message的定义得出。 - Voted:由 I3(p)、
MaxVote的定义以及Send Voted Message的定义得出。 - Success:由
Send Success Message的定义得出。
第 33 页:Acknowledgments 与 References

ACKNOWLEDGMENTS
Daniel Duchamp 指出了我需要一种新的 state-machine implementation。与 Martín Abadi、Andy Hisgen、Tim Mann 和 Garret Swart 的讨论使我接触到 Paxos。Λϵων´ιδας Γκ´ιµπας 为我理解 Paxon dialect 提供了宝贵帮助。
References
- Bernstein, P. A., Hadzilacos, V., and Goodman, N. 1987. Concurrency Control and Recovery in Database Systems. Addison-Wesley, Reading, Massachusetts。
- De Prisco, R., Lampson, B., and Lynch, N. 1997. Revisiting the Paxos algorithm. In M. Mavronicolas and P. Tsigas (Eds.), Proceedings of the 11th International Workshop on Distributed Algorithms (WDAG 97), Volume 1320 of Lecture Notes in Computer Science, Saarbruken, Germany, pp. 111–125. Springer-Verlag。
- Dijkstra, E. W. 1974. Self-stabilizing systems in spite of distributed control. Communications of the ACM 17(11), 643–644。
- Dwork, C., Lynch, N., and Stockmeyer, L. 1988. Consensus in the presence of partial synchrony. Journal of the ACM 35(2), 288–323。
- Fekete, A., Lynch, N., and Shvartsman, A. 1997. Specifying and using a partitionable group communication service. In Proceedings of the Sixteenth Annual ACM Symposium on Principles of Distributed Computing, pp. 53–62. ACM Press。
- Fischer, M. J., Lynch, N., and Paterson, M. S. 1985. Impossibility of distributed consensus with one faulty process. Journal of the ACM 32(2), 374–382。
- Gray, C. G. and Cheriton, D. R. 1989. Leases: An efficient fault-tolerant mechanism for distributed file cache consistency. In Proceedings of the Twelfth ACM Symposium on Operating Systems Principles, New York, pp. 202–210. ACM。
- Keidar, I. and Dolev, D. 1996. Efficient message ordering in dynamic networks. In Proceedings of the 15th Annual ACM Symposium on Principles of Distributed Computing. ACM。
- Ladin, R., Liskov, B., Shrira, L., and Ghemawat, S. 1992. Providing high availability using lazy replication. ACM Transactions on Computer Systems 10(4), 360–391。
- Lamport, L. 1978. Time, clocks, and the ordering of events in a distributed system. Communications of the ACM 21(7), 558–565。
- Lamport, L. 1984. Using time instead of timeout for fault-tolerant distributed systems. ACM Transactions on Programming Languages and Systems 6(2), 254–280。
- Lampson, B. W. 1996. How to build a highly available system using consensus. In O. Babaoglu and K. Marzullo (Eds.), Distributed Algorithms, Volume 1151 of Lecture Notes in Computer Science, Berlin, pp. 1–17. Springer-Verlag。
- Oki, B. M. and Liskov, B. H. 1988. Viewstamped replication: A new primary copy method to support highly-available systems. In Proceedings of the Seventh Annual ACM Symposium on Principles of Distributed Computing, pp. 8–17. ACM Press。
- Schneider, F. B. 1990. Implementing fault-tolerant services using the state machine approach: A tutorial. ACM Computing Surveys 22(4), 299–319。
- Skeen, M. D. 1982. Crash recovery in a distributed database system. Ph.D. thesis, University of California, Berkeley。
Received January 1990; Accepted March 1998。
机制索引
| 机制 | 本文位置 | 核心含义 |
|---|---|---|
| B1 | Section 2.1 | ballot number unique |
| B2 | Section 2.1 | 任意两个 quorum 相交 |
| B3 | Section 2.1 | 新 ballot 继承 quorum 中最高 prior vote 的 decree |
| Theorem 1 | Section 2.1 | 两个 successful ballot 不能选择不同 decree |
| Theorem 2 | Section 2.1 | 在足够大的相交 quorum 下可以创建保持 B1–B3 的 ballot |
| Basic Protocol | Section 2.3 | 只保证 consistency,不主动保证 progress |
| Complete Protocol | Section 2.4 | 通过 president、timer 与及时 action 推进 progress |
| Multi-Decree Parliament | Section 3 | 为每个 decree number 运行 Synod instance,并共享前两阶段 |
| State Machine Approach | Section 4.1 | 用共识得到 command sequence,再让各 server 执行相同 sequence |
本篇验收
- [x] 官方 Microsoft Research PDF 已固定到
source/part-time-parliament.pdf。 - [x] 33 个 PDF 页面均已渲染为
1224×1584PNG,并保存到assets/43 The Part-Time Parliament/。 - [x] 33 个页面图片均在对应译文前按原页顺序嵌入,显示宽度统一为
600。 - [x] Abstract、编辑说明、版权声明、正文 Sections 1–4、脚注、Figure 1–2、protocol steps、Theorem 1–2、Appendix A1–A2、invariant proof、Acknowledgments 和 References 均已覆盖。
- [x] ballot、quorum、decree、ledger、Synod、state machine、president、majority set 等术语按本系列约定保留 English 或中英并列。
- [x] 本地源文件 SHA-256:
93de820af20267fa2f227849fd7c5bc314cc867e6b88732c834cab9a24216f42。
参考资料
评论 (0)