MIT6.5840-2024 Lab2: Key/Value Server

MIT6.5840-2024 Lab2: Key/Value Server
ExisfarLab2: Key/Value Server
Lab2 URL: http://nil.csail.mit.edu/6.5840/2024/labs/lab-kvsrv.html
In this lab you will build a key/value server for a single machine that ensures that each operation is executed exactly once despite network failures and that the operations are linearizable. Later labs will replicate a server like this one to handle server crashes.
Key/value server with no network failures
Your first task is to implement a solution that works when there are no dropped messages.
You’ll need to add RPC-sending code to the Clerk Put/Append/Get methods in client.go, and implement Put, Append() and Get() RPC handlers in server.go.
You have completed this task when you pass the first two tests in the test suite: “one client” and “many clients”.
实验涉及的要点
- 把client.go中的Get/Put/Append三种RPC请求的函数补全、把server.go中的Get/Put/Append三种RPC处理函数补全即可。
Key/value server with dropped messages
Add code to Clerk to retry if doesn’t receive a reply, and to server.go to filter duplicates if the operation requires it. These notes include guidance on duplicate detection.
实验涉及的要点
-
You will have to think carefully about what state the server must maintain for handling duplicate
Get()
,Put()
, andAppend()
requests, if any at all. -
Your scheme for duplicate detection should free server memory quickly, for example by having each RPC imply that the client has seen the reply for its previous RPC. It’s OK to assume that a client will make only one call into a Clerk at a time.
-
线性一致性保证:每个操作都有唯一的(ClientID, OperationID)对;服务端记录每个操作的结果;重复请求返回相同结果
-
OperationID处理:在发送RPC前递增OperationID,确保即使RPC失败重试也不会重复执行
-
processedRecords结构:改为存储
map[int64]string
,记录每个操作的结果,这样可以准确返回之前执行的结果 -
返回值一致性:Put和Append都返回操作前的值,这是测试期望的行为
- 并发安全:所有操作都受mutex保护;操作记录确保不会重复执行 -
内存问题:processedRecords永久保存所有客户端的所有操作记录。对于长期运行的服务器,这将导致内存不断增长。