Checkpoint replication slots later

From: Ants Aasma <ants(dot)aasma(at)cybertec(dot)at>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Checkpoint replication slots later
Date: 2026-05-07 10:28:07
Message-ID: CANwKhkPCBcTQ_pk06MD5W5YYNnuYHp8dLNuOUz8-5pMBMPY1Bw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Right now replication slots are synced close to the beginning of
CheckpointGuts(). Importantly, before CheckPointBuffers() which for spread
checkpoints might take most of checkpoint_timeout to complete. This is a
problem because this function calculates how much WAL to keep around in
ReplicationSlotsComputeRequiredLSN(). By the time RemoveOldXlogFiles() gets
called this information might be quite stale and we hold onto many WAL
files unnecessarily until the next checkpoint cycle.

As far as I could tell there is no reason for this to happen early, so in
the attached patched I just moved it down closer to the end.

Regards,
Ants Aasma

Attachment Content-Type Size
0001-Checkpoint-replication-slots-late-in-the-cycle.patch text/x-patch 1.6 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2026-05-07 10:43:40 Re: Fix bug with accessing to temporary tables of other sessions
Previous Message Dilip Kumar 2026-05-07 10:13:55 Re: Include schema-qualified names in publication error messages.