1

Let's say that I configured streaming replication between Server A (master) and Server B (slave). If server A goes down and Server B is promoted, would I be able to use pg_rewind, where Server B is the source and Server A is the target, to bring Server A back up up to speed with Server B? According to the documentation regarding pg_rewind:

The result is equivalent to replacing the target data directory with the source one.

I assume that the rewind wouldn't "rewind" anything, but since:

When the target server is started for the first time after running pg_rewind, it will go into recovery mode and replay all WAL generated in the source server after the point of divergence.

wouldn't I just be able to place server A in recovery mode and recover all the WAL segments generated by Server B, even though they are on different timelines?

Thanks!

1 Answer 1

1

You often need pg_rewind because the standby server that got promoted might have been a few transactions behind the broken primary server. This can even happen with synchronous replication.

pg_rewind undoes these few transactions by replacing all affected blocks with blocks from the promoted (source) server. That is also why recovery will start from the last common checkpoint of both servers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.