LWLock waits
LWLock means a backend could not immediately acquire a lightweight lock that protects an internal shared-memory structure. It does not identify a SQL row or table lock, and pg_locks usually cannot name its owner.
repeat samples → isolate one hot tranche → correlate with workloadHow to read this class
A single sample is ordinary scheduler noise. Treat the event as contention only when the same LWLock name recurs across consecutive samples and affects foreground sessions whose latency has increased.
- Normal: brief appearances during WAL generation, snapshot acquisition, buffer lookup, vacuum, or checkpoint work.
- Watch: the same event occupies at least 10% of active foreground backends in three consecutive 1-second snapshots.
- Urgent: at least 25% of active foreground backends pile onto one event, waits persist beyond 5 seconds, or throughput collapses at the same time.
The percentages are operational triage thresholds, not PostgreSQL guarantees. Compare with the cluster’s own baseline and exclude background processes whose main loop is expected to wait.
Ten events worth recognizing
| Event | Protected resource | Typical story |
|---|---|---|
| BufferContent | Contents of one shared buffer | Many sessions touch the same hot page |
| BufferMapping | Buffer-table mapping partitions | Working-set churn or broad concurrent scans |
| LockManager | Heavyweight lock manager state | Large lock fan-out, DDL, or lock storms |
| ProcArray | Shared process/transaction array | Snapshot and transaction-ID pressure |
| WALBufMapping | WAL buffer page mapping | WAL buffers turn over under write pressure |
| WALInsert | WAL insertion state | Many writers serialize while inserting WAL |
| WALWrite | WAL buffer write coordination | WAL flush/write path cannot keep up |
| XactSLRU | Transaction-status SLRU | pg_xact cache churn or old visibility checks |
| MultiXactMemberSLRU | Multixact-member SLRU | Heavy row-locking and multixact churn |
| SyncRep | Synchronous replication wait queues | Commit acknowledgements and sender state contend |
Common misreads
- “LWLock means a leaked lock.” No. It is a short internal critical section; sustained recurrence is the signal.
- “The query shown owns the lock.”
pg_stat_activity.querybelongs to the waiter. The holder can be another backend inside a different source path. - “More CPU fixes it.” Extra concurrency can intensify a shared-memory hotspot. First identify the protected resource and workload shape.
- “
pg_lockswill reveal the blocker.” It covers heavyweight and predicate locks, not general LWLock ownership.
Start with BufferContent for a page-level hotspot and WALInsert for a write-heavy cluster.
Waiting to manage an extension’s space allocation in shared memory
Waiting for another process to complete IO via io_uring
Waiting to access AIO worker submission queue
Waiting to update the postgresql.auto.conf file
Waiting to read or update the current state of autovacuum workers
Waiting to ensure that a table selected for autovacuum still needs vacuuming
Waiting to read or update background worker state
Waiting to read or update vacuum-related information for a B-tree index
Waiting to access a data page in memory
Waiting to associate a data block with a buffer in the buffer pool
Waiting to begin a checkpoint.
Waiting to manage fsync requests
Waiting to read or update the last value set for a transaction commit timestamp
Waiting for I/O on a commit timestamp SLRU buffer
Waiting to access the commit timestamp SLRU cache
Waiting to read or update the pg_control file or create a new WAL file
Waiting to read or update the dynamic shared memory registry
Waiting to access dynamic shared memory registry’s dynamic shared memory allocator
Waiting to access dynamic shared memory registry’s shared hash table
Waiting to read or update dynamic shared memory allocation information
Waiting to read or update information related to injection points
Waiting to read or update a process’ fast-path lock information
Waiting to read or update information about “heavyweight” locks
Waiting to access logical replication launcher’s dynamic shared memory allocator
Waiting to access logical replication launcher’s shared hash table
Waiting to read or update the state of logical replication workers
Waiting to read or update shared multixact state
Waiting for I/O on a multixact member SLRU buffer
Waiting to access the multixact member SLRU cache
Waiting for I/O on a multixact offset SLRU buffer
Waiting to access the multixact offset SLRU cache
Waiting to read or truncate multixact information
Waiting for I/O on a NOTIFY message SLRU buffer
Waiting to read or update NOTIFY messages
Waiting to update limit on NOTIFY message storage
Waiting to access the NOTIFY message SLRU cache
Waiting to allocate a new OID
Waiting to read or update old snapshot control information.
Waiting to choose the next subplan during Parallel Append plan execution
Waiting to synchronize workers during Parallel B-tree scan plan execution
Waiting to synchronize workers during Parallel Hash Join plan execution
Waiting for parallel query dynamic shared memory allocation
Waiting for parallel vacuum dynamic shared memory allocation
Waiting for parallel query dynamic shared memory allocation
Waiting to access a parallel query’s information about composite types
Waiting to access a parallel query’s information about type modifiers that identify anonymous record types
Waiting to access the list of predicate locks held by the current serializable transaction during a parallel query
Waiting for stats dynamic shared memory allocator access
Waiting for shared memory stats data access
Waiting for stats shared memory hash table access
Waiting to access predicate lock information used by serializable transactions
Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session’s transaction ID)
Waiting to read or update a pg_internal.init relation cache initialization file
Waiting to read or update a pg_filenode.map file (used to track the filenode assignments of certain system catalogs)
Waiting to create, drop or use a replication origin
Waiting to read or update the progress of one replication origin
Waiting to allocate or free a replication slot
Waiting to read or update replication slot state
Waiting for I/O on a replication slot
Waiting to retrieve messages from the shared catalog invalidation queue
Waiting to add a message to the shared catalog invalidation queue
Waiting for I/O on a serializable transaction conflict SLRU buffer
Waiting to read or update shared pg_serial state
Waiting to access the serializable transaction conflict SLRU cache
Waiting to access the list of finished serializable transactions
Waiting to access the list of predicate locks held by serializable transactions
Waiting to read or update information about serializable transactions
Waiting to access a shared TID bitmap during a parallel bitmap index scan
Waiting to access a shared tuple store during parallel query
Waiting to find or allocate space in shared memory
Waiting for I/O on a sub-transaction SLRU buffer
Waiting to access the sub-transaction SLRU cache
Waiting to read or update information about the state of synchronous replication
Waiting to select the starting location of a synchronized table scan
Waiting to create or drop a tablespace
Waiting to read or update the state of prepared transactions
Waiting to replace a page in WAL buffers
Waiting to insert WAL data into a memory buffer
Waiting to read or update WAL summarization state
Waiting for WAL buffers to be written to disk
Waiting to read or update custom wait events information
Waiting to update limits on transaction id and multixact consumption
Waiting for I/O on a transaction status SLRU buffer
Waiting to access the transaction status SLRU cache
Waiting to execute pg_xact_status or update the oldest transaction ID available to it
Waiting to allocate a new transaction ID