I had replication set up with a simple
archive_command in postgresql.conf:
archive_command = 'rsync -a %p _postgresql@serverip:/var/postgresql/wal_archive/%f'
Which worked great for 2+ years until the replica went down. After the replica went down, the archive command failed repeatedly so pg_xlog files on master were never deleted and master ran out of disk space.
In my use case the replica is nice to have but not that important. However ensuring master is always available is very important, so I'd like to use an archive command that will sacrifice the replica before problems arise on master.
I currently went to the other extreme and changed the archive_command to:
archive_command = 'rsync -a %p _postgresql@serverip:/var/postgresql/wal_archive/%f || true'
But this doesn't seem ideal either since even a few seconds of network outage could cause replication to fail.
Ideally I'd like to change the
archive_command to something that will try to copy the WAL file to the replica a certain number of times, and if that fails, give up and remove the pg_xlog file. Any suggestions for a new