From 14a91010912632cae322b06fce0425faedcf7353 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 15 May 2020 19:55:56 -0400 Subject: [PATCH] Drop the redundant "Lock" suffix from LWLock wait event names. This was mostly confusing, especially since some wait events in this class had the suffix and some did not. While at it, stop exposing MainLWLockNames[] as a globally visible name; any code using that directly is almost certainly wrong, as its name has been misleading for some time. (GetLWLockIdentifier() is what to use instead.) Discussion: https://postgr.es/m/28683.1589405363@sss.pgh.pa.us --- doc/src/sgml/monitoring.sgml | 88 +++++++++---------- .../storage/lmgr/generate-lwlocknames.pl | 8 +- src/backend/storage/lmgr/lwlock.c | 5 +- src/include/storage/lwlock.h | 1 - 4 files changed, 53 insertions(+), 49 deletions(-) diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index e5b21cd8f61..42755659e1b 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -1750,31 +1750,31 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser - AddinShmemInitLock + AddinShmemInit Waiting to manage an extension's space allocation in shared memory. - AutoFileLock + AutoFile Waiting to update the postgresql.auto.conf file. - AutovacuumLock + Autovacuum Waiting to read or update the current state of autovacuum workers. - AutovacuumScheduleLock + AutovacuumSchedule Waiting to ensure that a table selected for autovacuum still needs vacuuming. - BackgroundWorkerLock + BackgroundWorker Waiting to read or update background worker state. - BtreeVacuumLock + BtreeVacuum Waiting to read or update vacuum-related information for a B-tree index. @@ -1792,15 +1792,15 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser pool. - CheckpointLock + Checkpoint Waiting to begin a checkpoint. - CheckpointerCommLock + CheckpointerComm Waiting to manage fsync requests. - CommitTsLock + CommitTs Waiting to read or update the last value set for a transaction commit timestamp. @@ -1809,16 +1809,16 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Waiting for I/O on a commit timestamp SLRU buffer. - CommitTsSLRULock + CommitTsSLRU Waiting to access the commit timestamp SLRU cache. - ControlFileLock + ControlFile Waiting to read or update the pg_control file or create a new WAL file. - DynamicSharedMemoryControlLock + DynamicSharedMemoryControl Waiting to read or update dynamic shared memory allocation information. @@ -1833,12 +1833,12 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser about heavyweight locks. - LogicalRepWorkerLock + LogicalRepWorker Waiting to read or update the state of logical replication workers. - MultiXactGenLock + MultiXactGen Waiting to read or update shared multixact state. @@ -1846,7 +1846,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Waiting for I/O on a multixact member SLRU buffer. - MultiXactMemberSLRULock + MultiXactMemberSLRU Waiting to access the multixact member SLRU cache. @@ -1854,11 +1854,11 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Waiting for I/O on a multixact offset SLRU buffer. - MultiXactOffsetSLRULock + MultiXactOffsetSLRU Waiting to access the multixact offset SLRU cache. - MultiXactTruncationLock + MultiXactTruncation Waiting to read or truncate multixact information. @@ -1867,20 +1867,20 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser buffer. - NotifyQueueLock + NotifyQueue Waiting to read or update NOTIFY messages. - NotifySLRULock + NotifySLRU Waiting to access the NOTIFY message SLRU cache. - OidGenLock + OidGen Waiting to allocate a new OID. - OldSnapshotTimeMapLock + OldSnapshotTimeMap Waiting to read or update old snapshot control information. @@ -1922,24 +1922,24 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser serializable transactions. - ProcArrayLock + ProcArray Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID). - RelationMappingLock + RelationMapping Waiting to read or update a pg_filenode.map file (used to track the filenode assignments of certain system catalogs). - RelCacheInitLock + RelCacheInit Waiting to read or update a pg_internal.init relation cache initialization file. - ReplicationOriginLock + ReplicationOrigin Waiting to create, drop or use a replication origin. @@ -1948,11 +1948,11 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser origin. - ReplicationSlotAllocationLock + ReplicationSlotAllocation Waiting to allocate or free a replication slot. - ReplicationSlotControlLock + ReplicationSlotControl Waiting to read or update replication slot state. @@ -1965,22 +1965,22 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser buffer. - SerializableFinishedListLock + SerializableFinishedList Waiting to access the list of finished serializable transactions. - SerializablePredicateListLock + SerializablePredicateList Waiting to access the list of predicate locks held by serializable transactions. - SerializableXactHashLock + SerializableXactHash Waiting to read or update information about serializable transactions. - SerialSLRULock + SerialSLRU Waiting to access the serializable transaction conflict SLRU cache. @@ -1995,16 +1995,16 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser query. - ShmemIndexLock + ShmemIndex Waiting to find or allocate space in shared memory. - SInvalReadLock + SInvalRead Waiting to retrieve messages from the shared catalog invalidation queue. - SInvalWriteLock + SInvalWrite Waiting to add a message to the shared catalog invalidation queue. @@ -2013,29 +2013,29 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Waiting for I/O on a sub-transaction SLRU buffer. - SubtransSLRULock + SubtransSLRU Waiting to access the sub-transaction SLRU cache. - SyncRepLock + SyncRep Waiting to read or update information about the state of synchronous replication. - SyncScanLock + SyncScan Waiting to select the starting location of a synchronized table scan. - TablespaceCreateLock + TablespaceCreate Waiting to create or drop a tablespace. - TwoPhaseStateLock + TwoPhaseState Waiting to read or update the state of prepared transactions. - WALBufMappingLock + WALBufMapping Waiting to replace a page in WAL buffers. @@ -2043,7 +2043,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Waiting to insert WAL data into a memory buffer. - WALWriteLock + WALWrite Waiting for WAL buffers to be written to disk. @@ -2051,16 +2051,16 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Waiting for I/O on a transaction status SLRU buffer. - XactSLRULock + XactSLRU Waiting to access the transaction status SLRU cache. - XactTruncationLock + XactTruncation Waiting to execute pg_xact_status or update the oldest transaction ID available to it. - XidGenLock + XidGen Waiting to allocate a new transaction ID. diff --git a/src/backend/storage/lmgr/generate-lwlocknames.pl b/src/backend/storage/lmgr/generate-lwlocknames.pl index 50fb8625cad..ca54acdfb0f 100644 --- a/src/backend/storage/lmgr/generate-lwlocknames.pl +++ b/src/backend/storage/lmgr/generate-lwlocknames.pl @@ -23,7 +23,7 @@ print $h $autogen; print $h "/* there is deliberately not an #ifndef LWLOCKNAMES_H here */\n\n"; print $c $autogen, "\n"; -print $c "const char *const MainLWLockNames[] = {"; +print $c "const char *const IndividualLWLockNames[] = {"; while (<$lwlocknames>) { @@ -38,6 +38,10 @@ while (<$lwlocknames>) (my $lockname, my $lockidx) = ($1, $2); + my $trimmedlockname = $lockname; + $trimmedlockname =~ s/Lock$//; + die "lock names must end with 'Lock'" if $trimmedlockname eq $lockname; + die "lwlocknames.txt not in order" if $lockidx < $lastlockidx; die "lwlocknames.txt has duplicates" if $lockidx == $lastlockidx; @@ -47,7 +51,7 @@ while (<$lwlocknames>) printf $c "%s \"\"", $continue, $lastlockidx; $continue = ",\n"; } - printf $c "%s \"%s\"", $continue, $lockname; + printf $c "%s \"%s\"", $continue, $trimmedlockname; $lastlockidx = $lockidx; $continue = ",\n"; diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 0bdc8e0499d..2fa90cc0954 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -111,7 +111,7 @@ extern slock_t *ShmemLock; * There are three sorts of LWLock "tranches": * * 1. The individually-named locks defined in lwlocknames.h each have their - * own tranche. The names of these tranches appear in MainLWLockNames[] + * own tranche. The names of these tranches appear in IndividualLWLockNames[] * in lwlocknames.c. * * 2. There are some predefined tranches for built-in groups of locks. @@ -125,6 +125,7 @@ extern slock_t *ShmemLock; * All these names are user-visible as wait event names, so choose with care * ... and do not forget to update the documentation's list of wait events. */ +extern const char *const IndividualLWLockNames[]; /* in lwlocknames.c */ static const char *const BuiltinTrancheNames[] = { /* LWTRANCHE_XACT_BUFFER: */ @@ -781,7 +782,7 @@ GetLWTrancheName(uint16 trancheId) { /* Individual LWLock? */ if (trancheId < NUM_INDIVIDUAL_LWLOCKS) - return MainLWLockNames[trancheId]; + return IndividualLWLockNames[trancheId]; /* Built-in tranche? */ if (trancheId < LWTRANCHE_FIRST_USER_DEFINED) diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h index d8e1b5c493e..c04ae971485 100644 --- a/src/include/storage/lwlock.h +++ b/src/include/storage/lwlock.h @@ -88,7 +88,6 @@ typedef union LWLockMinimallyPadded } LWLockMinimallyPadded; extern PGDLLIMPORT LWLockPadded *MainLWLockArray; -extern const char *const MainLWLockNames[]; /* struct for storing named tranche information */ typedef struct NamedLWLockTranche