PostgreSQL 19 Released
PostgreSQL 19 is out. Simon Willison notes that the project normally ships a new major version in September, but this cycle slipped by about two months, which he attributes mainly to the volume of issues the team had to work through amid what he calls the ongoing wave of AI-reported vulnerabilities. He describes the release as worth the wait.
His pick of the features is a new command aimed at applications that split reads across primary and standby servers. PostgreSQL 19 introduces WAIT FOR LSN, which gives those setups read-your-writes consistency. A session connected to a standby can pause until that standby has replayed its write-ahead log up to a named log sequence number, and only then run its query.
The WAL is PostgreSQL's append-only record of every change made to the database; standbys replay it to stay in step with the primary. Each position in that stream has a log sequence number, or LSN, a monotonically increasing pointer. Read-your-writes consistency is the guarantee that a client immediately sees its own just-committed changes. It is trivial on a single primary but easy to break when reads go to a replica that may be a fraction of a second behind.
The workflow Willison sketches runs in two steps. On the primary, after an UPDATE (his example flips rows in a movie table from the genre 'Drama' to 'Dramatic'), the application calls pg_current_wal_insert_lsn(), which returns a value formatted like 0/0306EE20. The application stores that LSN somewhere it survives the request boundary; he suggests a signed cookie, which keeps the value tamper-evident without server-side state.
A later request that lands on a standby starts with WAIT FOR LSN '0/0306EE20' WITH (TIMEOUT '0.1s'); before running its SELECT. The timeout is optional. When supplied, a replica that fails to catch up inside the window raises an error rather than blocking indefinitely, which gives the application an explicit signal to retry, fall back to the primary, or ask the user to reload.
The pattern is not new. Willison traces it to Wikipedia, which built a hand-rolled equivalent on MySQL replication. MediaWiki's rationale, as he recalls it, is ordering: a few seconds of replication lag are tolerable as long as successive requests paint a coherent picture. The software saves the primary's binlog position in the session and, at the start of each request, waits for the replica to reach that position before serving reads. The modern MediaWiki code uses MySQL's WAIT_FOR_EXECUTED_GTID_SET() and falls back to SOURCE_POS_WAIT().
Putting the primitive into core removes the need for each application to build its own plumbing. In practice, the trade-offs are worth noting. A standby catching up under a 100 ms budget still costs up to 100 ms of added latency at the tail, and a primary that is itself overloaded produces LSNs that replicas cannot reach quickly. Waiting does not repair replication lag; it makes the lag visible to the request path. A very short timeout turns slow replicas into errors, and an absent one can let a request hang when a standby is stalled, so operators will want to pair the command with monitoring and a sensible fallback.
Why it matters: teams that scale reads across standbys have long had to tolerate stale results or write their own catch-up logic. A built-in standby-side wait gives developers a supported, portable way to read their own writes, and product teams can lean on read replicas for more screens without showing users their own changes vanishing. Expect connection pools and ORMs to need work to carry an LSN across requests; that is an inference, not something the release notes state.
Based on reporting from the original publisher. Visit the source for full context and later updates.
Publisher excerpt
PostgreSQL 19 Released Most years PostgreSQL ships a new release in September, but this year's release came two months later thanks mainly to the flurry of issues that the PostgreSQL team needed to address as part of the ongoing AI-reported vulnerability apocalypse. This release was definitely worth the wait. My favorite new feature is this one: For applications that send reads to standbys, PostgreSQL 19 adds "read-your-writes" consistency with the new WAIT FOR LSN command. A session on a standby can use WAIT FOR L