Cookbook recipe

Synchronous standby not confirming — commits stalling

Applies to PostgreSQL 13–17 Last reviewed Nov 2025 Grounded in source
Estimated investigation4 min

Scenario

Primary writes are stalling because a synchronous standby is not acknowledging WAL — every commit is waiting for the standby to catch up. Diagnose it -- Check sync state of all standbys: SELECT application_name, state, sync_state,…

Investigation Path

Primary writes are stalling because a synchronous standby is not acknowledging WAL — every commit is waiting for the standby to catch up.

Diagnose it

-- Check sync state of all standbys:
SELECT application_name,
       state,
       sync_state,
       sent_lsn,
       write_lsn,
       flush_lsn,
       replay_lsn,
       write_lag,
       flush_lag,
       reply_time
FROM pg_stat_replication
ORDER BY sync_state DESC, flush_lag DESC NULLS LAST;

A healthy synchronous standby has sync_state = 'sync' and
state = 'streaming'. If it shows state = 'startup' or
disconnects from the view entirely, commits on the primary will hang until
wal_sender_timeout fires or another sync standby becomes available.

Why it happens

With synchronous_commit = on (or remote_apply), the primary
waits for the standby to acknowledge each WAL write before returning success to the client.
If the standby is slow, has crashed, or has lost its connection, the primary commit path
blocks — causing latency spikes and potentially timeouts visible to applications.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • How to fix it
  • Prevent it next time
  • Related & next steps
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes