{"Entry":{"collection":"waitevent","key":"buffer/BufferPin","name":"BufferPin","aliases":["BufferPin"],"metadata":{"aliases":["BufferPin"],"changed_in":["13"],"changes":[{"from":"12","moved":null,"renamed":null,"reworded":{"from":"Waiting to acquire a pin on a buffer.","to":"Waiting to acquire an exclusive pin on a buffer."},"status":"changed","to":"13"},{"from":"18","moved":null,"renamed":null,"reworded":null,"status":"removed","to":"19"}],"content_hash":"d225ff1a1a04f34427abe456287dc24afb670827ca88ab4cb3fe3e73c060e513","dossier":{"actions":{"en":["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."],"zh":["保全等待查询与关系上下文。","查找访问同一关系的长游标与 idle in transaction 会话。","确认最安全的持有者或维护受害者后再取消。"]},"diagnostic_sql":[{"id":"sessions","min_version":"13","sql":"SELECT pid, backend_type, usename, datname, application_name,\n       state, now() - query_start AS query_age,\n       now() - xact_start AS xact_age,\n       wait_event_type, wait_event,\n       pg_blocking_pids(pid) AS blocking_pids,\n       left(query, 160) AS query\nFROM pg_stat_activity\nWHERE wait_event_type = 'BufferPin'\n  AND wait_event = 'BufferPin'\nORDER BY query_age DESC NULLS LAST;","title":"Sessions waiting on BufferPin/BufferPin","title_zh":"正在等待 BufferPin/BufferPin 的会话"},{"id":"cohort","min_version":"13","sql":"SELECT wait_event, count(*) AS waiting_sessions,\n       count(*) FILTER (WHERE state = 'active') AS active_waiters,\n       max(now() - query_start) AS oldest_query\nFROM pg_stat_activity\nWHERE wait_event_type = 'BufferPin'\nGROUP BY wait_event\nORDER BY waiting_sessions DESC, wait_event;","title":"Current BufferPin cohort","title_zh":"当前 BufferPin 等待分布"},{"id":"lock_objects","min_version":"13","sql":"SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,\n       d.datname, n.nspname, c.relname,\n       l.page, l.tuple, l.virtualxid, l.transactionid,\n       l.classid, l.objid, l.objsubid\nFROM pg_stat_activity AS a\nLEFT JOIN pg_locks AS l ON l.pid = a.pid\nLEFT JOIN pg_database AS d ON d.oid = l.database\nLEFT JOIN pg_class AS c\n  ON c.oid = l.relation\n AND l.database = (\n       SELECT oid FROM pg_database WHERE datname = current_database()\n     )\nLEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace\nWHERE a.wait_event_type = 'BufferPin'\n  AND a.wait_event = 'BufferPin'\nORDER BY a.pid, l.granted, l.locktype, l.mode;","title":"Lock and relation context for these sessions","title_zh":"这些会话的锁与关系上下文"}],"emission":{"status":"active","verified_release":"18.6"},"incident_pattern":{"en":"","zh":""},"mechanism":{"en":"`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.","zh":"`WAIT_EVENT_BUFFER_PIN` 位于 `src/backend/storage/buffer/bufmgr.c:5819`，是经 grep 核验的报告路径。公共身份/资源映射位于 `src/backend/utils/activity/wait_event_names.txt:286`。探针覆盖的操作是：等待获取 buffer 上的独占 pin。缓冲区管理器需要独占 pin，但另一个后端仍在同一共享缓冲区上持有 pin；当前后端会休眠到最后一个冲突 pin 被释放。"},"metrics":["waiting_sessions","wait_event_share"],"normal":{"en":"An isolated sub-second sample can occur during scans or index maintenance.","zh":"扫描或索引维护期间，孤立的亚秒级样本可能正常。"},"official_descriptions":{"13":"Waiting to acquire an exclusive pin on a buffer.","14":"Waiting to acquire an exclusive pin on a buffer.","15":"Waiting to acquire an exclusive pin on a buffer.","16":"Waiting to acquire an exclusive pin on a buffer.","17":"Waiting to acquire an exclusive pin on a buffer","18":"Waiting to acquire an exclusive pin on a buffer"},"record_kind":"event","source_locations":[{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","excerpt":"ProcWaitForSignal(WAIT_EVENT_BUFFER_PIN);","grep_pattern":"WAIT_EVENT_BUFFER_PIN","grep_verified":true,"kind":"trigger","line":5819,"major":18,"path":"src/backend/storage/buffer/bufmgr.c","status":"live_trigger","symbol":"WAIT_EVENT_BUFFER_PIN","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/REL_18_6/src/backend/storage/buffer/bufmgr.c#L5819","version":"18.6"},{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","excerpt":"BUFFER_PIN\t\"Waiting to acquire an exclusive pin on a buffer.\"","grep_pattern":"BUFFER_PIN","grep_verified":true,"kind":"catalog_definition","line":286,"major":18,"path":"src/backend/utils/activity/wait_event_names.txt","status":"live_trigger","symbol":"BUFFER_PIN","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/REL_18_6/src/backend/utils/activity/wait_event_names.txt#L286","version":"18.6"}],"source_status":"live_trigger","trouble":{"en":"Treat a wait beyond one second as suspicious, especially when a cursor or idle transaction may keep the page pinned.","zh":"等待超过一秒就值得怀疑，尤其要检查游标或空闲事务是否持续钉住页面。"}},"first_version":"9.6","has_dossier":true,"imported_at":"2026-09-27T17:57:32.507954+08:00","key":"buffer/bufferpin","last_version":"18","name":"BufferPin","position":22,"present_in":["9.6","10","11","12","13","14","15","16","17","18"],"slug":"buffer-pin","source_rev":"english-manuals:427e1b9871728919ccc1cc87568ee2ea151769d5fde16a99965fcf03dd9d9903","summary":"Waiting to acquire an exclusive pin on a buffer.","summary_zh":"","type":"Buffer","type_slug":"buffer","type_variants":["BufferPin"]}},"Definition":{"Collection":"waitevent","Key":"buffer/BufferPin","SourceDatabase":"center","Version":"18","SourceTable":"waitevent","SourceKey":"buffer/bufferpin","SourceRevision":"english-manuals:427e1b9871728919ccc1cc87568ee2ea151769d5fde16a99965fcf03dd9d9903","Facts":{"description":"Waiting to acquire an exclusive pin on a buffer.","description_zh":"","doc":{"anchor":"WAIT-EVENT-BUFFERPIN-TABLE","file":"monitoring-stats.html","lang":"en","sha256":"aa979eed08627fbf715a9d792094a162a73671db5af810f3ab2aad3e073d5722","slug":"18"},"lang":"en","name":"BufferPin","source":"english-manual","type":"BufferPin","zh_from":""},"ManualEvidence":{"doc":{"anchor":"WAIT-EVENT-BUFFERPIN-TABLE","file":"monitoring-stats.html","lang":"en","sha256":"aa979eed08627fbf715a9d792094a162a73671db5af810f3ab2aad3e073d5722","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"waitevent","Key":"buffer/BufferPin","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"BufferPin","Summary":"等待获得缓冲区上的独占钉住。","BodyHTML":"\u003cp\u003e等待获得缓冲区上的独占钉住。\u003c/p\u003e","SourceRevision":"2026-08-31@34d13c8","ContentHash":"b3ce6bc3037860caa0b03e884fbcda49c75260f776ce252504392ec26ad5bea1","Payload":{"description_zh":"等待获得缓冲区上的独占钉住。","zh_from":"doc"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
