IPC:SyncRep
This event occurs when a transaction has completed locally and is waiting for confirmation from a remote standby server before it can return "Success" to the client.
PostgreSQL "Synchronous Replication" is technically Asynchronous Replication + A Wait. The database does not "write successfully to both places at the exact same instant." Instead,
it writes locally, streams the data asynchronously to the standby, and then pauses the user session (generating this wait event) until the standby sends a "Thumbs Up" acknowledgment.
Why it is happening (Root Causes)
- The "Lie" of Sync Replication:
PostgreSQL does not slow down your INSERT or UPDATE statements while they are running.
The data transmission to the standby happens in the background (by WAL Senders).
The IPC:SyncRep wait only kicks in at the very end, during COMMIT.
- Network Latency (RTT):
Since the primary must send a message and receive a reply, the minimum duration of this wait is the Round Trip Time (RTT) between servers.
If your servers are 50ms apart, every commit will wait at least 50ms.
-
Standby Performance Issues:
If the Standby server is overloaded or has slow disks, it cannot write the WAL data fast enough to send the acknowledgment back.
The Primary waits in IPC:SyncRep while the Standby struggles to catch up.
Additional References