PostgreSQL – Does CHECKPOINT Process Affect Streaming Replication?

failoverpatronipostgresql

Does Postgres CHECKPOINT process affect async streaming replication in any way?

If checkpoint_timeout is increased from 5min (default) to 30min, then CHECKPOINT processes will be triggered less often (some other parameters needs to be adjusted as well). If primary node crashes, then it will probably take more time to recover. But I have Patroni configured and it will failover primary to the other node in case of crash.

My question is – will failover last longer if checkpoints on old primary node are triggered less often?

I think it should not affect failover process, because WAL records are already replicated and applied on secondary node, but I want to confirm that.

Best Answer

You are correct, the speed of promoting a standby is not affected by checkpoint timing on the primary. WAL is streamed to the standby as soon as possible, and writing WAL is mostly independent of checkpoints (the only connections are that a checkpoint writes a WAL record and removes obsolete WAL segments).

What can delay promotion is if there is a conflict that prevents replaying WAL on the standby, but that's something entirely different.