Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a0bfa4

Browse files
committed
Prevent WAL files created by pg_basebackup -x/X from being archived again.
WAL (and timeline history) files created by pg_basebackup did notmaintain the new base backup's archive status. That's currently not aproblem if the new node is used as a standby - but if that node ispromoted all still existing files can get archived again. With a highwal_keep_segment settings that can happen a significant time later -which is quite confusing.Change both the backend (for the -x/-X fetch case) and pg_basebackup(for -X stream) itself to always mark WAL/timeline files included inthe base backup as .done. That's in line with walreceiver.c doing so.The verbosity of the pg_basebackup changes show pretty clearly that itneeds some refactoring, but that'd result in not be backpatchablechanges.Backpatch to 9.1 where pg_basebackup was introduced.Discussion: 20141205002854.GE21964@awork2.anarazel.de
1 parent6dd3050 commit2a0bfa4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎src/backend/replication/basebackup.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
257257
while (true)
258258
{
259259
/* Send another xlog segment */
260+
charsn[MAXPGPATH];
260261
charfn[MAXPGPATH];
262+
charpathbuf[MAXPGPATH];
261263
inti;
262264

263265
XLogFilePath(fn,ThisTimeLineID,logid,logseg);
@@ -290,6 +292,15 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
290292
* boundary, so padding is never necessary.
291293
*/
292294

295+
/*
296+
* Mark file as archived, otherwise files can get archived again
297+
* after promotion of a new node. This is in line with
298+
* walreceiver.c always doing a XLogArchiveForceDone() after a
299+
* complete segment.
300+
*/
301+
XLogFileName(sn,ThisTimeLineID,logid,logseg);
302+
StatusFilePath(pathbuf,sn,".done");
303+
sendFileWithContent(pathbuf,"");
293304

294305
/* Advance to the next WAL file */
295306
NextLogSeg(logid,logseg);
@@ -715,6 +726,15 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces)
715726
_tarWriteHeader(pathbuf+basepathlen+1,NULL,&statbuf);
716727
}
717728
size+=512;/* Size of the header just added */
729+
730+
/*
731+
* Also send archive_status directory (by hackishly reusing
732+
* statbuf from above ...).
733+
*/
734+
if (!sizeonly)
735+
_tarWriteHeader("./pg_xlog/archive_status",NULL,&statbuf);
736+
size+=512;/* Size of the header just added */
737+
718738
continue;/* don't recurse into pg_xlog */
719739
}
720740

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp