TECHNOLOGY

Successful pg_rewind is not a completed standby rejoin

In this article
THE QUICK TAKE

Accept rejoin only after required WAL replay and the intended standby relationship are verified, not from the rewind process exit alone.

The rewind succeeds but the former primary is not ready

After failover, an operator uses pg_rewind to align the former primary with the surviving cluster. The process finishes successfully. That is a useful intermediate result, but it does not yet prove that the data directory is consistent or that startup will follow the intended primary.

The pg_rewind manual explicitly requires WAL replay after the copying stage. Its model is synchronization of divergent cluster histories, not an instant declaration that a previously writable server is safe to return to service.

Establish source and target identities

Record which server is authoritative, which directory is the rewind target and where their timelines diverged. A familiar host name is insufficient evidence after failover. Keep application traffic away from the former primary until its role is established.

The tool needs target history reaching back to divergence, potentially from the archive. Missing target WAL and missing source WAL needed for later replay are related but different prerequisites. Inventory both rather than accepting an archive’s existence as proof that every required segment is retrievable.

Verify prerequisites before modifying the target

The manual requires data checksums or wal_log_hints on the target, together with full_page_writes. Check the actual cluster’s recorded configuration and initialization state rather than assuming all installations share a contemporary default.

It also warns that failure during rewind can leave the target directory unrecoverable and recommends a fresh backup in that case. Preserve an independent recovery option. Repeatedly rerunning a failed modification against the only remaining copy is not a documented substitute for a valid recovery baseline.

Treat copied configuration as changed state

Configuration files are copied in full. Settings appropriate to the source may not describe the intended standby target. The manual warns that starting without appropriate recovery configuration can make the target diverge again.

The recovery-configuration reference distinguishes standby mode from targeted archive recovery. Verify the intended signal files, upstream connection and archive retrieval path as a coherent role configuration. Do not treat all modes that replay WAL as interchangeable future behavior.

Accept replay and role separately

In an isolated failover exercise, preserve the divergence history, rewind result, required replay availability and startup recovery evidence. Then verify that the server actually follows the intended primary and that application routing recognizes its read/write role.

Ambiguous operation reconciliation explains why a changed database role does not resolve every client-side uncertain outcome. Shared PostgreSQL workloads provides context for checking application behavior after the recovered node becomes useful again.

State what was recovered

A complete report separates file synchronization, consistent replay, replication catch-up and application re-admission. The rewind exit status certifies its own operation, not all later stages. Acceptance should identify the authoritative history and the observed standby relationship, including any unresolved application reconciliation. This prevents a fast copying operation from becoming an unsupported claim of completed service recovery.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles