From 474e7da6485687425d216eda1685d7e530b24fd6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 15 May 2020 21:47:21 -0400 Subject: [PATCH] Change locktype "speculative token" to "spectoken". It's just weird that this name wasn't chosen to look like an identifier. The suspicion that it wasn't thought about too hard is reinforced by the fact that it wasn't documented in the pg_locks view (until I did so, a day or two back). Update, and add a comment reminding future adjusters of this array to fix the docs too. Do some desultory wordsmithing on various entries in the wait events tables. Discussion: https://postgr.es/m/24595.1589326879@sss.pgh.pa.us --- doc/src/sgml/catalogs.sgml | 2 +- doc/src/sgml/monitoring.sgml | 93 +++++++++---------- src/backend/utils/adt/lockfuncs.c | 7 +- .../expected/insert-conflict-specconflict.out | 10 +- .../specs/insert-conflict-specconflict.spec | 2 +- 5 files changed, 58 insertions(+), 56 deletions(-) diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 9d8fa0bec3..b1b077c97f 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -10238,7 +10238,7 @@ SCRAM-SHA-256$<iteration count>:&l tuple, transactionid, virtualxid, - speculative token, + spectoken, object, userlock, or advisory. diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 42755659e1..be31ac48b1 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -919,68 +919,66 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Activity - The server process is idle. This is used by - system processes waiting for activity in their main processing loop. - wait_event will identify the specific wait point. - See . + The server process is idle. This event type indicates a process + waiting for activity in its main processing loop. + wait_event will identify the specific wait point; + see . BufferPin - The server process is waiting to access to - a data buffer during a period when no other process can be - examining that buffer. Buffer pin waits can be protracted if - another process holds an open cursor which last read data from the + The server process is waiting for exclusive access to + a data buffer. Buffer pin waits can be protracted if + another process holds an open cursor that last read data from the buffer in question. See . Client - The server process is waiting for some activity - on a socket from user applications, and that the server expects - something to happen that is independent from its internal processes. - wait_event will identify the specific wait point. - See . + The server process is waiting for activity on a socket + connected to a user application. Thus, the server expects something + to happen that is independent of its internal processes. + wait_event will identify the specific wait point; + see . Extension - The server process is waiting for activity - in an extension module. This category is useful for modules to - track custom waiting points. + The server process is waiting for some condition defined by an + extension module. See . IO - The server process is waiting for a IO to complete. - wait_event will identify the specific wait point. - See . + The server process is waiting for an I/O operation to complete. + wait_event will identify the specific wait point; + see . IPC - The server process is waiting for some activity - from another process in the server. wait_event will - identify the specific wait point. - See . + The server process is waiting for some interaction with + another server process. wait_event will + identify the specific wait point; + see . Lock - The backend is waiting for a heavyweight lock. + The server process is waiting for a heavyweight lock. Heavyweight locks, also known as lock manager locks or simply locks, primarily protect SQL-visible objects such as tables. However, they are also used to ensure mutual exclusion for certain internal operations such as relation extension. wait_event - will identify the type of lock awaited. - See . + will identify the type of lock awaited; + see . LWLock - The backend is waiting for a lightweight lock. - Each such lock protects a particular data structure in shared memory. + The server process is waiting for a lightweight lock. + Most such locks protect a particular data structure in shared memory. wait_event will contain a name identifying the purpose of the lightweight lock. (Some locks have specific names; others are part of a group of locks each with a similar purpose.) @@ -991,7 +989,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Timeout The server process is waiting for a timeout to expire. wait_event will identify the specific wait - point. See . + point; see . @@ -1011,7 +1009,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ArchiverMain - Waiting in main loop of the archiver process. + Waiting in main loop of archiver process. AutoVacuumMain @@ -1023,8 +1021,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser BgWriterMain - Waiting in main loop of background writer process background - worker. + Waiting in main loop of background writer process. CheckpointerMain @@ -1032,19 +1029,20 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser LogicalApplyMain - Waiting in main loop of logical apply process. + Waiting in main loop of logical replication apply process. LogicalLauncherMain - Waiting in main loop of logical launcher process. + Waiting in main loop of logical replication launcher process. PgStatMain - Waiting in main loop of the statistics collector process. + Waiting in main loop of statistics collector process. RecoveryWalStream - Waiting for WAL from a stream at recovery. + Waiting in main loop of startup process for WAL to arrive, during + streaming recovery. SysLoggerMain @@ -1079,7 +1077,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser BufferPin - Waiting to acquire a pin on a buffer. + Waiting to acquire an exclusive pin on a buffer. @@ -1106,7 +1104,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser GSSOpenServer - Waiting to read data from the client while establishing the GSSAPI + Waiting to read data from the client while establishing a GSSAPI session. @@ -1708,14 +1706,14 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser page - Waiting to acquire a lock on page of a relation. + Waiting to acquire a lock on a page of a relation. relation Waiting to acquire a lock on a relation. - speculative token + spectoken Waiting to acquire a speculative insertion lock. @@ -1732,7 +1730,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser virtualxid - Waiting to acquire a virtual xid lock. + Waiting to acquire a virtual transaction ID lock. @@ -2072,7 +2070,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Extensions can add LWLock types to the list shown in . In some cases, the name assigned by an extension will not be available in all server processes; - so a wait event might be reported as + so an LWLock wait event might be reported as just extension rather than the extension-assigned name. @@ -2095,17 +2093,18 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser PgSleep - Waiting in process that called pg_sleep. + Waiting due to a call to pg_sleep or + a sibling function. RecoveryApplyDelay - Waiting to apply WAL at recovery because it is delayed. + Waiting to apply WAL during recovery because of a delay + setting. RecoveryRetrieveRetryInterval - Waiting when WAL data is not available from any kind of sources - (pg_wal, archive or stream) before trying - again to retrieve WAL data, at recovery. + Waiting during recovery when WAL data is not available from any + source (pg_wal, archive or stream). VacuumDelay diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c index ecb1bf92ff..e992d1bbfc 100644 --- a/src/backend/utils/adt/lockfuncs.c +++ b/src/backend/utils/adt/lockfuncs.c @@ -22,7 +22,10 @@ #include "utils/builtins.h" -/* This must match enum LockTagType! */ +/* + * This must match enum LockTagType! Also, be sure to document any changes + * in the docs for the pg_locks view and for wait event types. + */ const char *const LockTagTypeNames[] = { "relation", "extend", @@ -30,7 +33,7 @@ const char *const LockTagTypeNames[] = { "tuple", "transactionid", "virtualxid", - "speculative token", + "spectoken", "object", "userlock", "advisory" diff --git a/src/test/isolation/expected/insert-conflict-specconflict.out b/src/test/isolation/expected/insert-conflict-specconflict.out index 9be5ccf55f..ae361fbd03 100644 --- a/src/test/isolation/expected/insert-conflict-specconflict.out +++ b/src/test/isolation/expected/insert-conflict-specconflict.out @@ -362,16 +362,16 @@ step controller_print_speculative_locks: SELECT pa.application_name, locktype, mode, granted FROM pg_locks pl JOIN pg_stat_activity pa USING (pid) WHERE - locktype IN ('speculative token', 'transactionid') + locktype IN ('spectoken', 'transactionid') AND pa.datname = current_database() AND pa.application_name LIKE 'isolation/insert-conflict-specconflict-s%' ORDER BY 1, 2, 3, 4; application_namelocktype mode granted -isolation/insert-conflict-specconflict-s1speculative tokenShareLock f +isolation/insert-conflict-specconflict-s1spectoken ShareLock f isolation/insert-conflict-specconflict-s1transactionid ExclusiveLock t -isolation/insert-conflict-specconflict-s2speculative tokenExclusiveLock t +isolation/insert-conflict-specconflict-s2spectoken ExclusiveLock t isolation/insert-conflict-specconflict-s2transactionid ExclusiveLock t step controller_unlock_2_4: SELECT pg_advisory_unlock(2, 4); pg_advisory_unlock @@ -384,7 +384,7 @@ step controller_print_speculative_locks: SELECT pa.application_name, locktype, mode, granted FROM pg_locks pl JOIN pg_stat_activity pa USING (pid) WHERE - locktype IN ('speculative token', 'transactionid') + locktype IN ('spectoken', 'transactionid') AND pa.datname = current_database() AND pa.application_name LIKE 'isolation/insert-conflict-specconflict-s%' ORDER BY 1, 2, 3, 4; @@ -406,7 +406,7 @@ step controller_print_speculative_locks: SELECT pa.application_name, locktype, mode, granted FROM pg_locks pl JOIN pg_stat_activity pa USING (pid) WHERE - locktype IN ('speculative token', 'transactionid') + locktype IN ('spectoken', 'transactionid') AND pa.datname = current_database() AND pa.application_name LIKE 'isolation/insert-conflict-specconflict-s%' ORDER BY 1, 2, 3, 4; diff --git a/src/test/isolation/specs/insert-conflict-specconflict.spec b/src/test/isolation/specs/insert-conflict-specconflict.spec index 2572072c9e..6028397491 100644 --- a/src/test/isolation/specs/insert-conflict-specconflict.spec +++ b/src/test/isolation/specs/insert-conflict-specconflict.spec @@ -64,7 +64,7 @@ step "controller_print_speculative_locks" { SELECT pa.application_name, locktype, mode, granted FROM pg_locks pl JOIN pg_stat_activity pa USING (pid) WHERE - locktype IN ('speculative token', 'transactionid') + locktype IN ('spectoken', 'transactionid') AND pa.datname = current_database() AND pa.application_name LIKE 'isolation/insert-conflict-specconflict-s%' ORDER BY 1, 2, 3, 4; -- 2.39.5