Master-slave replication is eventually consistent, because clients making reads of the same “key” at the same time to the primary or the replicas can get different values (if a write took place, and hasn’t been replicated yet).
Reading Your Own Writes
Fix:
- Client always reads from the leader when it’s a read of something that they can have written to.
- Client keeps track of the logical timestamp they wrote at, and sends the timestamp with the read request (logical timestamp as in sequence number; real timestamp would depend on trusting clocks). If replica hasn’t arrived to it, wait/redirect/fail.
Monotonic Reads
Strong consistency
> Monotonic Reads
> Eventual consistency
Fix? Each user (e.g. via userID
hash) does reads always to the same replica. Works unless replica goes offline 🤷♂️.
Consistent Prefix Reads
Fix?
Writes go to the same machine.