PostgreSQL 19 ships WAIT FOR LSN for read-your-writes on standbys
Simon Willison's link blog post of 19 November 2026 notes the release of PostgreSQL 19. He writes that PostgreSQL usually ships a new release in September, but this year's came two months later, thanks mainly to the flurry of issues the PostgreSQL team had to address as part of what he calls the ongoing AI-reported vulnerability apocalypse. That explanation is his own. He adds that the release was definitely worth the wait.
His favorite new feature is read-your-writes consistency for applications that send reads to standbys, delivered through a new WAIT FOR LSN command. A session on a standby can use it to wait until the standby has replayed the write-ahead log (WAL) up to a specific log sequence number (LSN) before running a query, so the application can read data it just wrote on the primary.
Willison shows how it works in practice. On the primary, the application runs a write, for example UPDATE movie SET genre = 'Dramatic' WHERE genre = 'Drama';, and then calls SELECT pg_current_wal_insert_lsn();. That returns a value like 0/0306EE20. The application stores it somewhere; he suggests a signed cookie would work. On a subsequent request, the application runs WAIT FOR LSN '0/0306EE20' WITH (TIMEOUT '0.1s'); on the standby and then SELECT * FROM movie WHERE genre = 'Drama';. The timeout is optional. If one is given, an error is raised when the replica does not catch up within the specified time.
Willison says he first met this pattern in Wikipedia, which has a hand-rolled version built against MySQL replication. The MediaWiki documentation he quotes explains the aim: users should see events on the wiki in chronological order. A few seconds of lag is tolerable as long as the user sees a consistent picture across requests. MediaWiki does this by saving the primary binlog position in the session and, at the start of each request, waiting for the replica to catch up to that position before reading from it. He links the relevant MediaWiki code, which today uses MySQL's WAIT_FOR_EXECUTED_GTID_SET() function and falls back to SOURCE_POS_WAIT().
Key facts
- PostgreSQL 19 is out; Simon Willison says it came about two months later than the usual September release.
- He attributes the delay mainly to the flurry of issues the PostgreSQL team had to address amid what he calls the ongoing AI-reported vulnerability apocalypse.
- The new WAIT FOR LSN command lets a standby wait until it has replayed the WAL up to a given LSN before a query runs, giving read-your-writes consistency.
- The flow: read pg_current_wal_insert_lsn() on the primary after a write, keep it (a signed cookie would work), then run WAIT FOR LSN with an optional timeout on the standby.
- Wikipedia's MediaWiki uses a hand-rolled equivalent against MySQL replication, built on WAIT_FOR_EXECUTED_GTID_SET() with a fallback to SOURCE_POS_WAIT().
Why it matters
Reads sent to standbys can return stale data because a replica may lag behind the primary. A user who has just saved something can then fail to see it. PostgreSQL 19 puts a fix for this into the database itself: WAIT FOR LSN holds a query on a standby until the standby has replayed the WAL up to the position of the user's own write. Willison points out that Wikipedia had to hand-roll the same idea against MySQL replication, which shows the pattern is a long-standing need. Before this, applications had to build it themselves.
Who it affects
Mainly teams that run PostgreSQL with one or more standbys and send read traffic to them, and who want users to see their own writes straight away. It is also relevant to anyone who tracks PostgreSQL's release schedule, since this release landed about two months after the usual September slot, per Willison.
How to use it
Following Willison's example: after a write on the primary, run SELECT pg_current_wal_insert_lsn(); to get an LSN such as 0/0306EE20. Store it with the user's session; he suggests a signed cookie would work. On the next request, before reading from a standby, run WAIT FOR LSN '0/0306EE20' WITH (TIMEOUT '0.1s'); and then run the query. The timeout is optional. With one set, the command raises an error if the replica does not catch up in time, so the application needs a plan for that case. The LSN and the 0.1s timeout in his snippet are illustrations, not measurements.
How solid is it
This is a short link-blog post by Simon Willison, not release notes. The description of WAIT FOR LSN is text he quotes without naming where it comes from, and the snippet is his own example. The explanation for the delay, the AI-reported vulnerabilities, is his framing, not an official statement from the PostgreSQL project. The exact release date of PostgreSQL 19 is not given. Apart from WAIT FOR LSN, no other PostgreSQL 19 features are listed.
Risks and caveats
No benchmarks or performance figures for WAIT FOR LSN are given, so its cost under real replication lag is unknown from this post. With a timeout set, a lagging replica produces an error rather than a result, which the application must handle. The specific vulnerabilities behind the delay, their number, or who reported them are not named, so the delay story rests on Willison's reading alone.
“This release was definitely worth the wait.”
— Simon Willison, simonwillison.net