PostgreSQL 19's WAIT FOR LSN lets a read on an asynchronous replica wait until that replica has replayed your write. You get read-your-writes consistency without sending every read to the primary.
The problem: the write succeeded, the read missed it
Read-write splitting is a common way to scale: writes go to the primary, reads spread across asynchronous replicas. It breaks a simple expectation:
A user renames their profile from Alex to Sam.
The primary commits. Success.
The user refreshes, and the read lands on a replica.
The replica hasn't replayed the change yet, so it returns Alex.
Nothing failed. Replication lag let the user miss their own write. The guarantee that this never happens is called read-your-writes (RYW) consistency .
Why not just read from the primary?
You can, and it's a valid fix. Route reads that must see the latest write to the primary.…