Receiving WAL is different from showing its rows
The initial experiment pauses replay, adds 5,000 primary rows, and resumes. Verify the actual pause state and eventual standby row count, instead of judging freshness from a single time interval.
write_lag, flush_lag, and replay_lag are elapsed acknowledgement times for recent WAL. They can retain earlier values or become NULL, and do not necessarily rise continuously while paused. Sent-minus-replay bytes and actual data reads provide complementary evidence. pg_stat_wal_receiver shows receiving activity even while application is delayed.
The second experiment creates lag3_demo before enabling recovery_min_apply_delay = '5s'. The setting delays commit replay relative to the primary timestamp. Other records may replay earlier; slow delivery may already have consumed the minimum delay. It is not a uniform five-second lag or automatic undo button.
Keep the immediate/after-delay shell block together: it should show 0 then 1 row. Reaching the table's eventual count proves this transaction became visible. Clock-dependent sampling is bounded evidence for this fixture, not a recovery guarantee for arbitrary DDL.
Did you know? A pause request is not always an achieved pause: pg_get_wal_replay_pause_state() distinguishes pause requested from paused. Recovery control functions.
Key concepts
pg_wal_replay_pause() / pg_wal_replay_resume()
Standby-side functions that stop and restart WAL replay on demand, without touching the streaming connection itself — WAL keeps arriving and getting flushed to disk the whole time, it simply stops being applied. This makes them a safe, reversible way to create replay lag deliberately for testing, or to freeze a standby's visible data at a known point without disconnecting it.
recovery_min_apply_delay
recovery_min_apply_delay delays transaction commit replay relative to the primary timestamp. It does not delay every WAL record uniformly, and does not guarantee a human reaction window. Inspect actual row visibility and available WAL before treating a delayed standby as part of a recovery plan.