{
  "id": "database/temp-file-limit-exceeded",
  "signature": "psycopg2.OperationalError: ERROR: could not create temporary file: No space left on device HINT: You might need to increase the max_files_per_process limit.",
  "signature_zh": "psycopg2.OperationalError: 错误：无法创建临时文件：设备上没有剩余空间 提示：您可能需要增加 max_files_per_process 限制。",
  "regex": "could not create temporary file: No space left on device",
  "domain": "database",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "PostgreSQL has exhausted either disk space in the temporary file directory or the kernel's file descriptor limit, preventing the creation of temporary files for query execution.",
  "root_cause_type": "generic",
  "root_cause_zh": "PostgreSQL 已耗尽了临时文件目录中的磁盘空间或内核的文件描述符限制，导致无法为查询执行创建临时文件。",
  "versions": [
    {
      "version": "PostgreSQL 12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PostgreSQL 13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PostgreSQL 14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PostgreSQL 15",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PostgreSQL 16",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increase max_files_per_process in postgresql.conf without checking disk space",
      "why_fails": "The error is usually caused by full disk, not file descriptor limit; raising max_files_per_process won't free disk space",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Delete random files from pg_tblspc thinking they are temporary",
      "why_fails": "pg_tblspc contains symbolic links to tablespaces; deleting them can corrupt the database",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Restart PostgreSQL without clearing temp files",
      "why_fails": "Restarting doesn't reclaim disk space; the underlying issue of full disk or exhausted inodes remains",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check disk usage with `df -h` and `df -i` on the partition containing pg_stat_tmp and base directory. Free space by removing old WAL files or archiving logs: `pg_archivecleanup /path/to/archive $(ls -t /path/to/archive | tail -1)`",
      "success_rate": 0.8,
      "how": "Check disk usage with `df -h` and `df -i` on the partition containing pg_stat_tmp and base directory. Free space by removing old WAL files or archiving logs: `pg_archivecleanup /path/to/archive $(ls -t /path/to/archive | tail -1)`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add more disk space or mount a larger volume to the temporary directory. Then, restart PostgreSQL or set temp_tablespaces to a tablespace on a volume with sufficient space: `ALTER SYSTEM SET temp_tablespaces = 'fast_disk'; SELECT pg_reload_conf();`",
      "success_rate": 0.85,
      "how": "Add more disk space or mount a larger volume to the temporary directory. Then, restart PostgreSQL or set temp_tablespaces to a tablespace on a volume with sufficient space: `ALTER SYSTEM SET temp_tablespaces = 'fast_disk'; SELECT pg_reload_conf();`",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the issue is file descriptor limits, increase max_files_per_process in postgresql.conf and restart: `ALTER SYSTEM SET max_files_per_process = 2000;` then restart the server",
      "success_rate": 0.7,
      "how": "If the issue is file descriptor limits, increase max_files_per_process in postgresql.conf and restart: `ALTER SYSTEM SET max_files_per_process = 2000;` then restart the server",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用 `df -h` 和 `df -i` 检查包含 pg_stat_tmp 和 base 目录的分区磁盘使用情况。通过删除旧的 WAL 文件或归档日志来释放空间：`pg_archivecleanup /path/to/archive $(ls -t /path/to/archive | tail -1)`",
    "向临时目录添加更多磁盘空间或挂载更大的卷。然后重启 PostgreSQL，或将 temp_tablespaces 设置为空间充足的卷上的表空间：`ALTER SYSTEM SET temp_tablespaces = 'fast_disk'; SELECT pg_reload_conf();`",
    "如果问题是文件描述符限制，在 postgresql.conf 中增加 max_files_per_process 并重启：`ALTER SYSTEM SET max_files_per_process = 2000;` 然后重启服务器"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.postgresql.org/docs/current/runtime-config-resource.html#GUC-MAX-FILES-PER-PROCESS",
  "official_doc_section": null,
  "error_code": "53100",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-06-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}