This is the multi-page printable view of this section. .
BufferPin waits
BufferPin has one core event, also named BufferPin. It means PostgreSQL needs exclusive access to a shared buffer but another backend still pins that page so it cannot be removed or structurally changed.
Treat persistence as suspicious
Pins are normal and short-lived while executors inspect pages. A sustained exclusive-pin wait is unusual and can come from another session holding a cursor open, an executor paused on a page, or concurrent index work that needs to delete/recycle the page.
- Normal: isolated, sub-second samples during scans or index maintenance.
- Watch: the same foreground session remains on BufferPin for more than one second.
- Urgent: many sessions queue, index cleanup/DDL cannot advance, or a cursor-owning session is idle while holding the pin.
What to inspect
- Identify the waiting query and its relation locks.
- Look for long-running cursors,
idle in transaction, and executor sessions touching the same relation. - Correlate the onset with
VACUUM, index deletion/recycling, DDL, or long scans. - Preserve the holder’s query and transaction context before cancelling anything.
Common misreads
- A buffer pin is not a heavyweight lock and has no direct owner row in
pg_locks. shared_bufferssize does not make a held pin disappear.- The waiter may be vacuum/index maintenance while the application session holding the pin looks harmless.
1 - BufferPin: BufferPin
BufferPin
VersionsPG 13-18
Evidence2 source location(s)
Official description
Waiting to acquire an exclusive pin on a buffer
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
WAIT_EVENT_BUFFER_PIN at src/backend/storage/buffer/bufmgr.c:5819 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:286. The instrumented operation is: Waiting to acquire an exclusive pin on a buffer. The buffer manager needs an exclusive pin, but another backend still holds a pin on the same shared buffer. It sleeps until the last conflicting pin is released.
Normal or trouble?
- Normal: An isolated sub-second sample can occur during scans or index maintenance.
- Investigate: Treat a wait beyond one second as suspicious, especially when a cursor or idle transaction may keep the page pinned.
Diagnostic SQL
Response
- Preserve the waiting query and relation context.
- Find long cursors and idle-in-transaction sessions touching the same relation.
- Cancel only after identifying the safest holder or maintenance victim.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/buffer/bufmgr.c:5819 —
WAIT_EVENT_BUFFER_PIN - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:286 —
BUFFER_PIN
Related controls and signals
- GUCs: None directly.
- Metrics: [metric:waiting_sessions] · [metric:wait_event_share]