Commit cd123234 authored by Michael Paquier's avatar Michael Paquier

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 a7e8ece4.

Reported-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/20200421.150830.1410714948345179794.horikyota.ntt@gmail.com
parent c33869cc
...@@ -106,7 +106,8 @@ extractPageMap(const char *datadir, XLogRecPtr startpoint, int tliIndex, ...@@ -106,7 +106,8 @@ extractPageMap(const char *datadir, XLogRecPtr startpoint, int tliIndex,
* doing anything with the record itself. * doing anything with the record itself.
*/ */
XLogRecPtr XLogRecPtr
readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex) readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex,
const char *restoreCommand)
{ {
XLogRecord *record; XLogRecord *record;
XLogReaderState *xlogreader; XLogReaderState *xlogreader;
...@@ -115,6 +116,7 @@ readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex) ...@@ -115,6 +116,7 @@ readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex)
XLogRecPtr endptr; XLogRecPtr endptr;
private.tliIndex = tliIndex; private.tliIndex = tliIndex;
private.restoreCommand = restoreCommand;
xlogreader = XLogReaderAllocate(WalSegSz, datadir, &SimpleXLogPageRead, xlogreader = XLogReaderAllocate(WalSegSz, datadir, &SimpleXLogPageRead,
&private); &private);
if (xlogreader == NULL) if (xlogreader == NULL)
......
...@@ -339,7 +339,8 @@ main(int argc, char **argv) ...@@ -339,7 +339,8 @@ main(int argc, char **argv)
/* Read the checkpoint record on the target to see where it ends. */ /* Read the checkpoint record on the target to see where it ends. */
chkptendrec = readOneRecord(datadir_target, chkptendrec = readOneRecord(datadir_target,
ControlFile_target.checkPoint, ControlFile_target.checkPoint,
targetNentries - 1); targetNentries - 1,
restore_command);
/* /*
* If the histories diverged exactly at the end of the shutdown * If the histories diverged exactly at the end of the shutdown
......
...@@ -50,7 +50,7 @@ extern void findLastCheckpoint(const char *datadir, XLogRecPtr searchptr, ...@@ -50,7 +50,7 @@ extern void findLastCheckpoint(const char *datadir, XLogRecPtr searchptr,
XLogRecPtr *lastchkptredo, XLogRecPtr *lastchkptredo,
const char *restoreCommand); const char *restoreCommand);
extern XLogRecPtr readOneRecord(const char *datadir, XLogRecPtr ptr, extern XLogRecPtr readOneRecord(const char *datadir, XLogRecPtr ptr,
int tliIndex); int tliIndex, const char *restoreCommand);
/* in pg_rewind.c */ /* in pg_rewind.c */
extern void progress_report(bool force); extern void progress_report(bool force);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment