Safety vs Liveness Properties
What you'll learn: The two fundamental correctness criteria every distributed consensus algorithm must satisfy.
When designing consensus algorithms, we need to prove they work correctly. Computer scientists break "correctness" into two complementary properties: safety and liveness.
Safety: Nothing Bad Happens
Safety means the system never enters an incorrect state. Once violated, it's violated forever—there's no recovery.
For consensus specifically:
- All nodes that decide must decide the same value
- No two nodes can commit different values
- The agreed value must have been proposed by someone
Analogy: Safety is like a "no false positives" rule. A safety violation is like a bank accidentally crediting the same deposit to two different accounts—once it happens, you can't undo the damage.
Liveness: Something Good Eventually Happens
Liveness means the system eventually makes progress. A perfectly safe system that never decides anything is useless.
For consensus:
- The algorithm must eventually reach a decision
- Requests must eventually get responses
- The system can't deadlock forever
Analogy: Liveness is like guaranteeing your package will eventually arrive. It might be delayed, but it won't stay in limbo forever.
The Fundamental Tension
Here's the challenge: these properties often conflict. Recall the FLP Impossibility Result—in an asynchronous network with even one crash failure, you cannot guarantee both safety and liveness simultaneously.
Real consensus algorithms like Paxos and Raft make a deliberate choice: favor safety over liveness. They guarantee correctness (safety) always, but might get stuck (violate liveness) during network partitions or failures. Once the partition heals, liveness resumes.
Key Takeaway: Safety properties ensure correctness (no wrong decisions), while liveness properties ensure progress (decisions eventually happen). Consensus algorithms prioritize safety—better to wait than to be wrong.