Re: Fix safe_wal_size for slots without restart_lsn - Mailing list pgsql-hackers

From Xuneng Zhou
Subject Re: Fix safe_wal_size for slots without restart_lsn
Date
Msg-id CABPTF7XaduJtPVMD0aNaP_ufS2E6+C62Gp-iJR3dNqDQk-byuQ@mail.gmail.com
Whole thread
In response to Fix safe_wal_size for slots without restart_lsn  (Xuneng Zhou <xunengzhou@gmail.com>)
Responses Re: Fix safe_wal_size for slots without restart_lsn
List pgsql-hackers
On Wed, May 27, 2026 at 6:55 PM Xuneng Zhou <xunengzhou@gmail.com> wrote:
>
> Hi,
>
> Currently, pg_replication_slots can report a non-null safe_wal_size
> for a replication slot that has never reserved WAL, if
> max_slot_wal_keep_size is finite.
>
> Such a slot has restart_lsn = NULL and wal_status = NULL. safe_wal_size is
> derived from restart_lsn, so it's not meaningful in this state. The
> current code handles WALAVAIL_REMOVED but not WALAVAIL_INVALID_LSN
> before computing safe_wal_size, leading arithmetic on InvalidXLogRecPtr.
>
> Fix this by returning NULL for safe_wal_size when WAL availability is
> WALAVAIL_INVALID_LSN.
>

Fixed the indentation issue in v1 and updated the comment and doc. Not
sure this small issue warrants an additional test, still added one in
case someone wants it.


--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.

Attachment

pgsql-hackers by date:

Previous
From: Zsolt Parragi
Date:
Subject: Re: [Patch] Add WHERE clause support to REFRESH MATERIALIZED VIEW
Next
From: SATYANARAYANA NARLAPURAM
Date:
Subject: Re: [PATCH] Release replication slot on error in SQL-callable slot functions