Skip to content

Commit

Permalink
Write correct file name in "START WAL LOCATION" backup_label's field
Browse files Browse the repository at this point in the history
ThisTimeLineID is always 0 in a normal backend during recovery.
We get latest redo apply position timeline and we update it globally
to make do_pg_start_backup using the correct value when generate the
backup label text
  • Loading branch information
mnencia committed Feb 13, 2014
1 parent 3abceb2 commit 84f3856
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.so
*.o
.deps/
13 changes: 13 additions & 0 deletions pgespresso.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pgespresso_start_backup(PG_FUNCTION_ARGS)
char *backupidstr;
XLogRecPtr startpoint;
char *labelfile;
TimeLineID replayTLI;

backupidstr = text_to_cstring(backupid);

Expand All @@ -61,6 +62,18 @@ pgespresso_start_backup(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser or replication role to run a backup")));

/*
* ThisTimeLineID is always 0 in a normal backend during recovery.
* We get latest redo apply position timeline and we update it globally
* to make do_pg_start_backup use the correct value when generating
* backup label text
*/
if (RecoveryInProgress()) {
GetXLogReplayRecPtr(&replayTLI);
ThisTimeLineID = replayTLI;
elog(DEBUG1, "updated ThisTimeLineID = %u", ThisTimeLineID);
}

startpoint = do_pg_start_backup(backupidstr, fast, NULL, &labelfile);

PG_RETURN_TEXT_P(cstring_to_text(labelfile));
Expand Down

0 comments on commit 84f3856

Please sign in to comment.