Post

postgres 19 has WAIT FOR LSN, which means you can finally drop the "sleep and hope" workarounds for reading your own writes from replicas. I did all the digging around. Sample Go implementation, and the Rails workaround (Active Record thinks WAIT FOR is a write 🙃) boringsql.com/posts/read-y...

boringsql.comRead your own writes, off the primaryWAIT FOR in PostgreSQL 19 lets a reader block until the replica has replayed a specific LSN. Measured against sticky routing, sleeps, and synchronous commit, on a replica that misses the write 99% of ...

1 repost2 likes

For impatient here's TL;DR: even with replica on the same machine, loopback, naive reads miss 99.2% of the time. not sometimes. not under load. always.