Re: GetNamedLWLockTranche crashes on Windows in normal backend

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: GetNamedLWLockTranche crashes on Windows in normal backend
Date: 2025-09-08 19:47:26
Message-ID: CAA5RZ0vpr0P2rbA=_K0_SCHM7bmfVX4wEO9FAyopN1eWCYORhA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Thu, Sep 04, 2025 at 08:35:13PM -0500, Nathan Bossart wrote:
> > On Thu, Sep 04, 2025 at 04:12:09PM -0500, Sami Imseih wrote:
> >>> Yeah, I think modeling this after commit 4f2400c is a reasonable thing to
> >>> explore.
> >>
> >> Here it is as described above.
> >
> > Thanks. This looks like the right idea to me, but let's give some time for
> > others to comment.
>
> I've started preparing this for commit, and I realized that restricting
> GetNamedLWLockTranche() to shmem_startup_hook is not sufficient.
> EXEC_BACKEND builds will run this hook in every backend, so unless it's
> guarded behind some sort of "if (!found)" condition (i.e., only run in the
> postmaster), it'll still crash. I think we just need to add some extra
> notes to the docs and check for !IsUnderPostmaster, as discussed upthread.

I think v2 is fine because it is perfectly fine for a normal backend (
EXEC_BACKEND)
to call this function as long as it's processing the startup hook. The
goal is to prevent it
from being called outside of the startup hook.

> Or... what if we just moved the request array to shared memory?

I guess that works also, if we want to maintain the existing behavior.
I am OK with this
as well, and I don't see anything wrong with v3.

FWIW, I got the tests discussed in [0] commit ready and also included
tests for this
crash.

Attached is the patch with the tests. v4-0001 and v3-0001 are identical.
v4-0002 includes the tests.

I think we should commit these tests as well. If you think the tests should
be a separate thread, let me know.

--
Sami

[0] https://www.postgresql.org/message-id/aLcPbyWLawp5_rdt%40nathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-09-08 19:53:35 Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Previous Message Paul Ohlhauser 2025-09-08 19:30:07 Re: [PG19-3 PATCH] Don't ignore passfile