Menu

Read Your Own Writes on Async Replicas: PostgreSQL 19's WAIT FOR LSN
📰

Read Your Own Writes on Async Replicas: PostgreSQL 19's WAIT FOR LSN

DEV Community: sql·san·9 days ago
#zBD8bygP
#devtosql#devto#dev#replica#wait
Long article (809 words) — no AI summary yet.
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.