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-16 21:04:39
Message-ID: CAA5RZ0uaKtz7P=po9uqx=V=h6WofMJyp9O2UzpeDw98GNxbS-w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Tue, Sep 16, 2025 at 02:35:55PM -0500, Nathan Bossart wrote:
> > On Thu, Sep 11, 2025 at 04:18:00PM -0500, Nathan Bossart wrote:
> >> I've committed 0001, and I plan to look closer at 0002 soon.
> >
> > I ended up rewriting 0002 as an ordinary regression test, which resulted in
> > a much smaller patch with comparable coverage. (Yes, it needs some
> > comments.) Thoughts?
>
> Sorry for the noise. I was able to simplify the test code further.

This is a trimmed down test suite, but it does cover quite a bit:
tranche name length, NULL tranche names, number of tranches registered,
tranche name lookup. Overall this is still good test coverage.

A few comments.

1/
startup tranches should be:

#define NUM_STARTUP_TRANCHES (2)

instead of:

#define NUM_STARTUP_TRANCHES (256 - 2)

2/
I do think we should add tests for LWLockInitialize to test error for
an unregistered tranche.

```
Datum
test_lwlock_tranche_initialize(PG_FUNCTION_ARGS)
{
LWLock lock;

LWLockInitialize(&lock, LWTRANCHE_FIRST_USER_DEFINED + PG_GETARG_INT32(0));

PG_RETURN_VOID();
}
```

and we can run this test as the first query, before we create any
dynamic tranches
```
SELECT test_lwlock_tranche_initialize(2);
```

The error message will change when a built-in tranche is added, so
the out file will need to be updated at that point, but that does not occur
too often.

--
Sami

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniil Davydov 2025-09-16 21:48:51 [BUG] Query with postgres fwd deletes more tuples than it should
Previous Message Robert Haas 2025-09-16 20:12:39 Re: RFC: extensible planner state