Re: Checkpoint replication slots later

From: Hüseyin Demir <huseyin(dot)d3r(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Ants Aasma <ants(at)cybertec(dot)at>
Subject: Re: Checkpoint replication slots later
Date: 2026-05-16 16:37:31
Message-ID: 177894945149.1016.16623043430281952415.pgcf@coridan.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Ant,

Good idea. Moving CheckPointReplicationSlots() to the end of CheckPointGuts() means we can see more fresher restart_lsn. It's especially valuable for spread checkpoints as you described.

While reading the code for this, I noticed that the ReplicationSlot.last_saved_restart_lsn is completely invisible to operators today.

pg_replication_slots.restart_lsn exposes slot->data.restart_lsn, the current in-memory value, but WAL removal for persistent slots is gated on last_saved_restart_lsn (the value last
durably written to disk at checkpoint), not restart_lsn. See ReplicationSlotsComputeRequiredLSN() at slot.c:1346–1352:

Your patch makes the it more current at cleanup time, which helps. But between checkpoints the gap can still be wide. Should we also expose last_saved_restart_lsn since it's already available and can be exposed. ? Otherwise, the current approach LGTM.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-05-16 16:45:16 Re: [PATCH] Fix overflow and underflow in regr_r2()
Previous Message Dean Rasheed 2026-05-16 16:31:52 Re: [PATCH] Fix overflow and underflow in regr_r2()