database system_error ai_generated true

错误:归档命令失败,退出代码为1 详细信息:归档命令是:cp %p /archive/%f

ERROR: archive command failed with exit code 1 DETAIL: The archive command was: cp %p /archive/%f

ID: database/postgres-wal-archive-failure

其他格式: JSON · Markdown 中文 · English
85%修复率
85%置信度
1证据数
2023-06-20首次发现

版本兼容性

版本状态引入弃用备注
PostgreSQL 14 active
PostgreSQL 15 active
PostgreSQL 16 active

根因分析

PostgreSQL WAL归档命令因磁盘空间不足、权限问题或归档目标路径不正确而失败。

English

PostgreSQL WAL archiving command fails due to insufficient disk space, permission issues, or incorrect archive destination path.

generic

官方文档

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

解决方案

  1. Check disk space on archive destination: df -h /archive; if full, free space or increase archive destination mount size.
  2. Fix permissions on archive directory: chown -R postgres:postgres /archive; chmod 700 /archive;
  3. Test the archive command manually: sudo -u postgres cp /var/lib/postgresql/16/main/pg_wal/000000010000000000000001 /archive/; then fix any errors.

无效尝试

常见但无效的做法:

  1. Increase wal_keep_segments to a very high value to avoid archiving 60% 失败

    This only delays the problem; WAL segments still accumulate and eventually fill pg_wal, causing PostgreSQL to crash.

  2. Set archive_mode=off to disable archiving entirely 90% 失败

    Disabling archiving breaks point-in-time recovery and replication; not a viable fix for production systems that require backups.