Monograph 01 / 13PostgreSQL 19 read-your-writes consistency

How PostgreSQL 19 Keeps New Orders Visible on Read Replicas

A shopper places an order, opens the confirmation page and sees an empty order history. PostgreSQL 19 gives that page a way to wait for the specific write it needs.

Radiaix Engineering & Product EditorialCustom Software, AI Agents, Web Platforms & QA Architecture
Published 3 min read
PostgreSQL 19 diagram showing a primary database sending changes to a read replica, with a check marking the replay point.
Section 01

Why a confirmed order can disappear on refresh

Imagine a shopper who has just placed order 4821. Checkout returns an order number. The shopper follows the link to their order history, where yesterday’s purchase is still at the top. Refreshing a moment later reveals the new order. Both pages can be working exactly as their developers intended.

Checkout wrote the order to the primary database. The history page read from an asynchronous replica that was still applying earlier changes. PostgreSQL 19, released on November 19, 2026, adds WAIT FOR LSN. It lets the history page ask a specific standby to catch up to the checkout transaction before looking up the order.

Section 02

Carry the commit position from checkout to the read

PostgreSQL records changes in its write-ahead log (WAL). A log sequence number (LSN) marks a position in that log. For order 4821, the application needs a position at or beyond the order’s commit record. Sampling it while the checkout transaction is still open can point to a moment before the order became visible.

After the commit succeeds, read pg_current_wal_insert_lsn() on the primary. Keep the result with the shopper’s server-side session for the next request. Other transactions may have advanced the log between the commit and the sample. That can add a little waiting, but the target still covers the order.

On the history request, reserve one connection to a standby. Run WAIT FOR LSN with that target before the first query on the connection. The default standby_replay mode waits for the replica to apply the changes. On success, fetch the order on that same connection. Handing the query back to a pool that can pick a different replica would lose the guarantee.

Section 03

Give checkout a useful answer when replay is late

Set an explicit timeout. For example, if the confirmation page can spend 80 milliseconds waiting for replay, use that as its initial budget and measure the result. PostgreSQL waits indefinitely by default. With NO_THROW, the application can inspect the returned status and handle a timeout as an ordinary routing decision.

If the wait expires, fetch order 4821 by ID from the primary while the request still has time. If that lookup is temporarily unavailable, keep the confirmation number on screen and offer to refresh the details. Repeating the checkout write would turn a delayed read into a possible duplicate order.

Treat failover separately. An LSN is a numeric position and can occur on different database timelines. If the standby is promoted or the topology changes mid-request, recheck the order against the current authoritative database before reporting its status.

Section 04

Test the screen the shopper actually sees

Use a disposable primary and standby in staging. Give each test order a unique reference so yesterday’s data or a cached response cannot make the test pass. Exercise the same redirect, connection pool and cache policy that the browser encounters after checkout.

  • With replay caught up, submit an order and follow the confirmation link. The first response should contain that order’s reference and line items.
  • Pause replay before checkout and hold it past the wait budget. Verify that the page follows the fallback path, still shows the reference and creates exactly one order.
  • Resume replay and repeat with a fresh order. Record time spent waiting and the share of requests routed back to the primary. Those two measurements tell you what the freshness guarantee costs on this endpoint.
Executive Summary

Key Engineering Takeaways

TAKEAWAY // 01Capture the log position after checkout commits so it includes the new order.
TAKEAWAY // 02Wait for replay and fetch the order on the same standby connection.
TAKEAWAY // 03Put a limit on the wait and give the shopper a confirmation they can use even when the replica is late.
Common Questions

Frequently Asked Questions

Which reads need this guarantee?

Use it where someone expects to see the result of their own action, such as opening an order just placed or reviewing an address just edited. A weekly sales chart can usually tolerate an older view. Reading directly from the primary is also a simple option for low-volume confirmation pages.

What if the confirmation page uses a cache?

A cache hit can bypass the database entirely. For the first confirmation read, bypass any cached order list or serve a cached result only if you know it includes the new order. Otherwise the shopper can still see an old response after the replica has caught up.

Continue Exploring Radiaix Monographs
All 13 Articles
MONOGRAPH // 01Software Engineering
Radiaix engineer architecting custom workflow software and real-time telemetry state machines
Custom Operational Software Development9 min read

Designing Custom Operational Software Around Real-World Workflows

Dashboards fail when they ignore exceptions and handoffs. See how Radiaix models state transitions, role permissions, and real-time telemetry for mission-critical software.

Radiaix Proof: Radiaix built a real-time fleet tracking and dispatch platform combining low-latency map telemetry, automated alert rules, and role-based exception workflows.
Next Monograph · Game Development

Why Rockstar Spent Months on How Lucia Opens a Door in GTA 6

Turn Architecture Into Production

Ready to solve this bottleneck with Radiaix?

Partner with Radiaix to scope, build, and launch your next system.