Skip to content

Commit cd12323

Browse files
committed
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/20200421.150830.1410714948345179794.horikyota.ntt@gmail.com
1 parent c33869c commit cd12323

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/bin/pg_rewind/parsexlog.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ extractPageMap(const char *datadir, XLogRecPtr startpoint, int tliIndex,
106106
* doing anything with the record itself.
107107
*/
108108
XLogRecPtr
109-
readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex)
109+
readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex,
110+
const char *restoreCommand)
110111
{
111112
XLogRecord *record;
112113
XLogReaderState *xlogreader;
@@ -115,6 +116,7 @@ readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex)
115116
XLogRecPtr endptr;
116117

117118
private.tliIndex = tliIndex;
119+
private.restoreCommand = restoreCommand;
118120
xlogreader = XLogReaderAllocate(WalSegSz, datadir, &SimpleXLogPageRead,
119121
&private);
120122
if (xlogreader == NULL)

src/bin/pg_rewind/pg_rewind.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ main(int argc, char **argv)
339339
/* Read the checkpoint record on the target to see where it ends. */
340340
chkptendrec = readOneRecord(datadir_target,
341341
ControlFile_target.checkPoint,
342-
targetNentries - 1);
342+
targetNentries - 1,
343+
restore_command);
343344

344345
/*
345346
* If the histories diverged exactly at the end of the shutdown

src/bin/pg_rewind/pg_rewind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extern void findLastCheckpoint(const char *datadir, XLogRecPtr searchptr,
5050
XLogRecPtr *lastchkptredo,
5151
const char *restoreCommand);
5252
extern XLogRecPtr readOneRecord(const char *datadir, XLogRecPtr ptr,
53-
int tliIndex);
53+
int tliIndex, const char *restoreCommand);
5454

5555
/* in pg_rewind.c */
5656
extern void progress_report(bool force);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy