Re: memory leak in logical WAL sender with pgoutput's cachectx - Mailing list pgsql-hackers

From Masahiko Sawada
Subject Re: memory leak in logical WAL sender with pgoutput's cachectx
Date
Msg-id CAD21AoAfc-8iPiT3KCc1Jx7CygCBV6Wuay-Xt_A8y=BAD0obsg@mail.gmail.com
Whole thread Raw
In response to RE: memory leak in logical WAL sender with pgoutput's cachectx  ("Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>)
List pgsql-hackers
On Fri, Aug 15, 2025 at 5:07 AM Hayato Kuroda (Fujitsu)
<kuroda.hayato@fujitsu.com> wrote:
>
> Dear Sawada-san,
>
> > Given that cache invalidation is executed upon replaying
> > REORDER_BUFFER_CHANGE_INVALIDATION and the end of a transaction
> > replay, in which case do we keep the relcache (i.e. just setting
> > replicate_valid=false) because of in_use=true?
>
> Per old discussion [1], logicalrep_write_tuple ->SearchSysCache1 can cause the
> cache invalidation (I did not verify though).
> I felt in this case in_use can be true and validation can be skipped. Thought?

I've not verified, but even if that's true, IIUC only one relation's
cache entry can set in_use to true at a time. If my understanding is
correct, when the walsender accepts invalidation messages in
logicalrep_write_tuple() as you mentioned, it doesn't release the
cache of the relation whose change is being sent but does for other
relations. It seems to me too aggressive to release caches compared to
the current behavior.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: index prefetching
Next
From: Masahiko Sawada
Date:
Subject: Re: memory leak in logical WAL sender with pgoutput's cachectx