midterm-cheatsheet
midterm-cheatsheet
when ai < bi and aj > bj , for some i and j Total order broadcast: single leader:
To broadcast sends to the leader; Leader
broadcasts it via FIFO broadcast;. Assumption:
leader does not crash
Total order broadcast: logical clocks:
When node broadcasts message: • Attach logical
clock, Send message via reliable broadcast
When node receives message: • Buffer message
in total order of timestamps • Suppose the earliest
message in the buffer has timestamp T • Deliver
when we have seen all messages with timestamp
<T Write-Ahead Logging
Assumption: nodes do not crash Undo-Logging:
Typically, a majority quorum is used: R = W =
(n+1)/2
Read repair • After get() returns, it issues a put()
with the latest value to all replicas that responded
with stale value or did not respond
Broadcast-based replication
Primary-backup replication • One primary, others
backup • Primary receives and executes •
Replicates updated (passive replication). Primary
waits for acks from all backups, then respond. Can
have n-1 fail
State machine replication (SMR) • Symmetric
replicas • Any replica receives and replicates
operations • All replicas execute operations (active
replication) • Fault tolerance based on consensus
algorithm, can have (n-1)/2 fail
Requirements
• Initial state: start in the same state • Determinism:
receiving the same input on the same state
produce the same output and resulting state •
Agreement: All replicas process inputs in the same
sequence
Benefit of Log: • keeps current state of each lock •
Log allows leader to order the operations• Log
allows storing both tentative, committed operations
• Replicas only deliver committed operations to
service • Log allows handling failures (leader
resend)
Log synchronization:
Checkpoint: Leader forces followers to have same log
Restrictions on Election: Replicas respond to
candidate if it is at least as up to date: • Candidate
has higher term in last log entry, or • Candidate
has same last term and same or longer log length
When Leader Commit: when it is stored durably
on a majority
Log Compaction
Snapshot + Discards log until snapshot log index
Snapshot RPC: : If leader compacts log while
follower offline, follower’s log may end before the
start leader’s log - Leader sends snapshot and log.
Client Interaction
Storage API • put(key, value, T), (value, T) = Problem: Suppose leader executes client
get(key), del(key, T) // time stamp for at most 1 operation, then crashes before sending response
Concurrent writes to client • Client retries same operation with
Method 1. Use total order timestamp, e.g., logical another leader • Operation is executed twice
timestamp • v2 replaces v1, if T2 > T1; • Last writer Ensuring exactly-once: • State machine performs
wins, can lose data duplicate detection • Keeps [client -> (request ID,
Method 2: Use partial order timestamp, e.g., vector response)] , state machine checks, and returns
timestamp • v2 replaces v1, if T2 > T1; preserve response (without re-executing).
both {v1, v2} if T1 ∥ T2; • Complicated scheme, Leader for Read Ops:• Leader sends heartbeat
vector timestamps can become large messages to followers • Waits for a majority to
Quorum-based replication know if it is still the current leader • Responds to
Choose: R + W > N read-only operation (no logging needed).