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-08-25 19:34:17
Message-ID: CAA5RZ0tuKYaaS3ohjqXzxgk7xExz1VdP4Xyay9YxemJWr4vAfg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > Another approach is to just change GetNamedLWLockTranche to use
> > NamedLWLockTrancheArray since that is already copied in EXEC_BACKEND, and
> > allow GetNamedLWLockTranche to continue to be used outside of startup. In
> > this case, we will need to add num_lwlocks field to
> > NamedLWLockTrancheArray. This might be better to backpatch, since we will
> > not be changing user facing behavior.
>
> That seems like a reasonable thing to try. It looks like
> NamedLWLockTrancheRequests is copied, too. Could we used that instead of
> adding a new variable?

We would not need a new variable. Currently it's assumed that
NamedLWLockTrancheRequests will be the size of both
NamedLWLockTrancheRequests and NamedLWLockTrancheArray.

```
/*
* NamedLWLockTrancheRequests is both the valid length of the request array,
* and the length of the shared-memory NamedLWLockTrancheArray later on.
* This variable and NamedLWLockTrancheArray are non-static so that
* postmaster.c can copy them to child processes in EXEC_BACKEND builds.
*/
int NamedLWLockTrancheRequests = 0;
```

> My guess is that this has been broken since this code was introduced in
> commit c1772ad from 2016/v9.6, and AFAIK you are the first to report it, so
> I don't feel a tremendous amount of urgency to fix it on the back-branches.

Yeah, I was doing something for testing that is not likely to be done in
the real-world. Also, considering this is an EXEC_BACKEND case only,
it makes it even less likely.

--
Sami

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-08-25 19:46:59 Re: RFC: extensible planner state
Previous Message Masahiko Sawada 2025-08-25 19:24:07 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart