'Postgreql wal archive keeps failing: archive command failed with exit code 1

I have a file that keeps failing to archive.

The failed archive command was: test ! -f /mnt/wal_archive/archivedir/00000001000003F000000072 && cp pg_wal/00000001000003F000000072 /mnt/wal_archive/archivedir/00000001000003F000000072

As instructed in other questions, I already manually deleted the file manually on the archivedir, and the file was copied again automatically, once that occurs, I start seeing the fail command again.

At the moment the file is in the pg_wal and in the archivedir. Once the file is in the archivedir shouldn't it be removed from from the pg_wal?

I'm a bit lost and out of ideas, any help would be appreciated. thanks

UPDATE: This is all I get from the logs

DETAIL: The failed archive command was: test ! -f /mnt/wal_archive/archivedir/00000001000003F000000072 && cp pg_wal/00000001000003F000000072 /mnt/wal_archive/archivedir/00000001000003F000000072

Error 2022-05-12 09:54:29.207 CEST2022-05-12 07:54:29.206 UTC [18] LOG: archive command failed with exit code 1

Error 2022-05-12 09:54:29.207 CEST2022-05-12 07:54:29.206 UTC [18] DETAIL: The failed archive command was: test ! -f /mnt/wal_archive/archivedir/00000001000003F000000072 && cp pg_wal/00000001000003F000000072 /mnt/wal_archive/archivedir/00000001000003F000000072

Error 2022-05-12 09:54:29.207 CEST2022-05-12 07:54:29.207 UTC [18] WARNING: archiving write-ahead log file "00000001000003F000000072" failed too many times, will try again later

2nd Update:

Furthermore the wal_keep_segments and the max_wal_size settings are being ignored.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source