分布式共识系统:从 Raft 到分布式 KV
分布式共识系统:从 Raft 到分布式 KV
本专栏从复制状态机开始,使用 Raft 和 MIT 6.5840 Labs,逐步实现 Leader Election、日志复制、持久化、Snapshot、容错 KV 和 Sharded KV。
TL;DR
- 实现主线:先实现 Raft 核心,再把它接到复制状态机、KV 服务和分片 KV。
- 首选教程:MIT 6.5840 Lab 3,官方提供 Go 骨架代码、模拟 RPC 网络和测试。
- 实现阶段:3A 选主 → 3B 日志复制 → 3C 持久化 → 3D 快照与日志压缩。
- 最终结果:得到一个能够在节点崩溃、网络丢包和网络分区下保持线性一致性的分布式 KV 原型。
- 边界:这是教学型 Raft 系统,不直接等同于 etcd、TiKV 等生产系统;生产实现会继续处理成员变更、线性一致性读、流控和运维问题。
名词解释
| 名词 | 含义 | 本专栏对应物 |
|---|---|---|
| Consensus | 多个节点对一系列值达成一致 | Raft 对 replicated log 的协议 |
| Replicated State Machine | 多个节点按相同顺序执行相同命令 | Lab 4 的 KV 服务 |
| Leader | 接收客户端请求并协调日志复制的节点 | Raft 集群中的唯一当前领导者 |
| Log | 按顺序记录客户端命令的日志 | LogEntry 序列 |
| Commit | 某条日志已被多数节点确认,可以交给状态机执行 | commitIndex 推进 |
| Snapshot | 状态机在某个日志位置的持久化状态 | Lab 3D 的日志压缩机制 |
目录
| 章节 | 内容 |
|---|---|
| 专栏范围与资料 | 原文版本和资料边界 |
| 学习与实现路线 | 从 Raft 到分片 KV 的依赖顺序 |
| 章节索引 | 每篇笔记的实现目标 |
| 验收标准 | 如何判断每个阶段真正完成 |
| 本轮验收记录 | 2026-09-20 的实测结果与范围 |
专栏范围与资料
本专栏以 MIT 6.5840 Spring 2026 的 distributed-systems material 为主线:01–06 覆盖 Lab 3、Lab 4、Lab 5,09 起补充 lecture track。01–06 按讲义正文顺序逐句翻译,英文后紧跟中文,代码、命令、示例输出和原图保留在对应位置;HTML 的排版换行不当作语义断句。07–08 是配套原创导读,不是官方资料全文译本;Raft 扩展论文、etcd README 和官方 TLA+ 规范的全文翻译尚未收录。
第一版论文范围已固定为 28 篇:第 31–58 篇共 28 篇论文已完成,第一版论文专题已收束;后续新增只作为第二版选读,不改变本专栏第一版完成标准。
实际实现工作区位于 implementation/6.5840/,基于 MIT 官方实验骨架,基线提交为 513cac0aef010750fc74688da8a395974a83cf7a。骨架、测试器和原有测试来自官方;填入的 Raft/KV/分片实现是本地教学实现,不是官方参考答案。 为修复已证实的测试框架竞态,本轮在 tester1/group.go 对服务器组生命周期加锁,并在 shardkv1/test.go 修正后台控制器的停止协议;另新增了针对实现修复的回归测试。最新实测结果见文末,译文中的示例输出不作为实测证据。
核心资料:
- Raft 官方网站和扩展论文:理解协议、Figure 2、Snapshot 和成员变更。
- MIT 6.5840 Lab 3:实现 Raft 的 3A–3D。
- MIT 6.5840 Lab 4:使用 Raft 构造容错 KV 和复制状态机。
- MIT 6.5840 Lab 5:实现 Sharded KV 和配置变更。
- etcd/raft:最后用生产级实现对照教学版本的边界。
学习与实现路线
flowchart LR
A[共识与复制状态机] --> B[3A Leader Election]
B --> C[3B Log Replication]
C --> D[3C Persistence]
D --> E[3D Snapshot]
E --> F[Lab 4 Replicated KV]
F --> G[Lab 5 Sharded KV]
先建立正确的系统边界
flowchart TD
Client[客户端命令] --> Leader[Raft Leader]
Leader --> Log[复制日志]
Log --> Followers[多数 Follower]
Followers --> Commit[提交位置]
Commit --> StateMachine[本地状态机]
StateMachine --> Reply[客户端响应]
Raft 本身不等于数据库。Raft 负责让多个节点对命令顺序达成一致;KV、表或其他状态机负责解释并执行这些命令。只有所有节点按相同顺序应用相同日志,副本状态才会保持一致。
故障模型
flowchart TD
Healthy[多数节点可通信] --> Progress[系统继续提交日志]
Partition[网络分区或节点故障] --> Majority{是否仍有多数派?}
Majority -->|是| Progress
Majority -->|否| Pause[停止推进,但不返回错误结果]
Pause --> Recover[多数派恢复通信]
Recover --> Progress
Raft 可以在多数节点存活并能够互相通信时继续工作;如果没有多数派,系统应停止推进,而不是让不同分区分别提交互相冲突的结果。
章节索引
| 序号 | 主题 | 实现结果 |
|---|---|---|
| 01 | 分布式共识与复制状态机 | Lab 3 简介、准备工作与接口完整译文 |
| 02 | Raft Figure 2 与 3A-3B 日志复制 | 3A、3B 完整译文与实现讲解 |
| 03 | Lab 3C 持久化与重启恢复 | 3C 完整译文与持久化恢复 |
| 04 | Lab 3D 快照与日志压缩 | 3D 完整译文与快照 |
| 05 | Lab 4 容错 KV 与复制状态机 | Lab 4 全部正文译文与 RSM/KV |
| 06 | Lab 5 分片 KV 与分片迁移 | Lab 5 全部正文译文;实现范围为 5A–5C |
| 07 | etcd raft 源码导读 | 原创补充:生产级模块边界 |
| 08 | TLA+ 与正确性验证 | 原创补充:有限模型实践 |
| 09 | 6.5840:Lecture 01 Introduction | Spring 2026 Lecture 1 逐行译注:课程结构与 MapReduce |
| 10 | 6.5840:Lecture 02 Threads and RPC | Spring 2026 Lecture 2 逐行译注:Go threads、并发爬虫与 RPC |
| 11 | 6.5840:Lecture 03 GFS | Spring 2026 Lecture 3 逐行译注:GFS 的分片、复制、一致性与故障恢复 |
| 12 | 6.5840:Lecture 04 Fault-Tolerant Agreement and Paxos | Spring 2026 Lecture 4 逐行译注:quorum、Paxos 与 replicated state machine |
| 13 | 6.5840:Lecture 05 Go Patterns | Spring 2026 guest lecture:Go concurrency patterns,73 页已完成 |
| 14 | 6.5840:Lecture 06 RSM and Raft 1 | Spring 2026 Lecture 6 逐行译注:RSM、leader election、term 与日志 divergence |
| 15 | 6.5840:Lecture 07 Raft 2 | Spring 2026 Lecture 7 逐行译注:日志收敛、Election Restriction、persistence、snapshot 与 read-only operations |
| 16 | 6.5840:Lecture 08 Linearizability | Spring 2026 Lecture 8 逐行译注:consistency models、linearizability、history 与 eventual consistency |
| 17 | 6.5840:Lecture 09 ZooKeeper | Spring 2026 Lecture 9 逐行译注:ZooKeeper data model、session、watch、fencing 与性能取舍 |
| 18 | 6.5840:Lecture 10 Q&A Lab 3A+B | Spring 2026 Lecture 10 逐行译注:Raft library 结构、safety/liveness、debugging、locking 与 code tour |
| 19 | 6.5840:Lecture 11 Distributed Transactions | Spring 2026 Lecture 11 逐行译注:ACID、serializability、2PL、2PC、failure recovery 与 Raft 边界 |
| 20 | 6.5840:Lecture 12 Spanner | Spring 2026 Lecture 12 逐行译注:Paxos、2PC、Snapshot Isolation、safe time、TrueTime 与 external consistency |
| 21 | 6.5840:Lecture 13 Chain Replication | Spring 2026 Lecture 13 逐行译注:primary/backup、ROWA、Chain Replication、CFG、failure recovery 与 sharding |
| 22 | 6.5840:Lecture 14 FaRM OCC | Spring 2026 Lecture 14 逐行译注:FaRM、NVRAM、kernel bypass、RDMA、OCC、2PC 与 recovery |
| 23 | 6.5840:Lecture 15 IronFleet | Spring 2026 Lecture 15 逐行译注:IronFleet、formal verification、Hoare logic、refinement、invariants 与 Dafny |
| 24 | 6.5840:Lecture 16 Memcached | Spring 2026 Lecture 16 逐行译注:Memcache、look-aside cache、sharding/replication、lease、Gutter 与 consistency |
| 25 | 6.5840:Lecture 17 AWS Lambda | Spring 2026 Lecture 17 逐页逐行译注:container loading、MicroVM、Firecracker、cache hierarchy、erasure coding 与 isolation |
| 26 | 6.5840:Lecture 18 Ray | Spring 2026 Lecture 18 逐行译注:futures、actors、ownership、distributed scheduler、object store、lineage reconstruction 与 fate sharing |
| 27 | 6.5840:Lecture 19 SUNDR | Spring 2026 Lecture 19 逐行译注:SUNDR、untrusted storage、hash tree、digital signature、fork consistency 与 version vector |
| 28 | 6.5840:Lecture 20 Bitcoin | Spring 2026 Lecture 20 逐行译注:double spending、public ledger、proof-of-work、blockchain fork、51% attack 与 validation |
| 29 | 6.5840:Lecture 21 Byzantine Fault Tolerance | Spring 2026 Lecture 21 逐行译注:Byzantine faults、PBFT、quorum、view change、PRE-PREPARE/PREPARE/COMMIT 与 recovery |
| 30 | 6.5840:Lecture 22 Project demos | Spring 2026 Lecture 22 逐条译注:Project 选择、proposal、实现、write-up、presentation 与官方选题方向;课程日程没有独立讲义 |
| 31 | 论文:Raft 可理解的共识算法(扩展版) | Raft 2014 Extended Version:replicated state machine、Paxos 对比、leader election、log replication、safety、joint consensus、snapshot、client interaction 与 evaluation |
| 32 | 论文:The Google File System(GFS) | GFS 2003:master/chunkserver 架构、large chunk、lease、primary mutation order、record append、snapshot、replication、garbage collection、checksum、measurement 与 workload |
| 33 | 论文:Paxos Made Simple | Paxos Made Simple:consensus safety、majority、P1/P2/P2c、prepare/accept 两阶段、learner、progress、stable storage、state machine、多 instance 与 reconfiguration |
| 34 | 论文:Spanner:Google’s Globally-Distributed Database | Spanner:Paxos per tablet、directory placement、TrueTime、external consistency、safe time、2PL、2PC、schema-change transaction 与 F1 case study |
| 35 | 论文:Secure Untrusted Data Repository(SUNDR) | SUNDR:untrusted storage、fork consistency、hash tree、i-handle、version vector、Serialized/Concurrent SUNDR、VSL/PVL、bstor、性能与 CVS |
| 36 | 论文:Practical Byzantine Fault Tolerance(PBFT) | PBFT:n = 3f + 1、PRE-PREPARE/PREPARE/COMMIT、checkpoint、water mark、view change、MAC authenticator、BFS 与 Andrew benchmark |
| 37 | 论文:Dynamo:Amazon’s Highly Available Key-value Store | Dynamo:consistent hashing、virtual node、vector clock、N/R/W、sloppy quorum、hinted handoff、Merkle anti-entropy、gossip membership 与 production lessons |
| 38 | 论文:The Chubby Lock Service for Loosely-Coupled Distributed Systems | Chubby:Paxos、master lease、cell、advisory lock、sequencer、consistent cache、session/grace period、failover、proxy、partitioning 与 name service |
| 39 | 论文:Bigtable:A Distributed Storage System for Structured Data | Bigtable:sparse sorted map、row/column family/timestamp、tablet、SSTable、Chubby、METADATA、assignment、compaction、locality group、Bloom filter、performance 与 production workload |
| 40 | 论文:MapReduce:Simplified Data Processing on Large Clusters | MapReduce:Map/Reduce programming model、shuffle、master/worker、re-execution、atomic commit、locality、task granularity、backup task、combiner、counters、performance 与 indexing |
| 41 | 论文:ZooKeeper:Wait-free Coordination for Internet-scale Systems | ZooKeeper:coordination kernel、znode/data tree、ephemeral/sequential node、watch、session、A-linearizability、configuration、membership、lock、barrier、Zab、fuzzy snapshot、local read 与 performance |
| 42 | 论文:Chain Replication for Supporting High Throughput and Availability | Chain Replication:storage service interface、head/tail、strong consistency、update propagation invariant、Sent list、failure reconfiguration、primary/backup 对比、replica placement、parallel recovery 与 MTBU |
| 43 | 论文:The Part-Time Parliament | The Part-Time Parliament:ballot、quorum、B1/B2/B3、Theorem 1/2、Synod basic/complete protocol、multi-decree Parliament、state-machine approach 与 consistency invariant proof |
| 44 | 论文:Viewstamped Replication Revisited | Viewstamped Replication:2f + 1 replica group、primary/backup、normal operation、view change、recovery、checkpoint/Merkle tree、witness、fast reads、epoch reconfiguration 与 correctness |
| 45 | 论文:Implementing Fault-Tolerant Services Using the State Machine Approach | State Machine Approach:deterministic state machine、Replica Coordination、Agreement/Order、logical/real-time/replica-generated identifier、stability、faulty output/client、time-triggered request 与 reconfiguration |
| 46 | 论文:The Byzantine Generals Problem | Byzantine Generals:IC1/IC2、oral-message lower bound、OM(m)、signed-message SM(m)、3m + 1、regular graph、connectivity、timeout/clock、signature 与 reliable-system mapping |
| 47 | 论文:Time, Clocks, and the Ordering of Events in a Distributed System | Lamport clocks:happened-before、concurrent、Clock Condition、IR1/IR2、total ordering、mutual exclusion、State Machine、Strong Clock Condition、physical clock synchronization 与 skew bound |
| 48 | 论文:Distributed Snapshots: Determining Global States of Distributed Systems | Distributed Snapshot:global state、channel state、stable property、marker、consistent cut、termination、Theorem 1、stability detection 与 checkpoint |
| 49 | 论文:Impossibility of Distributed Consensus with One Faulty Process | FLP impossibility:asynchronous model、admissible run、partial/total correctness、Lemma 1–3、bivalent/univalent configuration、nondeciding run、initially dead majority protocol 与 Theorem 2 |
| 50 | 论文:End-to-End Arguments in System Design | End-to-End:application requirements、low-level correctness/performance boundary、careful file transfer、delivery acknowledgement、encryption、duplicate suppression、FIFO、SWALLOW、voice、layering |
| 51 | 论文:A Protocol for Packet Network Intercommunication | Cerf–Kahn internetwork protocol:异构 packet networks、GATEWAY、addressing、fragmentation、TCP、sequencing、window、flow control、SYN/REL 与 association |
| 52 | 论文:Congestion Avoidance and Control | Jacobson/Karels:packet conservation、slow-start、self-clocking、RTT mean/variation、exponential backoff、congestion avoidance、AIMD、gateway-side control、实验与 TCP timer interaction |
| 53 | 论文:The Design Philosophy of the DARPA Internet Protocols | Clark:Internet architecture goals、survivability、fate-sharing、datagram、IP/TCP layering、multiple service types、realization、flow 与 soft state |
| 54 | 论文:The Transaction Concept Virtues and Limitations | Gray:transaction 的 consistency/atomicity/durability、Nonstop、time-domain addressing、logging、locking、two-phase commit、nested 与 long-lived transactions |
| 55 | 论文:Consensus in the Presence of Partial Synchrony | Dwork/Lynch/Stockmeyer:partial synchrony、GST、fail-stop/omission/Byzantine faults、basic round model、distributed clocks、resiliency bounds 与 lower bounds |
| 56 | 论文:The Weakest Failure Detector for Solving Consensus | Chandra/Hadzilacos/Toueg:eventually weak failure detector ◇𝒲、eventually trusting detector 𝒱、reducibility、DAG、simulation forest、valency、fork/hook 与 weakest-detector theorem |
| 57 | 论文:Harvest, Yield, and Scalable Tolerant Systems | Fox/Brewer:Strong/Weak CAP、harvest/yield、probabilistic availability、application decomposition、orthogonal mechanisms、SNS、SRM 与 soft state |
| 58 | 论文:CAP Twelve Years Later How the Rules Have Changed | Brewer:CAP “2 of 3” 的误导、latency/partition decision、ACID/BASE、partition mode、version vector、CRDT、recovery 与 compensation |
验收标准
- [x] 能解释为什么单副本 KV 不能抵抗节点故障。
- [x] 能画出客户端命令从 Leader 到状态机的路径。
- [x] 3A 测试通过:初次选主、重新选主和多次选举。
- [x] 3B 测试通过:日志复制、提交和不可靠网络。
- [x] 3C 测试通过:持久化状态和重启恢复。
- [x] 3D 测试通过:Snapshot、InstallSnapshot 和日志压缩。
- [x] Lab 4 本轮完整
-race测试返回 PASS;部分线性一致性检查超时,限制见下表。 - [x] Lab 5 完整
-race回归通过:5A–5C 全部通过;线性一致性检查的已知超时限制见下表。 - [x] 已完成 etcd/raft 的
Node、Ready、Storage和应用驱动循环源码导读。 - [x] 已完成 TLA+ 模型的状态、动作、不变量和 Raft 安全性对照。
- [x] 已完成 Spring 2026 Lecture 1《Introduction》的 316 行逐行译注;MapReduce ASCII 示意、代码块和原文 diagram 占位均保留。
- [x] 已完成 Spring 2026 Lecture 2《Threads and RPC》的 308 行逐行译注;
crawler.go与kv.go代码完整保留,原文 diagram 占位均保留。 - [x] 已完成 Spring 2026 Lecture 3《GFS》的 351 行逐行译注;GFS 的文字 diagram 占位、术语、URL 和原文顺序均保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 4《Fault-Tolerant Agreement, Paxos》的 351 行逐行译注;Paxos 伪代码、状态示意、文字 diagram 占位和协议变量均保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 5 guest lecture《Go Patterns》73 页逐页翻译;代码、race output、stack trace、提示框和矢量图示位置按页面顺序保留,源 PDF 没有独立 raster image。
- [x] 已完成 Spring 2026 Lecture 6《RSM and Raft (1)》219 行逐行译注;RSM diagram、选举时序、日志示意和原文 diagram 占位均保留。
- [x] 已完成 Spring 2026 Lecture 7《Raft (2)》363 行逐行译注;日志 trace、Election Restriction、持久化字段、snapshot diagram 占位、InstallSnapshot 和 read-only operations 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 8《Consistency and Linearizability》346 行逐行译注;History 1–6、ASCII 时序图、linearization point、stale read、retransmission 和 eventual consistency 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 9《Zookeeper Case Study》287 行逐行译注;ZooKeeper API、coordinator election、ready znode scheme、session termination、fencing、read guarantees 和性能讨论均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 10《Lab 3 A+B Q&A》75 行逐行译注;Raft library 的 multi-threaded/single-threaded 结构、safety/liveness、debugging、locking 和 code tour 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 11《Distributed Transactions》333 行逐行译注;ACID、serializability、2PL、2PC、participant/TC failure recovery、blocking 和 Raft 边界均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 12《Spanner》330 行逐行译注;Paxos + 2PC、Snapshot Isolation、safe time、TrueTime、commit wait 和 external consistency 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 13《Chain Replication》357 行逐行译注;primary/backup、ROWA、Chain Replication、CFG、failure recovery、lease、quorum、sharding 和 rndpar 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 14《FaRM, Optimistic Concurrency Control》339 行逐行译注;NVRAM、kernel bypass、RDMA、OCC、LOCK、VALIDATE、COMMIT protocol、recovery 和 Spanner 对比均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 15《Verification: IronFleet》160 行逐行译注;IronFleet methodology、mechanized verification、Hoare logic、state-machine refinement、inductive invariants、proof engineering、liveness/safety、limitations 和 sort.dfy 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 16《Scaling Memcache at Facebook》291 行逐行译注;Facebook infrastructure、look-aside cache、sharding/replication、multiple regions、regional pool、thundering herd、Gutter、lease、eventual consistency 和 read-your-own-writes 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 17《AWS Lambda》57 页逐页逐行译注;每页原始 792×612 points 页面均以 1584×1224 PNG 嵌入并按 792 宽度显示,container loading、lazy loading、MicroVM、Firecracker、L1/L2/L3、erasure coding、userfaultfd、tenant/session isolation、SHA2、AES-GCM、KMS Key 和权限边界均按页面顺序保留;AWS 版权声明和页面内图示均保留。
- [x] 已完成 Spring 2026 Lecture 18《Ray》223 行逐行译注;futures、actors、borrowing、ownership sharding、centralized coordinator、lineage reconstruction、distributed scheduler、object store、GC、fate sharing 和 homework 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 19《Secure Untrusted Data Repository (SUNDR)》306 行逐行译注;integrity、cryptographic hash、digital signature、content-hash storage、hash tree、strawman log、fork consistency、serialized SUNDR 和 version vector 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 20《Bitcoin》292 行逐行译注;double spending、public ledger、peer network、blockchain、proof-of-work、fork resolution、confirmation、51% attack、mining incentives、validation checks 和 Q&A 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 21《Byzantine Fault Tolerance》342 行逐行译注;Byzantine fault model、3f+1/2f+1 quorum、Design 1–4、primary、PRE-PREPARE/PREPARE/COMMIT、view change、NEW-VIEW、checkpoint 和 recovery 均按原文顺序保留;源文件没有独立图片。
- [x] 已完成 Spring 2026 Lecture 22《Project demos》逐条译注;官方日程仅列出 Project demos,没有独立 lecture notes;官方 Project 页面中的项目选择、批准、组队、proposal、实现、write-up、presentation 和全部选题建议均按原顺序保留;页面没有独立图片。
- [x] 已完成 Raft 2014 Extended Version 全 18 页逐段译注;原始页面、Figure 1–16、RPC/state/rules、safety proof、joint consensus、snapshot、InstallSnapshot、client interaction、evaluation、related work、Conclusion 和 39 条 References 均已保留或翻译;18 张页面 PNG 按原页宽度嵌入。
- [x] 已完成 GFS 2003 论文全 15 页逐段译注;原始页面、Figure 1–3、Table 1–6、master/chunkserver 架构、lease、mutation order、record append、snapshot、metadata、replica placement、garbage collection、stale replica、checksum、measurement、workload、Experiences、Conclusion 和 References 均已保留或翻译;15 张页面 PNG 按原页宽度嵌入。
- [x] 已完成 Leslie Lamport《Paxos Made Simple》全 14 页逐段译注;原始页面、Contents、P1/P2/P2a/P2b/P2c/P1a、Phase 1–2、learner、progress、stable storage、state-machine implementation、no-op gap、α-command pipeline、reconfiguration 和 5 条 References 均已保留或翻译;14 张页面 PNG 按原页宽度嵌入。
- [x] 已完成 OSDI 2012《Spanner: Google’s Globally-Distributed Database》全 14 页逐段译注;原始页面、Figure 1–6、Table 1–6、Paxos per tablet、directory placement、TrueTime、external consistency、safe time、2PL、2PC、schema-change transaction、F1 case study、Future Work、Conclusion、Acknowledgements、42 条 References 和 Appendix A 均已保留或翻译;14 张页面 PNG 按原页宽度嵌入。
- [x] 已完成《Secure Untrusted Data Repository(SUNDR)》全 16 页逐段译注;原始页面、Figure 1–13、Sections 1–9、fork consistency、hash tree、i-handle、version vector、Serialized/Concurrent SUNDR、update certificate、VSL/PVL、bstor、性能评估、CVS workload、Acknowledgments 和 35 条 References 均已保留或翻译;16 张页面 PNG 按原页宽度嵌入。
- [x] 已完成《Practical Byzantine Fault Tolerance(PBFT)》全 14 页逐段译注;原始页面、Figure 1–2、Sections 1–9、
n = 3f + 1、PRE-PREPARE/PREPARE/COMMIT、checkpoint、water mark、view change、safety/liveness、non-determinism、MAC authenticator、BFS、micro-benchmark、Andrew benchmark、Acknowledgments 和 37 条 References 均已保留或翻译;14 张页面 PNG 按原页宽度嵌入。 - [x] 已完成《Dynamo: Amazon’s Highly Available Key-value Store》全 16 页逐段译注;原始页面、Figure 1–8、Table 1–2、Sections 1–7、consistent hashing、virtual node、preference list、vector clock、N/R/W、sloppy quorum、hinted handoff、Merkle anti-entropy、gossip membership、read repair、partitioning strategies、production lessons 和 24 条 References 均已保留或翻译;16 张页面 PNG 按原页宽度嵌入。
- [x] 已完成《The Chubby Lock Service for Loosely-Coupled Distributed Systems》全 16 页逐段译注;原始页面、Figure 1–2、Sections 1–6、Paxos/master lease、cell、file/ACL/handle、advisory lock、sequencer、events、API、consistent cache、session/grace period、failover、database、backup、mirroring、proxy、partitioning、production statistics、name service、lessons 和 24 条 References 均已保留或翻译;16 张页面 PNG 按原页宽度嵌入。
- [x] 已完成《Bigtable: A Distributed Storage System for Structured Data》全 14 页逐段译注;原始页面、Figure 1–6、Table 1–2、Row/Column Family/Timestamp data model、API 代码、SSTable、Chubby、tablet location、assignment、serving、compaction、locality group、compression、cache、Bloom filter、commit-log recovery、performance、Google Analytics/Google Earth/Personalized Search、lessons、related work 和 38 条 References 均已保留或翻译;14 张页面 PNG 按原页宽度嵌入。
- [x] 已完成《MapReduce: Simplified Data Processing on Large Clusters》全 13 页逐段译注;原始页面、Figure 1–4、Table 1、Figure 2/3 性能曲线、Map/Reduce pseudo-code、counter 示例、Appendix A 完整 C++ program、programming model、execution overview、fault tolerance、locality、task granularity、backup task、partitioning、ordering、combiner、bad-record skipping、performance、indexing、related work 和 18 条 References 均已保留或翻译;13 张页面 PNG 按原页宽度嵌入。
- [x] 已完成《ZooKeeper: Wait-free Coordination for Internet-scale Systems》全 14 页逐段译注;原始页面、Figure 1–8、Table 1–3、znode/data tree、ephemeral/sequential node、watch、session、API、A-linearizability、ready znode、configuration/rendezvous/group membership、lock/read-write lock/double barrier、Zab、fuzzy snapshot、local read、session migration、failure injection、performance、related work 和 31 条 References 均已保留或翻译;14 张页面 PNG 按原页宽度嵌入。
- [x] 已完成《Chain Replication for Supporting High Throughput and Availability》全 14 页逐段译注;原始页面、Figure 1–7、Table 1、client-view state machine、head/tail、strong consistency、update propagation invariant、Sent list、head/tail/middle failure、chain extension、primary/backup 对比、single/multiple chain simulation、failure throughput、replica placement、parallel recovery、MTBU、related work、conclusions、6 条 endnotes 和 25 条 References 均已保留或翻译;14 张页面 PNG 按原页宽度嵌入。
- [x] 已完成《The Part-Time Parliament》全 33 页逐段译注;固定 Microsoft Research 官方 PDF,覆盖 Abstract、编辑说明、版权声明、Sections 1–4、Figure 1–2、ballot/quorum、B1/B2/B3、Theorem 1/2、Synod preliminary/basic/complete protocol、multi-decree Parliament、state-machine approach、commit protocol、Appendix A invariant proof、Acknowledgments 和 15 条 References;33 张 1224×1584 页面 PNG 按 600 宽度嵌入。
- [x] 已完成《Viewstamped Replication Revisited》全 16 页逐段译注;固定 MIT CSAIL Technical Report MIT-CSAIL-TR-2012-021,覆盖 Abstract、Sections 1–9、Figure 1–4、
2f + 1replica group、primary/backup、normal operation、view change、recovery、checkpoint/Merkle tree、witness、batching、fast reads、state transfer、epoch reconfiguration、safety/liveness、Conclusions 和 13 条 References;16 张 1224×1584 页面 PNG 按 600 宽度嵌入。 - [x] 已完成《Implementing Fault-Tolerant Services Using the State Machine Approach: A Tutorial》全 21 页逐段译注;固定 Cornell 官方
SMSurvey.pdf,覆盖 Abstract、Sections 1–8、Figure 1–4、memory/mutex/tally 伪代码、Agreement/Order、logical/real-time/replica-generated identifier、stability test、faulty output/client、time-triggered request、reconfiguration、repair integration、restart stability、Acknowledgments 和完整 References;21 张按原始 page rectangle 渲染的页面 PNG 按 600 宽度嵌入。 - [x] 已完成《The Byzantine Generals Problem》全 20 页逐段译注;固定 Microsoft Research 官方 PDF,覆盖 Abstract、Introduction、IC1/IC2、three-general impossibility、
3m + 1lower bound、approximate agreement、OM(m)、SM(m)、Figure 1–7、不完全 communication graph、reliable system、A1–A4、timeout/clock、signature、Conclusion 和 4 条 References;20 张页面 PNG 按 600 宽度嵌入。 - [x] 已完成《Time, Clocks, and the Ordering of Events in a Distributed System》全 8 页逐段译注;固定 Microsoft Research / ACM 官方 PDF,覆盖 Abstract、Introduction、The Partial Ordering、happened-before、concurrent、Figure 1–3、Logical Clocks、Clock Condition、C1/C2、IR1/IR2、total ordering、mutual exclusion 五条 rules、State Machine、failure boundary、Anomalous Behavior、Strong Clock Condition、Physical Clocks、PC1/PC2、IR1′/IR2′、Theorem、Conclusion、Appendix proof、Acknowledgment 和 4 条 References;8 张 1224×1584 页面 PNG 按 600 宽度嵌入。
- [x] 已完成《Distributed Snapshots: Determining Global States of Distributed Systems》全 13 页逐段译注;固定 Microsoft Research / ACM 官方 PDF,覆盖 Abstract、Introduction、stable property、system model、Figure 1–8、Examples 2.1/2.2/3.1/4.1、marker rules、termination、Theorem 1、proof、stability detection、Acknowledgments 和 11 条 References;13 张按原始 page rectangle 渲染的页面 PNG 按原图比例嵌入。
- [x] 已完成《Impossibility of Distributed Consensus with One Faulty Process》全 9 页逐段译注;固定 MIT DSpace 记录与 MIT CSAIL PDF 镜像,覆盖 Abstract、Introduction、asynchronous assumptions、consensus protocol model、Lemma 1–3、Theorem 1、bivalence proof、admissible nondeciding run、Initially Dead Processes、Theorem 2、Conclusion、Acknowledgment 和 25 条 References;9 张页面 PNG 按原图比例嵌入。
- [x] 已完成《End-to-End Arguments in System Design》全 10 页逐段译注;固定 MIT 官方 PDF,覆盖 Abstract、Introduction、end-to-end argument、careful file transfer、performance tradeoff、delivery guarantees、secure transmission、duplicate suppression、FIFO、SWALLOW、packet voice、history、RISC、open operating system、Conclusions、Acknowledgements 和 17 条 References;10 张
1224×1584页面 PNG 按600宽度嵌入。 - [x] 已完成《A Protocol for Packet Network Intercommunication》全 13 页逐段译注;固定 1974 IEEE 版本,覆盖 Abstract、Introduction、GATEWAY、internetwork packet format、fragmentation、accounting、process-level communication、addressing、TCP/port、segment/packet format、reassembly、sequencing、retransmission、duplicate detection、window、flow control、TCP I/O、TCB/RCB、association、SYN/REL、Conclusions、Acknowledgment、18 条 References 和作者简介;13 张
1190×1684页面 PNG 按600宽度嵌入。 - [x] 已完成《Congestion Avoidance and Control》作者注明的 November 1988 slightly revised version 全 25 页逐段译注;固定公开 PDF,覆盖 congestion collapse、packet conservation、slow-start、self-clocking、RTT mean/variation、exponential backoff、congestion avoidance、AIMD、gateway-side control、实验、Appendix A–D 和 26 条 References;25 张
1190×1684页面 PNG 按600宽度嵌入。 - [x] 已完成《The Design Philosophy of the DARPA Internet Protocols》SIGCOMM ’88 版本全 10 页逐段译注;覆盖 Internet architecture goals、survivability、fate-sharing、datagram、TCP/IP layering、types of service、network varieties、realization、performance、flow、soft state、Rubber EOL 脚注和 18 条 References;10 张
1224×1584页面 PNG 按600宽度嵌入。 - [x] 已完成《The Transaction Concept: Virtues and Limitations》Jim Gray 1981 年版本全 11 页逐段译注;覆盖 transaction model、consistency/atomicity/durability、unprotected/protected/real actions、Nonstop、update-in-place、time-domain addressing、Figures 1–5、logging、locking、restartability、two-phase commit、nested、long-lived、programming-language integration 和 References;11 张按原始页面比例渲染的 PNG 按
600宽度嵌入。 - [x] 已完成《Consensus in the Presence of Partial Synchrony》JACM 1988 版本全 36 页逐段译注;覆盖 partial synchrony 的两种定义、GST、Table I、fail-stop/omission/authenticated Byzantine/unauthenticated Byzantine、basic round model、Algorithms 1–6、BROADCAST、distributed clocks、Theorems 3.1–6.7、lower bounds、open questions 和 20 条 References;36 张按原始 page rectangle 渲染的 PNG 按
600宽度嵌入。 - [x] 已完成《The Weakest Failure Detector for Solving Consensus》JACM 1996 版本全 38 页逐段译注;固定 University of Texas PDF mirror,SHA-256 为
d1068e16924fce1745cf96f85212035dad763907416776ea815626a7a685eb,按原始 page rectangle 渲染 38 张 PNG 并按600宽度嵌入。覆盖◇𝒲、𝒱、reducibility、failure-pattern/history model、DAG、simulation forest、valency、critical index、fork/hook、Theorems 5.1–5.4、Lemmata 6.2–6.6、weak consensus、infinite-range detector、Appendix A 和 10 条 References;单篇 checker/lint、38/38 图片顺序核对和git diff --check均通过。 - [x] 已完成《Harvest, Yield, and Scalable Tolerant Systems》HotOS-VII 1999 版本全 5 页逐段译注;固定 Berkeley RAD Lab 作者 PDF,SHA-256 为
dd4f89bff6afa94d9960932ec678f4c68c5fa4d94048bc940d4bc06de1e34d3d,按原始 page rectangle 渲染 5 张 PNG 并按600宽度嵌入。覆盖 Strong/Weak CAP、harvest/yield、single-location update、probabilistic availability、random placement/replication、application decomposition、orthogonal mechanisms、SNS、SRM、soft state、Discussion 和 24 条 References;单篇 checker/lint、5/5 图片顺序核对和git diff --check均通过。 - [x] 已完成《CAP Twelve Years Later: How the “Rules” Have Changed》IEEE Computer 2012 版本全 7 页逐段译注;固定作者上传的 IEEE Computer PDF mirror,SHA-256 为
86aa6800e67cfdff3d8e861310df189720eaa00a9ff00b21f622383b9e063e91,按原始 page rectangle 渲染 7 张 PNG 并按600宽度嵌入。覆盖“2 of 3”误导、CAP-latency connection、ACID/BASE/CAP 与 CAP Confusion 侧栏、partition mode、Figure 1、version vectors、CRDT、partition recovery、compensating transactions、ATM 案例和 16 条 References;单篇 checker/lint、7/7 图片顺序核对和git diff --check均通过。
本轮验收记录
验收日期:2026-09-20。测试显式使用 -count=1 或 -count=3,没有使用缓存结果;修改 Raft 后重新构建了实际被测试调用的 daemon。Lecture 1–4 的官方纯文本源分别固定为 316 行、308 行、351 行、351 行,并单独完成源行顺序核对。
| 项目 | 本轮结果 |
|---|---|
| 原文覆盖与顺序 | 01–05 与 Lab 3/4 的全部正文块逐项对应;Lab 5 的 166 个正文句子顺序检查通过,9 个代码/输出块齐全,原图位置及 PNG 文件检查通过 |
| 笔记格式与链接 | 23 个 Markdown 文件的 checker、lint 通过;参考资料的 14 个去重外部链接均返回 HTTP 200 |
| Raft 定向故障回归 | Figure 8 不可靠网络与重新选主各 3 次通过,总耗时 129.638 秒 |
Raft 完整 -race 回归 | 3A–3D 与新增两个回归测试全部通过,433.127 秒 |
单机 KV -race 回归 | 官方测试与新增失败重试测试通过,38.296 秒 |
RSM -race 回归 | 全部测试通过,60.566 秒 |
| 复制 KV | 修复后,原失败分区测试连续 3 次通过(38.361 秒);完整 4B/4C 及新增回归测试返回 PASS(210.453 秒)。TestSnapshotRecoverManyClients4C 内部 3 次线性一致性检查超时,不能据此宣称这些历史已被完整验证 |
| 分片 KV | 修复测试框架启动/清理竞态及控制器停止协议后,完整 go test -race -count=1 -v -timeout 15m ./shardkv1 通过,耗时 566.595 秒。此前精确 5C race 回归连续 3 次通过、150.529 秒。完整运行中 TestManyConcurrentClerkReliable5A 的线性一致性求解超时后被框架接受,不能据此宣称该段历史获得完整证明 |
| TLC 有限模型 | 3459 个生成状态、401 个不同状态、队列清空;未发现 NoCommittedDivergence 反例 |
复查译文的命令:
cd "/Users/maxingfang/w/w/21 数据库实现/04 分布式共识系统"
python3 -B source/audit_translation.py
该检查验证英文原文覆盖、顺序、代码块和图片位置,不等于自动证明中文翻译准确。中文译文仍需人工审校。
本轮修复了两个可复现的 Raft 问题:延迟回复占满复制槽位后堵住周期心跳;以及 follower 把本次 RPC 尚未核对的冲突尾部提交给状态机。另为单机 KV 失败重试加入暂停,避免已关闭网络下的 CPU 空转,并修复复制 KV 在 ErrWrongLeader 之后丢失写入不确定性的错误。对应回归测试均先复现失败,再验证修复。
复现代码验收时,应在 implementation/6.5840/src/ 中先构建 daemon,再分别运行各包;分包运行能及时看到测试输出,避免多包汇总输出掩盖早已发生的失败:
go build -race -o main/raft1d main/raft1d.go
go test -race -count=1 -v -timeout 15m ./raft1
go build -race -o main/rsm1d main/rsm1d.go
go test -race -count=1 -v -timeout 5m ./kvraft1/rsm
go build -race -o main/kvraft1d main/kvraft1d.go
go test -race -count=1 -v -timeout 6m ./kvraft1
go build -race -o main/kvsrv1d main/kvsrv1d.go
go build -race -o main/shardgrp1d main/shardgrp1d.go
go test -race -count=1 -v -timeout 15m ./shardkv1
分片测试曾报告一个测试框架竞态:ServerGrp.disconnect() 读取 sg.srvs,同时 StartServer() 写入同一数组位置。读取来自 Cleanup(),写入来自 shardkv1/test.go 启动、但在 partitionCtrler() 返回前未等待退出的后台 goroutine。经授权后,tester1/group.go 新增 lifecycleMu:同一服务器组的启动、关闭、连接重配和状态读取会串行进行,避免在服务器槽位被替换时读取它;GetConnected() 同时改为返回锁保护的副本。修复后执行:
go test -race -count=3 -v -timeout 8m \
-run '^TestPartitionRecoveryUnreliableNoClerk5C$' ./shardkv1
三次均通过,总耗时 150.529 秒,未出现 WARNING: DATA RACE。随后定位到另一处测试 liveness 缺陷:concurCtrler() 向无缓冲 channel 逐个发送停止信号,而后台控制器可能阻塞在被设计为无限重试的迁移 RPC 中,主测试便会永久卡在发送。现改为关闭 done channel 广播停止请求,不等待 worker 返回到 select;正在执行的迁移保留其原有重试语义。修复后,TestAcquireLockConcurrentUnreliable5C 连续 5 次通过(132.171 秒),完整 5A–5C 的 -race 套件通过,耗时 566.595 秒。
边界:通过测试不等于完整正确性证明;TLC 只检查附带的有限抽象模型。Lab 5 Part D 已翻译但未实现。分片客户端仍有教学性超时策略,配置查询超时并不取消底层请求;本轮重试暂停缓解空转,不应表述为已经消除所有 goroutine 泄漏。
参考资料
评论 (0)