mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Cross-check lists of built-in LWLock tranches.
lwlock.c, lwlock.h, and wait_event_names.txt each contain a list of
built-in LWLock tranches. It is easy to miss one or the other when
adding or removing tranches, and discrepancies have adverse effects
(e.g., breaking JOINs between pg_stat_activity and pg_wait_events).
This commit moves the lists of built-in tranches in lwlock.{c,h} to
lwlocklist.h and adds a cross-check to the script that generates
lwlocknames.h. If the lists do not match exactly, building will
fail.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/aHpOgwuFQfcFMZ/B%40ip-10-97-1-34.eu-west-3.compute.internal
This commit is contained in:
@@ -176,51 +176,23 @@ extern void LWLockInitialize(LWLock *lock, int tranche_id);
|
||||
* Every tranche ID less than NUM_INDIVIDUAL_LWLOCKS is reserved; also,
|
||||
* we reserve additional tranche IDs for builtin tranches not included in
|
||||
* the set of individual LWLocks. A call to LWLockNewTrancheId will never
|
||||
* return a value less than LWTRANCHE_FIRST_USER_DEFINED.
|
||||
* return a value less than LWTRANCHE_FIRST_USER_DEFINED. The actual list of
|
||||
* built-in tranches is kept in lwlocklist.h.
|
||||
*/
|
||||
typedef enum BuiltinTrancheIds
|
||||
{
|
||||
LWTRANCHE_XACT_BUFFER = NUM_INDIVIDUAL_LWLOCKS,
|
||||
LWTRANCHE_COMMITTS_BUFFER,
|
||||
LWTRANCHE_SUBTRANS_BUFFER,
|
||||
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
|
||||
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
|
||||
LWTRANCHE_NOTIFY_BUFFER,
|
||||
LWTRANCHE_SERIAL_BUFFER,
|
||||
LWTRANCHE_WAL_INSERT,
|
||||
LWTRANCHE_BUFFER_CONTENT,
|
||||
LWTRANCHE_REPLICATION_ORIGIN_STATE,
|
||||
LWTRANCHE_REPLICATION_SLOT_IO,
|
||||
LWTRANCHE_LOCK_FASTPATH,
|
||||
LWTRANCHE_BUFFER_MAPPING,
|
||||
LWTRANCHE_LOCK_MANAGER,
|
||||
LWTRANCHE_PREDICATE_LOCK_MANAGER,
|
||||
LWTRANCHE_PARALLEL_HASH_JOIN,
|
||||
LWTRANCHE_PARALLEL_BTREE_SCAN,
|
||||
LWTRANCHE_PARALLEL_QUERY_DSA,
|
||||
LWTRANCHE_PER_SESSION_DSA,
|
||||
LWTRANCHE_PER_SESSION_RECORD_TYPE,
|
||||
LWTRANCHE_PER_SESSION_RECORD_TYPMOD,
|
||||
LWTRANCHE_SHARED_TUPLESTORE,
|
||||
LWTRANCHE_SHARED_TIDBITMAP,
|
||||
LWTRANCHE_PARALLEL_APPEND,
|
||||
LWTRANCHE_PER_XACT_PREDICATE_LIST,
|
||||
LWTRANCHE_PGSTATS_DSA,
|
||||
LWTRANCHE_PGSTATS_HASH,
|
||||
LWTRANCHE_PGSTATS_DATA,
|
||||
LWTRANCHE_LAUNCHER_DSA,
|
||||
LWTRANCHE_LAUNCHER_HASH,
|
||||
LWTRANCHE_DSM_REGISTRY_DSA,
|
||||
LWTRANCHE_DSM_REGISTRY_HASH,
|
||||
LWTRANCHE_COMMITTS_SLRU,
|
||||
LWTRANCHE_MULTIXACTMEMBER_SLRU,
|
||||
LWTRANCHE_MULTIXACTOFFSET_SLRU,
|
||||
LWTRANCHE_NOTIFY_SLRU,
|
||||
LWTRANCHE_SERIAL_SLRU,
|
||||
LWTRANCHE_SUBTRANS_SLRU,
|
||||
LWTRANCHE_XACT_SLRU,
|
||||
LWTRANCHE_PARALLEL_VACUUM_DSA,
|
||||
LWTRANCHE_AIO_URING_COMPLETION,
|
||||
/*
|
||||
* LWTRANCHE_INVALID is an unused value that only exists to initialize the
|
||||
* rest of the tranches to appropriate values.
|
||||
*/
|
||||
LWTRANCHE_INVALID = NUM_INDIVIDUAL_LWLOCKS - 1,
|
||||
|
||||
#define PG_LWLOCK(id, name)
|
||||
#define PG_LWLOCKTRANCHE(id, name) LWTRANCHE_##id,
|
||||
#include "storage/lwlocklist.h"
|
||||
#undef PG_LWLOCK
|
||||
#undef PG_LWLOCKTRANCHE
|
||||
|
||||
LWTRANCHE_FIRST_USER_DEFINED,
|
||||
} BuiltinTrancheIds;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
*
|
||||
* lwlocklist.h
|
||||
*
|
||||
* The predefined LWLock list is kept in its own source file for use by
|
||||
* automatic tools. The exact representation of a keyword is determined by
|
||||
* the PG_LWLOCK macro, which is not defined in this file; it can be
|
||||
* The list of predefined LWLocks and built-in LWLock tranches is kept in
|
||||
* its own source file for use by automatic tools. The exact
|
||||
* representation of a keyword is determined by the PG_LWLOCK and
|
||||
* PG_LWLOCKTRANCHE macros, which are not defined in this file; they can be
|
||||
* defined by the caller for special purposes.
|
||||
*
|
||||
* Also, generate-lwlocknames.pl processes this file to create lwlocknames.h.
|
||||
@@ -84,3 +85,53 @@ PG_LWLOCK(50, DSMRegistry)
|
||||
PG_LWLOCK(51, InjectionPoint)
|
||||
PG_LWLOCK(52, SerialControl)
|
||||
PG_LWLOCK(53, AioWorkerSubmissionQueue)
|
||||
|
||||
/*
|
||||
* There also exist several built-in LWLock tranches. As with the predefined
|
||||
* LWLocks, be sure to update the WaitEventLWLock section of
|
||||
* src/backend/utils/activity/wait_event_names.txt when modifying this list.
|
||||
*
|
||||
* Note that the IDs here (the first value) don't include the LWTRANCHE_
|
||||
* prefix. It's added elsewhere.
|
||||
*/
|
||||
PG_LWLOCKTRANCHE(XACT_BUFFER, XactBuffer)
|
||||
PG_LWLOCKTRANCHE(COMMITTS_BUFFER, CommitTsBuffer)
|
||||
PG_LWLOCKTRANCHE(SUBTRANS_BUFFER, SubtransBuffer)
|
||||
PG_LWLOCKTRANCHE(MULTIXACTOFFSET_BUFFER, MultiXactOffsetBuffer)
|
||||
PG_LWLOCKTRANCHE(MULTIXACTMEMBER_BUFFER, MultiXactMemberBuffer)
|
||||
PG_LWLOCKTRANCHE(NOTIFY_BUFFER, NotifyBuffer)
|
||||
PG_LWLOCKTRANCHE(SERIAL_BUFFER, SerialBuffer)
|
||||
PG_LWLOCKTRANCHE(WAL_INSERT, WALInsert)
|
||||
PG_LWLOCKTRANCHE(BUFFER_CONTENT, BufferContent)
|
||||
PG_LWLOCKTRANCHE(REPLICATION_ORIGIN_STATE, ReplicationOriginState)
|
||||
PG_LWLOCKTRANCHE(REPLICATION_SLOT_IO, ReplicationSlotIO)
|
||||
PG_LWLOCKTRANCHE(LOCK_FASTPATH, LockFastPath)
|
||||
PG_LWLOCKTRANCHE(BUFFER_MAPPING, BufferMapping)
|
||||
PG_LWLOCKTRANCHE(LOCK_MANAGER, LockManager)
|
||||
PG_LWLOCKTRANCHE(PREDICATE_LOCK_MANAGER, PredicateLockManager)
|
||||
PG_LWLOCKTRANCHE(PARALLEL_HASH_JOIN, ParallelHashJoin)
|
||||
PG_LWLOCKTRANCHE(PARALLEL_BTREE_SCAN, ParallelBtreeScan)
|
||||
PG_LWLOCKTRANCHE(PARALLEL_QUERY_DSA, ParallelQueryDSA)
|
||||
PG_LWLOCKTRANCHE(PER_SESSION_DSA, PerSessionDSA)
|
||||
PG_LWLOCKTRANCHE(PER_SESSION_RECORD_TYPE, PerSessionRecordType)
|
||||
PG_LWLOCKTRANCHE(PER_SESSION_RECORD_TYPMOD, PerSessionRecordTypmod)
|
||||
PG_LWLOCKTRANCHE(SHARED_TUPLESTORE, SharedTupleStore)
|
||||
PG_LWLOCKTRANCHE(SHARED_TIDBITMAP, SharedTidBitmap)
|
||||
PG_LWLOCKTRANCHE(PARALLEL_APPEND, ParallelAppend)
|
||||
PG_LWLOCKTRANCHE(PER_XACT_PREDICATE_LIST, PerXactPredicateList)
|
||||
PG_LWLOCKTRANCHE(PGSTATS_DSA, PgStatsDSA)
|
||||
PG_LWLOCKTRANCHE(PGSTATS_HASH, PgStatsHash)
|
||||
PG_LWLOCKTRANCHE(PGSTATS_DATA, PgStatsData)
|
||||
PG_LWLOCKTRANCHE(LAUNCHER_DSA, LogicalRepLauncherDSA)
|
||||
PG_LWLOCKTRANCHE(LAUNCHER_HASH, LogicalRepLauncherHash)
|
||||
PG_LWLOCKTRANCHE(DSM_REGISTRY_DSA, DSMRegistryDSA)
|
||||
PG_LWLOCKTRANCHE(DSM_REGISTRY_HASH, DSMRegistryHash)
|
||||
PG_LWLOCKTRANCHE(COMMITTS_SLRU, CommitTsSLRU)
|
||||
PG_LWLOCKTRANCHE(MULTIXACTOFFSET_SLRU, MultiXactOffsetSLRU)
|
||||
PG_LWLOCKTRANCHE(MULTIXACTMEMBER_SLRU, MultiXactMemberSLRU)
|
||||
PG_LWLOCKTRANCHE(NOTIFY_SLRU, NotifySLRU)
|
||||
PG_LWLOCKTRANCHE(SERIAL_SLRU, SerialSLRU)
|
||||
PG_LWLOCKTRANCHE(SUBTRANS_SLRU, SubtransSLRU)
|
||||
PG_LWLOCKTRANCHE(XACT_SLRU, XactSLRU)
|
||||
PG_LWLOCKTRANCHE(PARALLEL_VACUUM_DSA, ParallelVacuumDSA)
|
||||
PG_LWLOCKTRANCHE(AIO_URING_COMPLETION, AioUringCompletion)
|
||||
|
||||
Reference in New Issue
Block a user