Archiving logs to network storage/Maximize PITR

Hi,

I have yet to encounter a scenario where my archiving fails.

Yup, I agree. I don’t see this happening very often. Usually it’s something silly like a firewall rule.

How does Postgres handle a failure of the archive thread as you say with a non-zero return from the archive_command?

In the case that archive_command returns a non-zero status, which is what happens when either a C program or a bash script returns when it fails, PostgreSQL continues to operate BUT a message is recorded in the log stating that the WAL failed to ship and the WAL remains. In that case PostgreSQL will attempt to resend the WAL over and over and over … until it either gets confirmation i.e. status 0, or you’ve taken the time to correct the problem causing the issue.

For example if for some reason your script was not completely correct and that you noticed it sometime after it failed. Well, you’d have quite the collection of WALS in your wal directory. The good news is that as soon as the problem is fixed postgres will proceed to push the backlog of WALS as fast as possible and will very quickly remove them without further issue.

Hope this helps.