summaryrefslogtreecommitdiff
path: root/src/bin/pg_rewind/filemap.h
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-10-25 09:07:31 +0900
committerMichael Paquier <michael@paquier.xyz>2025-10-25 09:07:31 +0900
commit5173bfd0443e0c0f3fa37006727d516dc1ba4cee (patch)
treedb570500673c70d6608c5bcd806c3a75d52cba21 /src/bin/pg_rewind/filemap.h
parent14ee8e6403001c3788f2622cdcf81a8451502dc2 (diff)
pg_rewind: Skip copy of WAL segments generated before point of divergence
This commit makes the way WAL segments are handled from the source to the target server slightly smarter: the copy of the WAL segments is now skipped if these have been created before the point where source and target have diverged (the WAL segment where the point of divergence exists is still copied), because we know that such segments exist on both the target and source. Note that the on-disk size of the WAL segments on the source and target need to match. Hence, only the segments generated after the point of divergence are now copied. A segment existing on the source but not the target is copied. Previously, all the WAL segments were just copied in full. This change can make the rewind operation cheaper in some configurations, especially for setups where some WAL retention causes many segments to remain on the source server even after the promotion of a standby used as source to rewind a previous primary. A TAP test is added to track these new behaviors. The file map printed with --debug now includes all the information related to WAL segments, to be able to track if these are copied or skipped, and the test relies on the debug output generated. Author: John Hsu <johnhyvr@gmail.com> Author: Justin Kwan <justinpkwan@outlook.com> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> Reviewed-by: Japin Li <japinli@hotmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com> Discussion: https://postgr.es/m/181b4c6fa9c.b8b725681941212.7547232617810891479@viggy28.dev
Diffstat (limited to 'src/bin/pg_rewind/filemap.h')
-rw-r--r--src/bin/pg_rewind/filemap.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/bin/pg_rewind/filemap.h b/src/bin/pg_rewind/filemap.h
index fada420fc23..5145f0b4c46 100644
--- a/src/bin/pg_rewind/filemap.h
+++ b/src/bin/pg_rewind/filemap.h
@@ -11,6 +11,7 @@
#include "datapagemap.h"
#include "storage/block.h"
#include "storage/relfilelocator.h"
+#include "access/xlogdefs.h"
/* these enum values are sorted in the order we want actions to be processed */
typedef enum
@@ -113,7 +114,7 @@ extern void process_target_wal_block_change(ForkNumber forknum,
RelFileLocator rlocator,
BlockNumber blkno);
-extern filemap_t *decide_file_actions(void);
+extern filemap_t *decide_file_actions(XLogSegNo last_common_segno);
extern void calculate_totals(filemap_t *filemap);
extern void print_filemap(filemap_t *filemap);