Replicas drift apart
Because writes can succeed at a subset of replicas, copies of a row can become inconsistent. Cassandra uses anti entropy mechanisms to reconcile them, and read repair is one of them.
Read repair on the read path
When a read needs more than one replica, the coordinator compares the responses by timestamp.
- The replica with the newest timestamp wins, since Cassandra uses last write wins.
- The coordinator pushes the freshest value back to stale replicas, repairing them.
Blocking versus background
- A blocking read repair happens before the client gets its answer when consistency requires agreement, so the returned value is correct.
- Older versions also did probabilistic background repair on extra replicas not needed for the query.
Limits and full repair
Read repair only fixes data that is actually read. Rarely read rows can stay inconsistent, so operators run periodic full repair with the repair tool and rely on hinted handoff for short outages.
Diagram
Key idea
Read repair reconciles replicas during reads using last write wins, but only for rows that are read, so periodic full repair is still needed.