Behavior of PostgreSQL checkpoint_timeout when the previous checkpoint is still in progress
1
vote
1
answer
416
views
Dear PostgreSQL Community, I am trying to better understand PostgreSQL checkpoints internally, so I was thinking about this scenario.
Lets say we have checkpoint_timeout 15 mins and checkpoint_completion_target 0.85. Now if we face a case when one checkpoint for some reason takes lets say 20 minutes, for example
1:00PM - checkpoint1 started
1:15PM checkpoint timeout fired but checkpoint1 is still running (checkpoint2 here was scheduled)
1:20PM - checkpoint1 finished
My question is will the next checkpoint trigger right away at 1:20PM or will it be suspended and started at 1:30 as initially scheduled? I assume that two checkpoints cannot overlap. ( For now lets do not discuss other affecting parameters as max_wal_size, which can also trigger)
So does the checkpoint1 write ALL the dirty buffers to the disk, so we have very clean state at 1:20 so there is no need for the second checkpoint to start? As far as I understand the old checkpoint will not touch pages which were dirtied after its start, so in this case there is a need for the new checkpoint to just fire after the old one finishes.
Also, will checkpoint_timeout scheduling be switched any way? Like scheduled to run late for as much time as was the previous one delayed, or is it not alterable?
I will be more than happy if you can share more details regarding internal insights.
Asked by igelr
(2162 rep)
Feb 29, 2024, 01:29 PM
Last activity: Feb 29, 2024, 04:16 PM
Last activity: Feb 29, 2024, 04:16 PM