Exactly. “Read-your-writes” consistency sounds like common sense, but once you introduce replicas, it gets tricky.
On a single node, life is simple — the transaction log is sequential, so once a write is acknowledged, any immediate read will see it. But in a primary/replica setup, replication lag can break that illusion. If your read gets routed to a replica that hasn’t applied the latest write yet, you’ll see stale data (or even a missing record).
That’s why many systems enforce:
Writes critical reads → primary
Other reads → replicas
Async and semi-sync replication trade off consistency for performance/availability, so you can’t guarantee read-your-writes if your reads hit replicas. Synchronous replication does guarantee it, but at the cost of higher latency, since the primary waits for acknowledgments from replicas.
---
A Real-world example:
In MySQL, the default is asynchronous replication. If you write a row to the primary and then immediately query a replica, you might not see it because the replication thread hasn’t applied the change yet. Semi-sync MySQL helps by requiring at least one replica to confirm receipt, but that still doesn’t guarantee your query hits that replica.
In Postgres, tools like Patroni or pgpool-II let you route queries smartly — for example, always directing a client’s reads to the primary right after a write to ensure read-your-writes, while still distributing other reads to replicas.
So the rule of thumb: if you need strong consistency (like after creating a record and immediately fetching it), stick to the primary. If you just need scale and can tolerate some staleness, replicas are fine.