What's changed: Initial version (topic G4)
4.3Replication failures and recovery
Learn how to handle failures while running replication: pg_ctl promote, which promotes a standby to primary; pg_rewind, which re-synchronizes an old primary as a standby of the new one; pg_receivewal, which continuously receives WAL directly; the conflicts unique to logical replication; and error handling for streaming replication.
Handling failures in a replication setup adds a dimension beyond single-server failure handling: how do you reorganize the primary/standby relationship? Promotion (failover) when the primary is completely lost, re-synchronizing an old primary back into the new topology, guarding against interruptions in WAL delivery, and the apply-time conflicts unique to logical replication—these concentrate much of the hands-on judgment within Gold's failure-response domain.
4.3.1Promotion and re-sync: pg_ctl promote and pg_rewind
- pg_ctl promote—the command that promotes a streaming-replication standby to become the new primary. It is the core operation of failover on primary failure: after running it, the standby exits read-only mode and begins operating as an ordinary read/write primary.
- pg_rewind—a tool that re-configures the old primary (the original primary, once recovered from its failure) as a standby following the new primary's timeline. It rewinds and re-synchronizes only the divergent portion of the WAL history between the old and new primaries, so it restores the old primary faster than rebuilding it entirely from a base backup. It does, however, require the old primary's WAL, so it must be used soon after the divergence occurs.
- pg_receivewal—a standalone client tool (formerly pg_receivexlog) that continuously receives the WAL stream from the primary and keeps saving it as files. Besides serving as a dedicated WAL archive destination, it is also used as a supplementary way to preserve WAL while normal archiving (archive_command) is not functioning for some reason.
Continue reading — free sign-up
You're reading the free preview. Sign up free to read this section in full, plus every chapter (including 4+) and all questions.

