pgsql: Check that the tranche name is unique in RequestNamedLWLockTranc

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Check that the tranche name is unique in RequestNamedLWLockTranc
Date: 2026-04-05 18:11:33
Message-ID: E1w9Rwa-00376E-2T@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Check that the tranche name is unique in RequestNamedLWLockTranche

You could request two tranches with same name, but things would get
confusing when you called GetNamedLWLockTranche() to get the LWLocks
allocated for them; it would always return the first tranche with the
name. That doesn't make sense, so forbid duplicates.

We still allow duplicates with LWLockNewTrancheId(). That works better
as you don't use the name to look up the tranche ID later. It's still
confusing in wait events, for example, but it's not dangerous in the
same way.

Reviewed-by: Sami Imseih <samimseih(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/463a28db-0c0b-4af6-bac6-3891828bbbfe@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f10b6be2581f879f24a4830443bab356ec6d71c5

Modified Files
--------------
src/backend/storage/lmgr/lwlock.c | 7 +++++++
1 file changed, 7 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2026-04-05 19:29:26 pgsql: Add tid_block() and tid_offset() accessor functions
Previous Message Andrew Dunstan 2026-04-05 15:02:21 pgsql: Add pg_get_database_ddl() function