diff options
author | Michael Paquier | 2020-04-21 23:08:28 +0000 |
---|---|---|
committer | Michael Paquier | 2020-04-21 23:08:28 +0000 |
commit | cd123234404ef9a45415060633d3be31329820b2 (patch) | |
tree | 86be45c66105a0341bda751617c48e031a585f73 | |
parent | c33869cc3bfc42bce822251f2fa1a2a346f86cc5 (diff) |
Fix single-record reads to use restore_command if available in pg_rewind
readOneRecord() is used now when looking for a checkpoint record to
check if the target server is an ancestor of the source across multiple
timelines, and using a restore_command if available improves the
stability of the operation. This part was missed in a7e8ece.
Reported-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/[email protected]
-rw-r--r-- | src/bin/pg_rewind/parsexlog.c | 4 | ||||
-rw-r--r-- | src/bin/pg_rewind/pg_rewind.c | 3 | ||||
-rw-r--r-- | src/bin/pg_rewind/pg_rewind.h | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c index 14a5db5433..c51b5db315 100644 --- a/src/bin/pg_rewind/parsexlog.c +++ b/src/bin/pg_rewind/parsexlog.c @@ -106,7 +106,8 @@ extractPageMap(const char *datadir, XLogRecPtr startpoint, int tliIndex, * doing anything with the record itself. */ XLogRecPtr -readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex) +readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex, + const char *restoreCommand) { XLogRecord *record; XLogReaderState *xlogreader; @@ -115,6 +116,7 @@ readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex) XLogRecPtr endptr; private.tliIndex = tliIndex; + private.restoreCommand = restoreCommand; xlogreader = XLogReaderAllocate(WalSegSz, datadir, &SimpleXLogPageRead, &private); if (xlogreader == NULL) diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 101f0911be..633955f7be 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -339,7 +339,8 @@ main(int argc, char **argv) /* Read the checkpoint record on the target to see where it ends. */ chkptendrec = readOneRecord(datadir_target, ControlFile_target.checkPoint, - targetNentries - 1); + targetNentries - 1, + restore_command); /* * If the histories diverged exactly at the end of the shutdown diff --git a/src/bin/pg_rewind/pg_rewind.h b/src/bin/pg_rewind/pg_rewind.h index b122ae43e5..5cf5f17bb5 100644 --- a/src/bin/pg_rewind/pg_rewind.h +++ b/src/bin/pg_rewind/pg_rewind.h @@ -50,7 +50,7 @@ extern void findLastCheckpoint(const char *datadir, XLogRecPtr searchptr, XLogRecPtr *lastchkptredo, const char *restoreCommand); extern XLogRecPtr readOneRecord(const char *datadir, XLogRecPtr ptr, - int tliIndex); + int tliIndex, const char *restoreCommand); /* in pg_rewind.c */ extern void progress_report(bool force); |