Re: Don't keep closed WAL segment in page cache after replay

From: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
To: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Don't keep closed WAL segment in page cache after replay
Date: 2026-02-18 09:51:59
Message-ID: CAO6_Xqric0=7TVC-dLySU6_mtG3ie8kJY=87EjDeYjqGc3uNNA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for the review!

On Tue, Feb 17, 2026 at 9:38 AM Kirill Reshke <reshkekirill(at)gmail(dot)com> wrote:
> This does not immediately strike me as good reasoning. We have, for
> example, pg_stat_get_wal_senders (or WalSndInitStopping from
> walsenders.h) function which accesses exactly WalSndCtl->walsnds.
> Why don't we simply have another utility function that will return the
> number of active walsenders?

That's true it is an option. I've switched to this approach and
created a WalSndRunning. We only need to know if there's at least one
wal sender running, no need to have a precise number.

I've also added StandbyMode as a condition to restrict this to
replicas. XLogPageRead may be used by the primary when starting up,
and will likely re-read the WAL so releasing cached pages should be
avoided on the primary.

Attachment Content-Type Size
v3-0001-Don-t-keep-closed-WAL-segments-in-page-cache-afte.patch application/octet-stream 3.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nicolas Adenis-Lamarre 2026-02-18 09:54:48 Re: Convert coalesce to or/and
Previous Message Peter Eisentraut 2026-02-18 09:50:38 Use LOCKMODE in parse_relation.c/.h