{"Entry":{"collection":"waitevent","key":"lwlock/ProcArray","name":"ProcArray","aliases":["ProcArray","ProcArrayLock"],"metadata":{"aliases":["ProcArray","ProcArrayLock"],"changed_in":["10","13"],"changes":[{"from":"9.6","moved":{"from":"LWLockNamed","to":"LWLock"},"renamed":null,"reworded":null,"status":"changed","to":"10"},{"from":"12","moved":null,"renamed":{"from":"ProcArrayLock","to":"ProcArray"},"reworded":{"from":"Waiting to get a snapshot or clearing a transaction id at transaction end.","to":"Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID)."},"status":"changed","to":"13"}],"content_hash":"39f7938c25059da3ccd70f5f2f5bc4a14a71c5c256ef3b20e900e8eec90764c2","dossier":{"actions":{"en":["Measure active backends and transaction age, not only total connections.","Find long-running and idle-in-transaction sessions that keep visibility horizons old.","Pool connections, shorten transactions, and avoid synchronized bursts of tiny transactions."],"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 = 'LWLock'\n  AND wait_event = 'ProcArray'\nORDER BY query_age DESC NULLS LAST;","title":"Sessions waiting on LWLock/ProcArray","title_zh":"正在等待 LWLock/ProcArray 的会话"},{"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 = 'LWLock'\nGROUP BY wait_event\nORDER BY waiting_sessions DESC, wait_event;","title":"Current LWLock cohort","title_zh":"当前 LWLock 等待分布"},{"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 = 'LWLock'\n  AND a.wait_event = 'ProcArray'\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"},"gucs":["max_connections","idle_in_transaction_session_timeout"],"incident_pattern":{"en":"An application reconnect storm creates thousands of short transactions while a reporting query holds an old snapshot, amplifying ProcArray traffic.","zh":"应用重连风暴制造数千个短事务，同时报表查询持有旧快照，放大了 ProcArray 流量。"},"mechanism":{"en":"ProcArrayLock protects the shared PGPROC/PGXACT arrays used for snapshots, transaction visibility, and transaction end. Snapshot acquisition and updates to process transaction state must briefly coordinate through it.","zh":"ProcArrayLock 保护用于快照、事务可见性与事务结束处理的共享 PGPROC/PGXACT 数组。获取快照以及更新进程事务状态都必须短暂经过它协调。"},"metrics":["waiting_sessions","wait_event_share","active_backends","oldest_transaction_age"],"normal":{"en":"Brief waits are expected on busy OLTP systems that start and finish many transactions.","zh":"大量事务开始与结束的繁忙 OLTP 系统中，短暂等待属于预期。"},"official_descriptions":{"13":"Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID).","14":"Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID).","15":"Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID).","16":"Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID).","17":"Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID)","18":"Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID)"},"record_kind":"event","source_locations":[{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","excerpt":"LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);","grep_pattern":"ProcArray","grep_verified":true,"kind":"resource_path","line":6121,"major":18,"path":"src/backend/access/transam/xlog.c","status":"dynamic_trigger","symbol":"ProcArray","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/REL_18_6/src/backend/access/transam/xlog.c#L6121","version":"18.6"},{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","excerpt":"pgstat_report_wait_start(PG_WAIT_LWLOCK | lock-\u003etranche);","grep_pattern":"pgstat_report_wait_start","grep_verified":true,"kind":"generic_reporter","line":739,"major":18,"path":"src/backend/storage/lmgr/lwlock.c","status":"dynamic_trigger","symbol":"pgstat_report_wait_start","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/REL_18_6/src/backend/storage/lmgr/lwlock.c#L739","version":"18.6"},{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","excerpt":"ProcArray\t\"Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID).\"","grep_pattern":"ProcArray","grep_verified":true,"kind":"catalog_definition","line":316,"major":18,"path":"src/backend/utils/activity/wait_event_names.txt","status":"dynamic_trigger","symbol":"ProcArray","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/REL_18_6/src/backend/utils/activity/wait_event_names.txt#L316","version":"18.6"}],"source_status":"dynamic_trigger","trouble":{"en":"Persistent contention can accompany extreme connection counts, snapshot-heavy workloads, long transactions, or bursts of transaction completion.","zh":"持续竞争可能伴随极高连接数、大量快照、长事务，或事务集中结束。"}},"first_version":"9.6","has_dossier":true,"imported_at":"2026-09-27T17:57:32.986759+08:00","key":"lwlock/procarray","last_version":"20","name":"ProcArray","position":256,"present_in":["9.6","10","11","12","13","14","15","16","17","18","19","20"],"slug":"proc-array","source_rev":"english-manuals:84be1ae4cc9436680a7bb1d31d8fdcf4676ebebdc10959830e14a8ee91716eab","summary":"Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID).","summary_zh":"","type":"LWLock","type_slug":"lwlock","type_variants":["LWLock","LWLockNamed"]}},"Definition":{"Collection":"waitevent","Key":"lwlock/ProcArray","SourceDatabase":"center","Version":"18","SourceTable":"waitevent","SourceKey":"lwlock/procarray","SourceRevision":"english-manuals:84be1ae4cc9436680a7bb1d31d8fdcf4676ebebdc10959830e14a8ee91716eab","Facts":{"description":"Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID).","description_zh":"","doc":{"anchor":"WAIT-EVENT-LWLOCK-TABLE","file":"monitoring-stats.html","lang":"en","sha256":"aa979eed08627fbf715a9d792094a162a73671db5af810f3ab2aad3e073d5722","slug":"18"},"lang":"en","name":"ProcArray","source":"english-manual","type":"LWLock","zh_from":""},"ManualEvidence":{"doc":{"anchor":"WAIT-EVENT-LWLOCK-TABLE","file":"monitoring-stats.html","lang":"en","sha256":"aa979eed08627fbf715a9d792094a162a73671db5af810f3ab2aad3e073d5722","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"waitevent","Key":"lwlock/ProcArray","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"ProcArray","Summary":"等待访问各进程的共享数据结构（通常是为了获取快照或报告会话的事务 ID）。","BodyHTML":"\u003cp\u003e等待访问各进程的共享数据结构（通常是为了获取快照或报告会话的事务 ID）。\u003c/p\u003e","SourceRevision":"2026-08-31@34d13c8","ContentHash":"c5a3bcba67d4e71084a16b56444d3115a3fa9f466d61bd6edfddc73894a93ca8","Payload":{"description_zh":"等待访问各进程的共享数据结构（通常是为了获取快照或报告会话的事务 ID）。","zh_from":"doc"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
