Re: Accessing an invalid pointer in BufferManagerRelation structure - Mailing list pgsql-hackers

From Daniil Davydov
Subject Re: Accessing an invalid pointer in BufferManagerRelation structure
Date
Msg-id CAJDiXgiQXRWZ+n=fHaLqzLkGt6y9DY4_HPELPwaq3AVcFGYKtA@mail.gmail.com
Whole thread Raw
In response to Re: Accessing an invalid pointer in BufferManagerRelation structure  (Álvaro Herrera <alvherre@kurilemu.de>)
Responses Re: Accessing an invalid pointer in BufferManagerRelation structure
List pgsql-hackers
Hi,

On Sun, Oct 19, 2025 at 6:32 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:
>
> I edited your comments a bit.  What do you think of this version?
>

Thanks for looking into this! All added changes LGTM.

> I don't think this is backpatchable material, mainly because you said
> you don't see any situations in which relcache invalidations would
> occur in the middle of this.  Can you can cause a problem to occur by
> adding an untimely invalidation somewhere without this patch, which is
> fixed by this patch?

Yep, by now (if I did not miss anything) described problem cannot occur even
with debug_discard_caches parameter on. But one of our clients had faced
this problem, because we have some differences in source code. In the first
letter I described scenario, when the occurrence of a problem becomes possible :
***
if (just for example) we add acquiring of new lock into ExtendBufferedRelLocal
or ExtendBufferedRelShared, relation cache will be invalidated (inside
AcceptInvalidationMessages).
***

>
> BTW how does this interact with SMgrRelation pinning?

Hm, maybe I don't fully understand the question. Smgr pinning is one of the side
effects of BMR_GET_SMGR (in case we use this macro with
invalidated/uninitialized
rd_smgr entry).
Without patch pincount cannot save us from undesirable invalidation,
because it guards
from smgr_destroy, not from smgr_release.

--
Best regards,
Daniil Davydov



pgsql-hackers by date:

Previous
From: Dimitrios Apostolou
Date:
Subject: [PATCH v4] parallel pg_restore: avoid disk seeks when jumping short distance forward
Next
From: Mihail Nikalayeu
Date:
Subject: Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY