This set practises retry semantics, timestamp-based reconciliation, the quorum intersection lemma and the difference between read-after-write consistency and linearizability.
Problem 1
Problem 3.1 (Which requests are safe to retry).For each update on a state
, say whether it is idempotent, and justify in one line.
. . on a set . - Append item
to the end of a list . - Compare-and-set:
if , else , in the two cases and . - A client sends the non-idempotent request “debit 100” with request id 42 to a server that deduplicates by id (Proposition 3.5). Is the combined client-and-server protocol exactly-once? What must the server store, and where?
Solution
- Idempotent:
. - Not idempotent:
. - Idempotent: removing
from a set that no longer contains changes nothing. - Not idempotent: appending twice gives a list ending in
. - For
it is idempotent (Example 3.4): after the first application , so the second does nothing. For the function is the identity, which is trivially idempotent. - Yes, under the assumptions of Proposition 3.5. The server must store the set of processed ids together with their replies, in stable storage, and must apply the debit and record id 42 atomically; otherwise a crash between the two steps lets the retry debit again.
Problem 2
Problem 3.2 (Anti-entropy with tombstones).Two replicas hold records
with Lamport timestamps written as integers (ties do not occur). Replica A holds and . Replica B holds , and .
- Give the state of both replicas after one anti-entropy exchange in which each sends all its records to the other.
- Which keys can a client read, and with which values?
- Suppose that before the exchange, A had garbage-collected its tombstone for
(so A holds no record for ). What does the exchange produce now, and which client-visible anomaly is this? - A late retry of the write
for reaches A after the exchange of part 1. What happens?
Solution
- Per key, both keep the record with the larger timestamp (Proposition 3.8). For
: , so the tombstone . For : . For : only B has it, so . Both replicas end with the same three records. and . The key is deleted: its record is a tombstone, which a read reports as “not found”. - A has nothing for
(timestamp ), so it adopts B’s . The deleted key reappears with value 5: a resurrection. Tombstones may be dropped only after every replica has stored them. - A holds timestamp 4 for
and the retry has timestamp , so the rule “store only if the timestamp is larger” discards it. The delete stays in force; the retry is harmless because it carries its original timestamp.
Problem 3
Problem 3.3 (Quorums that miss each other).A store has
replicas A to E, all initially holding for key . It uses the client protocol of Module 3 with read repair.
- With
, , give an execution in which client P completes and then P’s own returns . Which property is violated? - Now take
. P’s write is acknowledged by C, D, E. Q then reads and the first three responses come from A, B, C. What does Q return, and which messages does read repair send? - In part 2, after the read repair, suppose D and E crash. Can a read still succeed? Can a write? Can both reads and writes survive the crash of D, E and C?
Solution
- P’s write reaches C, D, E (three acknowledgements, complete); A and B miss it. P’s read collects
responses from A and B, both , and returns . Since , the sets and are disjoint (Lemma 3.14, part 2). Read-after-write consistency (Definition 3.12) is violated. - Responses
from A and B and from C. Q returns , the largest timestamp, as guaranteed by Theorem 3.16. Read repair sends with the original timestamp to A and B (optionally also to D and E, which ignore it). - With D and E down, A, B, C are alive: 3 replicas, enough for
and , so both reads and writes succeed. With C, D, E down only 2 replicas are alive, fewer than 3: both reads and writes block. Majority quorums with tolerate unavailable replicas, not 3.
Problem 4
Problem 3.4 (Write quorums must also intersect).Lemma 3.14 is about a read quorum and a write quorum.
- Prove that if
, any two write quorums share a replica. - Give
, , with but , and two concurrent writes and that complete with disjoint write quorums. After both complete, what does a quorum read return, and is any replica guaranteed to hold the winning value? - Prove: with
, a quorum read always contains a replica of each completed write quorum, even when write quorums are disjoint. Why does part 2 therefore not break read-after-write?
Solution
- Let
be write quorums, . By inclusion-exclusion, , since and the sizes are integers. This is part 1 of the lemma with replaced by . - Take
, , ( , ). Write 1 with timestamp is acknowledged by , write 2 with by ; the other messages are delayed. A read of any 3 replicas meets both pairs and returns (largest timestamp). Only C and D hold , and no replica holds both writes, but nothing is lost from the reader’s point of view. - Each completed write quorum
has , and the read quorum has , so by Lemma 3.14 for each separately. The read sees every completed write and returns the one with the largest timestamp. Disjoint write quorums matter only for algorithms that need two writers to see each other (for example to compute the next timestamp, as in multi-writer ABD, or to elect one leader in Module 5); there , or a read phase before writing, is required.
Problem 5
Problem 3.5 (Is this execution linearizable).Three replicas,
, initial value with timestamp . Consider each execution and say whether it is allowed by (a) the plain quorum protocol of Module 3 and (b) linearizability. If an execution is allowed by (a) but not (b), name the step the ABD write-back phase changes.
- Client 1’s
completes. Then client 2’s get returns . - Client 1’s
is in progress. Client 2’s get returns and completes. Then client 3’s get returns . - Client 1’s
is in progress. Client 2’s get returns and completes. Then client 3’s get returns .
Solution
- (a) Not allowed: by Theorem 3.16 a read that starts after a completed write returns a timestamp
. (b) Not allowed either. - (a) Allowed: this is exactly the execution of Proposition 3.19. (b) Not allowed: client 2’s read precedes client 3’s in real time, so client 3 must return a value no older than
. ABD changes client 2’s get: it would write back to a quorum before returning, so client 3’s quorum would contain a replica holding . - (a) Allowed. (b) Allowed: both reads overlap the write, so the write’s instant can be placed after client 2’s read and before client 3’s read. Old-then-new is fine; only new-then-old violates linearizability.