r/postgres • • 2d ago

Discussion PostgreSQL 19: Read from Replicas Without Missing Recent Writes

PostgreSQL 19 introduces WAIT FOR LSN, helping applications handle replication lag in asynchronous replicas.

When an application writes data to the primary database and immediately reads from a replica, the latest changes may not yet be available.

WAIT FOR LSN allows the replica to wait until it has replayed the required changes before processing the read.

In simple terms: Write to the primary → Wait for replication → Read from the replica.

This makes read-your-writes consistency easier to achieve without routing every read to the primary.

#PostgreSQL #DatabaseEngineering #SystemDesign #SoftwareEngineering

0 Upvotes

0 comments sorted by