]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix single-record reads to use restore_command if available in pg_rewind
authorMichael Paquier <michael@paquier.xyz>
Tue, 21 Apr 2020 23:08:28 +0000 (08:08 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 21 Apr 2020 23:08:28 +0000 (08:08 +0900)
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/20200421.150830.1410714948345179794.horikyota.ntt@gmail.com

src/bin/pg_rewind/parsexlog.c
src/bin/pg_rewind/pg_rewind.c
src/bin/pg_rewind/pg_rewind.h

index 14a5db54331f1290d6fdda1c1517cfa2ec513b54..c51b5db315aab812f00a7afb7f8de4a7632e94da 100644 (file)
@@ -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)
index 101f0911becb13c8585e09cd5e4dcd74175b0a99..633955f7be5d50440f5456d8f651538b937ce1f1 100644 (file)
@@ -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
index b122ae43e5ac263ddb0e28600c6f344a33c00bc4..5cf5f17bb5f1a2cbf8246c2bd827d98ee78009e4 100644 (file)
@@ -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);