Re: Improve LWLock tranche name visibility across backends

From: Rahila Syed <rahilasyed90(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improve LWLock tranche name visibility across backends
Date: 2025-09-01 13:05:55
Message-ID: CAH2L28sz2NcLCS2v1MNkBNUiTiO=-CegFGdAvO24nE+hbjzgjQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> I've also attached a rebased patch that addresses all the latest feedback.
> A reworked verison of the test patch is also included, but that's mostly
> intended for CI purposes and is still not intended for commit (yet).
>
>
Please see below for some comments regarding v20 patch.

1. Following unused declaration is present in the lwlock.h file.

extern void LWLockRegisterTranche(int tranche_id, const char
*tranche_name);

2. I am struggling to understand the use of LocalLWLockCounter in the patch.

If the intention is to delay acquiring the spin lock when trancheId is less
than LocalLWLockCounter,
it seems possible that we might read NamedLWLockTrancheNames in the
GetLWTrancheName function
after LocalLWLockCounter has been updated, but before
NamedLWLockTrancheNames has been updated
in the LWLockNewTrancheId function.
To prevent reading an outdated tranche name, we should acquire the spin
lock unconditionally in the
GetLWTrancheName function

3.
+ ereport(ERROR,
+ (errmsg("maximum number of tranches already
registered"),
+ errdetail("No more than %d tranches may be
registered.",
+ MAX_NAMED_TRANCHES)));
+ }

Since this patch sets a maximum limit on the number of LW lock tranches
that can be registered,
would it make sense to offer a configurable option rather than using a
hard-coded MAX_NUM_TRANCHES?
This will allow users who have reached the maximum limit to register their
LW Locks.

Thank you,
Rahila Syed

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2025-09-01 13:12:20 Re: ABI Compliance Checker GSoC Project
Previous Message David E. Wheeler 2025-09-01 13:02:23 Re: Generate GUC tables from .dat file