database runtime_error ai_generated true

ERROR: archive command failed with exit code 1: cp pg_wal/000000010000000000000001 /archive/000000010000000000000001

ID: database/postgresql-wal-archiver-failed

Also available as: JSON · Markdown · 中文
82%Fix Rate
88%Confidence
1Evidence
2023-09-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
PostgreSQL 14.x active
PostgreSQL 15.x active
PostgreSQL 16.x active

Root Cause

The PostgreSQL archiver process fails to copy WAL segments to the archive destination, typically due to disk full, permission issues, or missing directory.

generic

中文

PostgreSQL 归档进程无法将 WAL 段复制到归档目标,通常由于磁盘满、权限问题或缺少目录。

Official Documentation

https://www.postgresql.org/docs/16/continuous-archiving.html

Workarounds

  1. 80% success Check disk space and permissions: df -h /archive; ls -ld /archive; then ensure the archive directory exists: mkdir -p /archive && chown postgres:postgres /archive
    Check disk space and permissions: df -h /archive; ls -ld /archive; then ensure the archive directory exists: mkdir -p /archive && chown postgres:postgres /archive
  2. 85% success Test the archive command manually: su - postgres -c 'cp /var/lib/postgresql/16/main/pg_wal/000000010000000000000001 /archive/000000010000000000000001' and fix errors (e.g., SELinux context).
    Test the archive command manually: su - postgres -c 'cp /var/lib/postgresql/16/main/pg_wal/000000010000000000000001 /archive/000000010000000000000001' and fix errors (e.g., SELinux context).

中文步骤

  1. 检查磁盘空间和权限:df -h /archive; ls -ld /archive;然后确保归档目录存在:mkdir -p /archive && chown postgres:postgres /archive
  2. 手动测试归档命令:su - postgres -c 'cp /var/lib/postgresql/16/main/pg_wal/000000010000000000000001 /archive/000000010000000000000001' 并修复错误(例如 SELinux 上下文)。

Dead Ends

Common approaches that don't work:

  1. Restarting PostgreSQL without fixing the archive destination 95% fail

    Restarting does not resolve the underlying issue; the archiver will continue to fail on the next WAL segment.

  2. Setting archive_mode to off to stop archiving 90% fail

    Disabling archiving can lead to WAL accumulation and potential data loss in case of a disaster recovery scenario.