Search code examples
postgresqlpgbackrest

Does PostgreSQL Replica Server Generate WAL Files?


My setup with PostgreSQL 14 streaming replication, includes pgBackRest for archiving to a dedicated repository server. Both archive commands and archive recovery work from this repository. Despite the setup with pgBackRest and a dedicated repository server, the replica server is generating its own WAL files. I expect the replica to apply WALs from the repository server as needed, not generate its own.


Solution

  • The standby does not generate WAL, it writes copies of the primary's WAL segments that get filled with the data streamed from the primary.

    These WAL files serve two purposes:

    1. they allow the standby to recover from a crash during recovery

    2. they buffer WAL that has been received from the primary but cannot be replayed yet because of a replication conflict

    If the WAL on the standby grows large, replay must be delayed. See this article for more details about replication conflicts.