Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly

Alexander Korotkov <aekorotkov@gmail.com>

From: Alexander Korotkov <aekorotkov@gmail.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Vitaly Davydov <v.davydov@postgrespro.ru>, pgsql-hackers <pgsql-hackers@postgresql.org>, Masahiko Sawada <sawada.mshk@gmail.com>, tomas@vondra.me
Date: 2025-05-29T11:59:39Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Update comment for ReplicationSlot.last_saved_restart_lsn

  2. Fix CheckPointReplicationSlots() with max_replication_slots == 0

  3. Remove excess assert from InvalidatePossiblyObsoleteSlot()

  4. Improve runtime and output of tests for replication slots checkpointing.

  5. Keep WAL segments by slot's last saved restart LSN

  6. Fix an assert in CheckPointReplicationSlots().

On Tue, May 27, 2025 at 2:26 PM Amit Kapila <amit.kapila16@gmail.com> wrote:
> Yeah, we should be able to change ABI during beta, but I can't comment
> on the idea of effective_restart_lsn without seeing the patch or a
> detailed explanation of this idea.

Could you, please, check the patch [1].  It implements this idea
except it names new field restart_lsn_flushed instead of
effective_restart_lsn.

> Now, you see my point related to restart_lsn computation for logical
> slots, it is better to also do some analysis of the problem related to
> xmin I have highlighted in one of my previous emails [1]. I see your
> response to it, but I feel someone needs to give it a try by writing a
> test and see the behavior. I am saying because logical slots took
> precaution of flushing to disk before updating shared values of xmin
> for a reason, whereas similar precautions are not taken for physical
> slots, so there could be a problem with that computation as well.

I see LogicalConfirmReceivedLocation() performs correctly while
updating effective_catalog_xmin only after syncing the slot to the
disk.  I don't see how effective_xmin gets updates with the logical
replication progress though.  Could you get me some clue on this,
please?

Links.
1. https://www.postgresql.org/message-id/1538a2-67c5c700-7-77ec5a80%40179382871

------
Regards,
Alexander Korotkov
Supabase