LWLock: WALWrite
Waiting for WAL buffers to be written to disk
PostgreSQL wait event dossier
ClassLWLock
Event
WALWrite
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting for WAL buffers to be written to disk
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
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.
Normal or trouble?
- Normal: Brief waits occur when concurrent committers help write WAL.
- Investigate: Sustained WALWrite with commit latency usually means the WAL write path is slow or cannot absorb the generated WAL rate.
Diagnostic SQL
Sessions waiting on LWLock/WALWrite
Current LWLock cohort
Lock and relation context for these sessions
Response
- 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.
Source evidence
- PostgreSQL 18.6 · src/backend/access/transam/xlog.c:2047 —
WALWrite - PostgreSQL 18.6 · src/backend/storage/lmgr/lwlock.c:739 —
pgstat_report_wait_start - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:320 —
WALWrite
Related controls and signals
- GUCs: [guc:wal_writer_delay] · [guc:wal_writer_flush_after] · [guc:synchronous_commit]
- Metrics: [metric:waiting_sessions] · [metric:wait_event_share] · [metric:wal_write_time] · [metric:wal_sync_time] · [metric:commit_latency]
Typical incident pattern
A cloud volume hits its burst-credit ceiling; WAL writes lengthen, committers queue on WALWrite, and synchronous commits slow together.