pgsql: Make LWLockCounter a global variable.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make LWLockCounter a global variable.
Date: 2025-08-29 17:14:06
Message-ID: E1us2fu-002Frr-10@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Make LWLockCounter a global variable.

Using the LWLockCounter requires first calculating its address in
shared memory like this:

LWLockCounter = (int *) ((char *) MainLWLockArray - sizeof(int));

Commit 82e861fbe1 started this trend in order to fix EXEC_BACKEND
builds, but it could also be fixed by adding it to the
BackendParameters struct. The current approach is somewhat
difficult to follow, so this commit switches to the latter. While
at it, swap around the code in LWLockShmemSize() to match the order
of assignments in CreateLWLocks() for added readability.

Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Discussion: https://postgr.es/m/aLDLnan9gNCS9fHx%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/67fcf48c3bb3cc3cf51788332701ffb694fb108b

Modified Files
--------------
src/backend/postmaster/launch_backend.c | 3 +++
src/backend/storage/lmgr/lwlock.c | 24 ++++++++----------------
src/include/storage/lwlock.h | 1 +
3 files changed, 12 insertions(+), 16 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-08-29 17:31:15 pgsql: pg_dump: Fix compression API errorhandling
Previous Message Tom Lane 2025-08-29 16:06:04 pgsql: Fix .gitignore for src/interfaces/libpq-oauth.