pgsql: test_dsa: Avoid leaking LWLock tranches.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: test_dsa: Avoid leaking LWLock tranches.
Date: 2025-11-12 20:58:28
Message-ID: E1vJHvA-006IGz-1Y@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

test_dsa: Avoid leaking LWLock tranches.

Since this is a test module, leaking a couple of LWLock tranches is
fine, but we want to discourage that pattern in third-party code.
This commit teaches the module to create only one tranche and to
store its ID in shared memory for use by other backends.

Reported-by: Alexander Lakhin <exclusion(at)gmail(dot)com>
Reviewed-by: Sami Imseih <samimseih(at)gmail(dot)com>
Discussion: https://postgr.es/m/dd36d384-55df-4fc2-825c-5bc56c950fa9%40gmail.com

Branch
------
master

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

Modified Files
--------------
src/test/modules/test_dsa/test_dsa.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2025-11-12 21:13:28 pgsql: Remove obsolete autovacuum comment.
Previous Message Nathan Bossart 2025-11-12 20:31:11 pgsql: Teach DSM registry to ERROR if attaching to an uninitialized ent