Skip to content

Avoid copying WAL segments before divergence to speed up pg_rewind #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

achanda
Copy link
Owner

@achanda achanda commented May 7, 2025

This optimization adds a conditional check to avoid unnecessarily copying WAL segment files from source to target if they are common between both servers, before the point of WAL divergence during pg_rewind.

On the source server, each WAL file's corresponding segment number is computed and compared against the segment number of the first diverged LSN. All WAL files which fall before the segment of the first diverged LSN can safely be skipped from copying to the target.

The reduction in WAL segment files transmitted over the network from source to target server massively reduces overall pg_rewind execution time when a large amount of WAL segment files are retained.

Regression tests are included to verify that WAL segment files prior to WAL divergence are not copied.

Authors: Justin Kwan, Vignesh Ravichandran

This optimization adds a conditional check to avoid unnecessarily copying
WAL segment files from source to target if they are common between both
servers, before the point of WAL divergence during pg_rewind.

On the source server, each WAL file's corresponding segment number is
computed and compared against the segment number of the first diverged LSN.
All WAL files which fall before the segment of the first diverged LSN can
safely be skipped from copying to the target.

The reduction in WAL segment files transmitted over the network from source
to target server massively reduces overall pg_rewind execution time when a
large amount of WAL segment files are retained.

Regression tests are included to verify that WAL segment files prior to WAL
divergence are not copied.

Authors: Justin Kwan, Vignesh Ravichandran
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant