{"Entry":{"collection":"waitevent","key":"lwlock/WALWrite","name":"WALWrite","aliases":["WALWrite","WALWriteLock"],"metadata":{"aliases":["WALWrite","WALWriteLock"],"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":"WALWriteLock","to":"WALWrite"},"reworded":null,"status":"changed","to":"13"}],"content_hash":"81668d81992e6fc131e43beb43d9058dbdd37a564a79cd0efa3e0fe29a8daa6d","dossier":{"actions":{"en":["Compare WAL write and sync time with commit latency.","Check the WAL filesystem/device, virtualization throttling, and checkpoint overlap.","Reduce burstiness; tune wal_writer settings only after storage evidence confirms the path."],"zh":["把 WAL write/sync 时间与提交延迟对照。","检查 WAL 文件系统/设备、虚拟化限速与检查点重叠。","降低突发性；只有存储证据确认后才调整 wal_writer 参数。"]},"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 = 'WALWrite'\nORDER BY query_age DESC NULLS LAST;","title":"Sessions waiting on LWLock/WALWrite","title_zh":"正在等待 LWLock/WALWrite 的会话"},{"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 = 'WALWrite'\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":["wal_writer_delay","wal_writer_flush_after","synchronous_commit"],"incident_pattern":{"en":"A cloud volume hits its burst-credit ceiling; WAL writes lengthen, committers queue on WALWrite, and synchronous commits slow together.","zh":"云盘耗尽突发积分，WAL 写入变长，提交会话在 WALWrite 上排队，同步提交延迟同步恶化。"},"mechanism":{"en":"WALWriteLock serializes progress that writes shared WAL buffers and advances the written/flushed WAL positions. A waiter is queued behind the backend currently performing or coordinating that work.","zh":"WALWriteLock 串行化共享 WAL 缓冲区写入，以及 written/flushed 位置的推进。等待者正在当前执行或协调这项工作的后端之后排队。"},"metrics":["waiting_sessions","wait_event_share","wal_write_time","wal_sync_time","commit_latency"],"normal":{"en":"Brief waits occur when concurrent committers help write WAL.","zh":"多个提交者协助写 WAL 时会短暂出现。"},"official_descriptions":{"13":"Waiting for WAL buffers to be written to disk.","14":"Waiting for WAL buffers to be written to disk.","15":"Waiting for WAL buffers to be written to disk.","16":"Waiting for WAL buffers to be written to disk.","17":"Waiting for WAL buffers to be written to disk","18":"Waiting for WAL buffers to be written to disk"},"record_kind":"event","source_locations":[{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","excerpt":"LWLockAcquire(WALWriteLock, LW_EXCLUSIVE);","grep_pattern":"WALWrite","grep_verified":true,"kind":"resource_path","line":2047,"major":18,"path":"src/backend/access/transam/xlog.c","status":"dynamic_trigger","symbol":"WALWrite","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/REL_18_6/src/backend/access/transam/xlog.c#L2047","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":"WALWrite\t\"Waiting for WAL buffers to be written to disk.\"","grep_pattern":"WALWrite","grep_verified":true,"kind":"catalog_definition","line":320,"major":18,"path":"src/backend/utils/activity/wait_event_names.txt","status":"dynamic_trigger","symbol":"WALWrite","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/REL_18_6/src/backend/utils/activity/wait_event_names.txt#L320","version":"18.6"}],"source_status":"dynamic_trigger","trouble":{"en":"Sustained WALWrite with commit latency usually means the WAL write path is slow or cannot absorb the generated WAL rate.","zh":"WALWrite 持续出现且提交延迟上升，通常表示 WAL 写路径变慢，或吞吐跟不上 WAL 生成速度。"}},"first_version":"9.6","has_dossier":true,"imported_at":"2026-09-27T17:57:33.082591+08:00","key":"lwlock/walwrite","last_version":"20","name":"WALWrite","position":286,"present_in":["9.6","10","11","12","13","14","15","16","17","18","19","20"],"slug":"wal-write","source_rev":"english-manuals:be8d14efd552f75c470f45563f8b1549a2aeaa6fb85b33687a34a856e9e5e684","summary":"Waiting for WAL buffers to be written to disk.","summary_zh":"","type":"LWLock","type_slug":"lwlock","type_variants":["LWLock","LWLockNamed"]}},"Definition":{"Collection":"waitevent","Key":"lwlock/WALWrite","SourceDatabase":"center","Version":"18","SourceTable":"waitevent","SourceKey":"lwlock/walwrite","SourceRevision":"english-manuals:be8d14efd552f75c470f45563f8b1549a2aeaa6fb85b33687a34a856e9e5e684","Facts":{"description":"Waiting for WAL buffers to be written to disk.","description_zh":"","doc":{"anchor":"WAIT-EVENT-LWLOCK-TABLE","file":"monitoring-stats.html","lang":"en","sha256":"aa979eed08627fbf715a9d792094a162a73671db5af810f3ab2aad3e073d5722","slug":"18"},"lang":"en","name":"WALWrite","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/WALWrite","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"WALWrite","Summary":"等待WAL缓冲区写入磁盘。","BodyHTML":"\u003cp\u003e等待WAL缓冲区写入磁盘。\u003c/p\u003e","SourceRevision":"2026-08-31@34d13c8","ContentHash":"4de3d66de0047cadaf3205decce8636207a4882d3c153643538a46f779a0c756","Payload":{"description_zh":"等待WAL缓冲区写入磁盘。","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}
