postgresqlpgpool

Use of wal files in archive directory of postgres


I have a 2 node PostgreSQL 13.4 HA setup. I have kept the archive_mode=on. With this configuration the wal files are moved from pg_wal dir to archive directory. Also, I am using streaming replication for syncing the master and standby nodes.

I want to understand if a wal file is moved from pg_wal directory to the archive directory, without being replicated to the slave server (maybe due to the high creation rate of the wal files by postgres), would postgres be still able to replicate them to standby or I need to tweak my postgresql.conf to accommodate sufficient wal files in the pg_wal before shipping them to the archive directory.


Solution

  • Once the master has sent the WAL file to the archive and removed it from pg_wal, it will not try to bring it back again so that it can deliver it to the replica.

    But what you can do is configure the replica to have a restore_command which goes and fetches the file from the archive itself. That way if the replica gets denied by the master (because the file was already removed for example), it can fall back to the archive. Then once it has exhausted the archive, it will switch back to streaming.