Avoid copying WAL segments before divergence to speed up pg_rewind #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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