How Distributed Systems Avoid Race Conditions using Pessimistic Locking
Pessimistic locking is used in distributed systems to prevent race conditions by ensuring that only one process can access shared data at a time. This involves using a cluster-wide lock database to manage locks and employing leases to release locks if a node fails. Fence tokens further ensure that stale updates are prevented by rejecting writes from nodes with out-of-date tokens.