Safety and Liveness Properties
What you'll learn: You'll understand the two fundamental guarantees that every consensus algorithm must satisfy: safety (nothing bad happens) and liveness (something good eventually happens).
The Two Core Guarantees
When designing distributed consensus systems, we need to satisfy two distinct types of properties that seem simple but are surprisingly difficult to achieve simultaneously:
Safety means that nothing bad ever happens. In consensus terms, this usually means:
- All nodes agree on the same value (agreement)
- The agreed value was actually proposed by some node (validity)
- Once decided, the decision never changes (irrevocability)
Safety violations are permanent and catastrophic. If two nodes decide on different values, you can't "undo" that inconsistency.
Liveness means that something good eventually happens. For consensus:
- The system eventually reaches a decision (termination)
- Progress is made, even if slowly
Liveness violations mean the system is stuck or deadlocked, but at least it hasn't corrupted data.
Why the Distinction Matters
Think of a traffic light: safety means "cars from perpendicular directions never both have green lights" (no crashes), while liveness means "eventually every direction gets a green light" (traffic flows).
You can trivially achieve safety by never making a decision—but that violates liveness. You can achieve liveness by making quick decisions without coordination—but that violates safety.
The genius of algorithms like Paxos and Raft is achieving both properties simultaneously, even under network partitions and failures. However, as you've learned from CAP theorem, under partitions you often must choose: sacrifice liveness to preserve safety (CP systems), or sacrifice strong safety guarantees for availability (AP systems).
Key Takeaway: Safety properties ensure correctness (no wrong decisions), while liveness properties ensure progress (decisions eventually happen)—consensus algorithms must carefully balance both, though distributed systems may prioritize one over the other during failures.