Skip to content
Planet PostgreSQL·· 9h agoFeatured

PostgreSQL 19.0 WAIT FOR LSN Load Testing and Tuning Finds Two Stall Bugs

Jobin Augustine: Stop Fighting Synchronous Replication: Meet WAIT FOR LSN – Part 3 – numbers, tuning and bugs

Brief · Based on the source excerpt

Jobin Augustine ran several hundred thousand WAIT FOR LSN operations on PostgreSQL 19.0, comparing the approach with synchronous replication and finding two rare stall bugs. One remains unfixed, so he recommends waiting for PostgreSQL 19.1 before production use.

Why It Matters

Applications that need to read back a write from a standby can wait for WAL to reach the specified LSN on demand instead of making every primary commit wait for the standby.

Technical Breakdown · Distilled from the original source

Two Places to Wait for Replication

  • The Rust program waitforlsn is a closed-loop load generator. In the synchronous replication baseline, –mode sync, a cycle normally ends after the primary commits. With –verify, it also fetches the LSN and reads the row back from the standby to check whether the write is visible without an explicit wait.
  • In –mode waitfor, the primary commits asynchronously and the standby executes WAIT FOR LSN. The comparison covers throughput, latency, and whether the standby can read back the write. The supplied excerpt does not include the results for those metrics.

Connection Pools and the Write Cycle

  • The program uses tokio and deadpool-postgres, with separate pools sized by –primary-pool and –standby-pool.
  • Each worker runs an autocommit INSERT … RETURNING id and then SELECT pg_current_wal_insert_lsn() on the same primary connection. It returns that connection before borrowing one from the standby pool, so the standby wait does not tie up the primary connection.

Stall Bugs and Production Timing

  • The PostgreSQL 19.0 load test surfaced two rare stall bugs. One remains unfixed, which is why the author recommends waiting for PostgreSQL 19.1 before production use. The excerpt mentions a workaround but does not give its steps.
Source: Planet PostgreSQL· postgr.es

PG Radar summarizes verified changes and impact. Read the original post for full technical details and code samples.

Read Official Source

Related PostgreSQL Reference