Try PostgreSQL 19 WAIT FOR LSN from a Desktop GUI (Standby Read-Your-Writes)
PostgreSQL 19 adds WAIT FOR LSN so a standby can wait until it has replayed your write. Try the official pattern in HiDataLinker's SQL editor: capture the LSN on the primary, wait on the standby, then run the SELECT.
PostgreSQL 19.0, announced on 19 November 2026, adds WAIT FOR LSN so a session on a standby can wait until write-ahead log has been replayed to a given log sequence number, then read data the application just wrote on the primary. This guide shows that official pattern in HiDataLinker, a free MIT PostgreSQL desktop GUI (MySQL in the same client): two local-first connection profiles, SQL in the editor, and no seat, tab, or connection freemium wall. The command exists only on PostgreSQL 19+. Confirm each server with SELECT version();.
Why a commit on the primary can miss a read on the standby
With asynchronous streaming replication, a COMMIT on the primary can succeed before the standby has replayed that WAL. The replica is healthy; it is simply a little behind. A follow-up SELECT sent to the standby can then return the old row, or no row at all.
Older workarounds were coarse: always read the primary after a write, poll pg_last_wal_replay_lsn() until it catches up, or set synchronous_commit = remote_apply so every commit waits for a replica. PostgreSQL 19 is narrower. The official WAIT command delays only the sessions that ask, and only until a specific LSN is reached.
What WAIT FOR LSN does (and what it is not)
The documented syntax is:
WAIT FOR LSN 'lsn' [ WITH ( MODE 'mode', TIMEOUT 'timeout', NO_THROW ) ];
The LSN is required. MODE, TIMEOUT, and NO_THROW are optional.
standby_replay(the default). After asuccessstatus,pg_last_wal_replay_lsn()is at or beyond the target, so a followingSELECTcan see the write. This is the read-your-writes mode.standby_flushandstandby_write. These wait until WAL is flushed or written on the standby. They do not by themselves make the new row visible. Use them when you care about durability of received WAL, not when the next statement is aSELECTthat must see the change.primary_flush. Waits for flush on a primary only. It is a different tool; the walkthrough below is the standby pattern.
The command returns success, timeout, or not in recovery. With NO_THROW, you must read that status before assuming the LSN was reached. Without it, a timeout or a promotion raises an error. Official docs are explicit: the LSN of the last modification should be stored on the client or pooler side. The database does not carry it for you.
This is not synchronous replication, not a lag SLA, and not a guarantee across a timeline change. WAIT compares numeric LSNs only.
Try it in a desktop SQL editor (two connections)
HiDataLinker's hook here is the SQL editor, not a wizard. The docs describe pasting a URL or filling the form, starting a SQL editor, running with ⌘/Ctrl+Enter, and opening up to five sessions. Save two connection profiles — one to the primary, one to the standby — and keep both sessions open. There is no built-in primary/standby pair, topology picker, or replica lag view. v1.3.0 can switch database on the same connection, but that only changes the current database on the same server. It does not move you from primary to standby.
- Install from hidatalinker.onesolo.app. Open New Connection twice: the primary host and the standby host. Prefer pasting a
postgresql://URL when you have one (paste a DATABASE_URL). Test, then connect. Profiles stay on your machine. - On each session, run
SELECT version();andSELECT pg_is_in_recovery();. Expect PostgreSQL 19+ on both,falseon the primary, andtrueon the standby. (pg_is_in_recovery()is ordinary PostgreSQL, not a special HiDataLinker control.) - On the primary, after the write has committed, capture an LSN at or after the end of that transaction's
COMMITrecord. The official autocommit example usespg_current_wal_insert_lsn()becausesynchronous_commitmay beoff:
UPDATE movie SET genre = 'Dramatic' WHERE genre = 'Drama';
SELECT pg_current_wal_insert_lsn();
-- example result: 0/0306EE20
Do not take the LSN from inside the still-open write transaction, including a RETURNING LSN in the same uncommitted statement.
- On the standby, run
WAITas a top-level command, before any statement that takes a snapshot or holds a lock, then the read:
WAIT FOR LSN '0/0306EE20';
SELECT * FROM movie WHERE genre = 'Drama';
The default mode is standby_replay. In an interactive editor, prefer a bounded wait so a lagging replica does not hang the session:
WAIT FOR LSN '0/0306EE20' WITH (MODE 'standby_replay', TIMEOUT '2s', NO_THROW);
Proceed with the SELECT on this standby only when the status is success. On timeout, retry, wait longer, or run the read on the primary. On not in recovery, the server may not be a standby, or it may have been promoted — re-check which server you are on. Do not treat that status as success.
WAIT cannot run inside a function, procedure, or DO block, and it cannot run while the session holds a snapshot. Standby modes are rejected if the session already holds a lock and the target LSN is not yet reached — deadlock detection will not see that cycle. The natural order is wait first, then query.
HiDataLinker runs this SQL in the editor the same way it runs other PostgreSQL statements. It does not provide a replication dashboard, lag monitor, LSN picker, or automatic read-your-writes routing. For other PostgreSQL 19 SQL in the same editor — REPACK, INSERT ... ON CONFLICT DO SELECT, COPY TO FORMAT json, and visual EXPLAIN ANALYZE / BUFFERS — see Try PostgreSQL 19 SQL from a Desktop GUI.
Common mistakes (and the fix)
- Running
WAIT FOR LSNon the primary with a standby mode. You getnot in recovery, or an error withoutNO_THROW. Use the standby session forstandby_replay. - Using
standby_flushorstandby_writeand expecting the new row to appear. Those modes are about WAL durability or write, not replay. - Capturing the LSN before the write commits.
- Putting
WAITafter aSELECT, or any locking statement, in the same transaction. - Omitting
TIMEOUTin an interactive editor and waiting indefinitely. - Treating numeric
successas enough after a promotion or timeline change. Official docs:WAIThas no notion of timeline; applications that care must validate topology themselves. - Expecting HiDataLinker to pick the LSN, route the next query, or show replica lag. It will not.
What this means for an application
In production, the same SQL is usually issued by the application or a connection pooler that stores the last modification LSN. Simon Willison's 19 November 2026 note walks through that pattern and compares it to MediaWiki's MySQL approach with WAIT_FOR_EXECUTED_GTID_SET(). He mentions storing the LSN in a signed cookie so a later request can wait on a replica before reading. This article is a way to see the command work in a desktop editor, not a claim that HiDataLinker implements session stickiness or injects WAIT for you.
Why a light dual-engine client helps here
Local-first profiles, URL paste, and a SQL editor you can leave open on two sessions are enough to rehearse the official walkthrough. There is no seat, tab, or connection freemium wall in the MIT core. Dump / same-engine migrate is there if you want a backup of a lab cluster, including PostgreSQL 18+ virtual generated columns. WAIT FOR LSN itself is a PostgreSQL 19 command; MySQL in the same client does not change that.
v1 markets MySQL and PostgreSQL only. The workbench is a native Tauri desktop app, not a heavy Java or Electron shell, and not a replication console.
Source: github.com/henrybit/HiDataLinker · Overview: /db-client
Soft next step
Need a desktop SQL editor that can open two PostgreSQL 19 sessions and run the official WAIT FOR LSN pattern, without a freemium wall and without a replication dashboard the product does not have?