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

From: "Vitaly Davydov" <v(dot)davydov(at)postgrespro(dot)ru>
To: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly
Date: 2025-03-03 15:12:12
Message-ID: 1538a2-67c5c700-7-77ec5a80@179382871
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Hackers,

Let me please introduce a new version of the patch.

Patch description:

The slot data is flushed to the disk at the beginning of checkpoint. If
an existing slot is advanced in the middle of checkpoint execution, its
advanced restart LSN is taken to calculate the oldest LSN for WAL
segments removal at the end of checkpoint. If the node is restarted just
after the checkpoint, the slots data will be read from the disk at
recovery with the oldest restart LSN which can refer to removed WAL
segments.

The patch introduces a new in-memory state for slots -
flushed_restart_lsn which is used to calculate the oldest LSN for WAL
segments removal. This state is updated every time with the current
restart_lsn at the moment, when the slot is saving to disk.

With best regards,
Vitaly

Attachment Content-Type Size
0001-Keep-WAL-segments-by-slot-s-flushed-restart-LSN.patch text/x-patch 5.9 KB
0002-Fix-src-recovery-t-001_stream_rep.pl.patch text/x-patch 971 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2025-03-03 15:20:11 Re: Change log level for notifying hot standby is waiting non-overflowed snapshot
Previous Message David E. Wheeler 2025-03-03 15:10:44 Re: RFC: Additional Directory for Extensions