Why is read repair not sufficient in making dynamo-style database linearizable?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Dynamo-style databases, based on the Dynamo paper by Amazon, are designed to be highly available and scalable, but they notably compromise on strong consistency to achieve these goals. Linearizability, also known as strong consistency, is a property of particular distributed systems which ensures that operations appear instantaneous and will be completed in the order they were received. To understand why read repair, a commonly implemented mechanism in Dynamo-style systems, is not sufficient to achieve linearizability, we first need to look into its workings and limitations.
What is Read Repair?
Read repair is a background mechanism used in distributed data systems to ensure eventual consistency. The basic idea behind read repair is simple: during a read operation, if different replicas return different values for the same data, the system detects this discrepancy and initiates a correction to make all replicas consistent. This happens often asynchronously; the read repair processes the discrepancies after the read operation returns a result to the client.
Limitations of Read Repair
- Asynchronous Nature:
- Read repair does not correct inconsistencies immediately as it works in the background. During this lag, different users might see different values, violating linearizability.
- Conflict Resolution:
- When discrepancies are detected, read repair resolves conflicts based on predefined policies like "last write wins" or based on timestamps. Such methods can result in lost updates, again violating linearizability where each operation’s effect should be instantaneous and observable.
- Dependence on Active Reading:
- Read repair is only triggered during read requests. If a data item is not frequently accessed, the inconsistencies among replicas might persist indefinitely, leading to stale reads which are incompatible with linearizability.
Why Linearizability Matters
Linearizability ensures that once an update operation completes, any subsequent read will reflect that update or a more recent one; essentially, the system behaves as if all operations are happening sequentially. For applications requiring strict data correctness and recency, such as financial transaction systems, linearizability is crucial.
Dynamo-Style Databases and Consistency
Dynamo-style databases prioritize availability and partition tolerance (AP of CAP theorem), which often leads them to employ eventual consistency models. These systems are designed to continue operating despite network partitions and to handle large volumes of data, sacrificing some aspects of consistency to prevent any single point of failure and to reduce latency in network communications.
To enhance this model, techniques like read repair are implemented, but alone, these are not enough for achieving linearizability due to their inherent reactive and not proactive consistency maintenance.
Why Read Repair is Not Sufficient for Linearizability
As outlined, the asynchronous and partial nature of read repair means it can’t provide the guarantees required for linearizability. Here’s a summarization in a table format:
| Aspect | Effect on Linearizability |
| Asynchronous nature | Causes lags in consistency; not instantaneous |
| Conflict resolution | Possible loss of updates; not all operations are visible |
| Dependence on reading | Inconsistencies persist without frequent access |
Conclusion
In conclusion, while read repair is beneficial for enhancing consistency in an eventual consistency model by correcting discrepancies during reads, it does not meet the requirements for linearizability. To achieve linearizability in a Dynamo-style system, more sophisticated mechanisms like synchronous replication and consensus algorithms (like Paxos or Raft) would be needed, which can significantly impact the system's availability and performance, moving away from the original design goals of Dynamo-style databases. These trade-offs must be carefully considered based on the application's specific requirements for consistency, availability, and partition tolerance.
Related reading
- Why isn't RDBMS Partition Tolerant in CAP Theorem and why is it Available?
- Why Kafka is not P in CAP theorem
- Why MongoDB is Consistent not available and Cassandra is Available not consistent?
- Why mysql INSERT ... ON DUPLICATE KEY UPDATE can break RBR replication on a master / master configuration
- Why Neo4J docker authentication doesn't work
- Why secondary indexes are less efficient in Cassandra?
- Why shouldn't I use mysql_ functions in PHP?
- Why split app server into Read and Write servers?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.