# LWLock waits

> Contention on PostgreSQL's internal shared-memory data structures.
---

`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.

<div class="signal-strip"><span class="signal-dot"></span><strong>Operator rule</strong><code>repeat samples → isolate one hot tranche → correlate with workload</code></div>

## How to read this class {#how-to-read}

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 {#top-events}

| Event | Protected resource | Typical story |
| --- | --- | --- |
| [BufferContent](buffer-content/) | Contents of one shared buffer | Many sessions touch the same hot page |
| [BufferMapping](buffer-mapping/) | Buffer-table mapping partitions | Working-set churn or broad concurrent scans |
| [LockManager](lock-manager/) | Heavyweight lock manager state | Large lock fan-out, DDL, or lock storms |
| [ProcArray](proc-array/) | Shared process/transaction array | Snapshot and transaction-ID pressure |
| [WALBufMapping](wal-buf-mapping/) | WAL buffer page mapping | WAL buffers turn over under write pressure |
| [WALInsert](wal-insert/) | WAL insertion state | Many writers serialize while inserting WAL |
| [WALWrite](wal-write/) | WAL buffer write coordination | WAL flush/write path cannot keep up |
| [XactSLRU](xact-slru/) | Transaction-status SLRU | pg_xact cache churn or old visibility checks |
| [MultiXactMemberSLRU](multi-xact-member-slru/) | Multixact-member SLRU | Heavy row-locking and multixact churn |
| [SyncRep](sync-rep/) | Synchronous replication wait queues | Commit acknowledgements and sender state contend |

## Common misreads {#misreads}

1. **“LWLock means a leaked lock.”** No. It is a short internal critical section; sustained recurrence is the signal.
2. **“The query shown owns the lock.”** `pg_stat_activity.query` belongs to the waiter. The holder can be another backend inside a different source path.
3. **“More CPU fixes it.”** Extra concurrency can intensify a shared-memory hotspot. First identify the protected resource and workload shape.
4. **“`pg_locks` will reveal the blocker.”** It covers heavyweight and predicate locks, not general LWLock ownership.

Start with [BufferContent](buffer-content/) for a page-level hotspot and [WALInsert](wal-insert/) for a write-heavy cluster.

---

Section pages:

- [LWLock: AddinShmemInit](/lwlock/addin-shmem-init/): Waiting to manage an extension's space allocation in shared memory
- [LWLock: AioUringCompletion](/lwlock/aio-uring-completion/): Waiting for another process to complete IO via io_uring
- [LWLock: AioWorkerSubmissionQueue](/lwlock/aio-worker-submission-queue/): Waiting to access AIO worker submission queue
- [LWLock: AutoFile](/lwlock/auto-file/): Waiting to update the postgresql.auto.conf file
- [LWLock: Autovacuum](/lwlock/autovacuum/): Waiting to read or update the current state of autovacuum workers
- [LWLock: AutovacuumSchedule](/lwlock/autovacuum-schedule/): Waiting to ensure that a table selected for autovacuum still needs vacuuming
- [LWLock: BackgroundWorker](/lwlock/background-worker/): Waiting to read or update background worker state
- [LWLock: BtreeVacuum](/lwlock/btree-vacuum/): Waiting to read or update vacuum-related information for a B-tree index
- [LWLock: BufferContent](/lwlock/buffer-content/): Waiting to access a data page in memory
- [LWLock: BufferMapping](/lwlock/buffer-mapping/): Waiting to associate a data block with a buffer in the buffer pool
- [LWLock: Checkpoint](/lwlock/checkpoint/): Waiting to begin a checkpoint.
- [LWLock: CheckpointerComm](/lwlock/checkpointer-comm/): Waiting to manage fsync requests
- [LWLock: CommitTs](/lwlock/commit-ts/): Waiting to read or update the last value set for a transaction commit timestamp
- [LWLock: CommitTsBuffer](/lwlock/commit-ts-buffer/): Waiting for I/O on a commit timestamp SLRU buffer
- [LWLock: CommitTsSLRU](/lwlock/commit-ts-slru/): Waiting to access the commit timestamp SLRU cache
- [LWLock: ControlFile](/lwlock/control-file/): Waiting to read or update the pg_control file or create a new WAL file
- [LWLock: DSMRegistry](/lwlock/dsm-registry/): Waiting to read or update the dynamic shared memory registry
- [LWLock: DSMRegistryDSA](/lwlock/dsm-registry-dsa/): Waiting to access dynamic shared memory registry's dynamic shared memory allocator
- [LWLock: DSMRegistryHash](/lwlock/dsm-registry-hash/): Waiting to access dynamic shared memory registry's shared hash table
- [LWLock: DynamicSharedMemoryControl](/lwlock/dynamic-shared-memory-control/): Waiting to read or update dynamic shared memory allocation information
- [LWLock: InjectionPoint](/lwlock/injection-point/): Waiting to read or update information related to injection points
- [LWLock: LockFastPath](/lwlock/lock-fast-path/): Waiting to read or update a process' fast-path lock information
- [LWLock: LockManager](/lwlock/lock-manager/): Waiting to read or update information about "heavyweight" locks
- [LWLock: LogicalRepLauncherDSA](/lwlock/logical-rep-launcher-dsa/): Waiting to access logical replication launcher's dynamic shared memory allocator
- [LWLock: LogicalRepLauncherHash](/lwlock/logical-rep-launcher-hash/): Waiting to access logical replication launcher's shared hash table
- [LWLock: LogicalRepWorker](/lwlock/logical-rep-worker/): Waiting to read or update the state of logical replication workers
- [LWLock: MultiXactGen](/lwlock/multi-xact-gen/): Waiting to read or update shared multixact state
- [LWLock: MultiXactMemberBuffer](/lwlock/multi-xact-member-buffer/): Waiting for I/O on a multixact member SLRU buffer
- [LWLock: MultiXactMemberSLRU](/lwlock/multi-xact-member-slru/): Waiting to access the multixact member SLRU cache
- [LWLock: MultiXactOffsetBuffer](/lwlock/multi-xact-offset-buffer/): Waiting for I/O on a multixact offset SLRU buffer
- [LWLock: MultiXactOffsetSLRU](/lwlock/multi-xact-offset-slru/): Waiting to access the multixact offset SLRU cache
- [LWLock: MultiXactTruncation](/lwlock/multi-xact-truncation/): Waiting to read or truncate multixact information
- [LWLock: NotifyBuffer](/lwlock/notify-buffer/): Waiting for I/O on a NOTIFY message SLRU buffer
- [LWLock: NotifyQueue](/lwlock/notify-queue/): Waiting to read or update NOTIFY messages
- [LWLock: NotifyQueueTail](/lwlock/notify-queue-tail/): Waiting to update limit on NOTIFY message storage
- [LWLock: NotifySLRU](/lwlock/notify-slru/): Waiting to access the NOTIFY message SLRU cache
- [LWLock: OidGen](/lwlock/oid-gen/): Waiting to allocate a new OID
- [LWLock: OldSnapshotTimeMap](/lwlock/old-snapshot-time-map/): Waiting to read or update old snapshot control information.
- [LWLock: ParallelAppend](/lwlock/parallel-append/): Waiting to choose the next subplan during Parallel Append plan execution
- [LWLock: ParallelBtreeScan](/lwlock/parallel-btree-scan/): Waiting to synchronize workers during Parallel B-tree scan plan execution
- [LWLock: ParallelHashJoin](/lwlock/parallel-hash-join/): Waiting to synchronize workers during Parallel Hash Join plan execution
- [LWLock: ParallelQueryDSA](/lwlock/parallel-query-dsa/): Waiting for parallel query dynamic shared memory allocation
- [LWLock: ParallelVacuumDSA](/lwlock/parallel-vacuum-dsa/): Waiting for parallel vacuum dynamic shared memory allocation
- [LWLock: PerSessionDSA](/lwlock/per-session-dsa/): Waiting for parallel query dynamic shared memory allocation
- [LWLock: PerSessionRecordType](/lwlock/per-session-record-type/): Waiting to access a parallel query's information about composite types
- [LWLock: PerSessionRecordTypmod](/lwlock/per-session-record-typmod/): Waiting to access a parallel query's information about type modifiers that identify anonymous record types
- [LWLock: PerXactPredicateList](/lwlock/per-xact-predicate-list/): Waiting to access the list of predicate locks held by the current serializable transaction during a parallel query
- [LWLock: PgStatsDSA](/lwlock/pg-stats-dsa/): Waiting for stats dynamic shared memory allocator access
- [LWLock: PgStatsData](/lwlock/pg-stats-data/): Waiting for shared memory stats data access
- [LWLock: PgStatsHash](/lwlock/pg-stats-hash/): Waiting for stats shared memory hash table access
- [LWLock: PredicateLockManager](/lwlock/predicate-lock-manager/): Waiting to access predicate lock information used by serializable transactions
- [LWLock: ProcArray](/lwlock/proc-array/): Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID)
- [LWLock: RelCacheInit](/lwlock/rel-cache-init/): Waiting to read or update a pg_internal.init relation cache initialization file
- [LWLock: RelationMapping](/lwlock/relation-mapping/): Waiting to read or update a pg_filenode.map file (used to track the filenode assignments of certain system catalogs)
- [LWLock: ReplicationOrigin](/lwlock/replication-origin/): Waiting to create, drop or use a replication origin
- [LWLock: ReplicationOriginState](/lwlock/replication-origin-state/): Waiting to read or update the progress of one replication origin
- [LWLock: ReplicationSlotAllocation](/lwlock/replication-slot-allocation/): Waiting to allocate or free a replication slot
- [LWLock: ReplicationSlotControl](/lwlock/replication-slot-control/): Waiting to read or update replication slot state
- [LWLock: ReplicationSlotIO](/lwlock/replication-slot-io/): Waiting for I/O on a replication slot
- [LWLock: SInvalRead](/lwlock/s-inval-read/): Waiting to retrieve messages from the shared catalog invalidation queue
- [LWLock: SInvalWrite](/lwlock/s-inval-write/): Waiting to add a message to the shared catalog invalidation queue
- [LWLock: SerialBuffer](/lwlock/serial-buffer/): Waiting for I/O on a serializable transaction conflict SLRU buffer
- [LWLock: SerialControl](/lwlock/serial-control/): Waiting to read or update shared pg_serial state
- [LWLock: SerialSLRU](/lwlock/serial-slru/): Waiting to access the serializable transaction conflict SLRU cache
- [LWLock: SerializableFinishedList](/lwlock/serializable-finished-list/): Waiting to access the list of finished serializable transactions
- [LWLock: SerializablePredicateList](/lwlock/serializable-predicate-list/): Waiting to access the list of predicate locks held by serializable transactions
- [LWLock: SerializableXactHash](/lwlock/serializable-xact-hash/): Waiting to read or update information about serializable transactions
- [LWLock: SharedTidBitmap](/lwlock/shared-tid-bitmap/): Waiting to access a shared TID bitmap during a parallel bitmap index scan
- [LWLock: SharedTupleStore](/lwlock/shared-tuple-store/): Waiting to access a shared tuple store during parallel query
- [LWLock: ShmemIndex](/lwlock/shmem-index/): Waiting to find or allocate space in shared memory
- [LWLock: SubtransBuffer](/lwlock/subtrans-buffer/): Waiting for I/O on a sub-transaction SLRU buffer
- [LWLock: SubtransSLRU](/lwlock/subtrans-slru/): Waiting to access the sub-transaction SLRU cache
- [LWLock: SyncRep](/lwlock/sync-rep/): Waiting to read or update information about the state of synchronous replication
- [LWLock: SyncScan](/lwlock/sync-scan/): Waiting to select the starting location of a synchronized table scan
- [LWLock: TablespaceCreate](/lwlock/tablespace-create/): Waiting to create or drop a tablespace
- [LWLock: TwoPhaseState](/lwlock/two-phase-state/): Waiting to read or update the state of prepared transactions
- [LWLock: WALBufMapping](/lwlock/wal-buf-mapping/): Waiting to replace a page in WAL buffers
- [LWLock: WALInsert](/lwlock/wal-insert/): Waiting to insert WAL data into a memory buffer
- [LWLock: WALSummarizer](/lwlock/wal-summarizer/): Waiting to read or update WAL summarization state
- [LWLock: WALWrite](/lwlock/wal-write/): Waiting for WAL buffers to be written to disk
- [LWLock: WaitEventCustom](/lwlock/wait-event-custom/): Waiting to read or update custom wait events information
- [LWLock: WrapLimitsVacuum](/lwlock/wrap-limits-vacuum/): Waiting to update limits on transaction id and multixact consumption
- [LWLock: XactBuffer](/lwlock/xact-buffer/): Waiting for I/O on a transaction status SLRU buffer
- [LWLock: XactSLRU](/lwlock/xact-slru/): Waiting to access the transaction status SLRU cache
- [LWLock: XactTruncation](/lwlock/xact-truncation/): Waiting to execute pg_xact_status or update the oldest transaction ID available to it
- [LWLock: XidGen](/lwlock/xid-gen/): Waiting to allocate a new transaction ID
