ERROR database storage_error ai_generated true

ERROR: could not write to file "base/16384/12345": No space left on device

ID: database/disk-full

Also available as: JSON · Markdown
88%Fix Rate
90%Confidence
45Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
16 active

Root Cause

The filesystem containing PostgreSQL's data directory is full. Writes fail including WAL, temp files, and table data. PostgreSQL may become read-only or crash. Caused by table bloat, excessive WAL retention, large temp files, or insufficient disk provisioning.

generic

Workarounds

  1. 90% success Free disk space by removing non-essential files, then run maintenance
    1) Remove old log files: find /var/log/postgresql -name '*.log' -mtime +7 -delete. 2) Clear temp files. 3) Drop unused tables or indexes. 4) Once some space is available, run regular VACUUM (not FULL) on bloated tables. 5) Check pg_wal size and adjust wal_keep_size if excessive.
  2. 85% success Move tablespaces or WAL to a different volume with available space
    Create a tablespace on a volume with space: CREATE TABLESPACE extra_space LOCATION '/mnt/extra/pgdata'; Move large tables: ALTER TABLE big_table SET TABLESPACE extra_space; For WAL, symlink pg_wal to a larger volume (requires stop/start).

Dead Ends

Common approaches that don't work:

  1. Running VACUUM FULL on large tables when the disk is already completely full 95% fail

    VACUUM FULL needs to create a complete copy of the table before dropping the old one. When disk is at 100%, there is no space for the copy and the operation fails immediately or makes things worse.

  2. Deleting PostgreSQL WAL files manually from pg_wal directory 85% fail

    Manually deleting WAL segments can corrupt the database and prevent recovery. PostgreSQL tracks which WAL files are needed; removing them without pg_archivecleanup causes data loss.

Error Chain

Leads to:
Preceded by:
Frequently confused with: