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

Commit4bd0ad9

Browse files
committed
Prevent archive recovery from scanning non-existent WAL files.
Previously when there were multiple timelines listed in the history fileof the recovery target timeline, archive recovery searched all of them,starting from the newest timeline to the oldest one, to find the segmentto read. That is, archive recovery had to continuously fail scanningthe segment until it reached the timeline that the segment belonged to.These scans for non-existent segment could be harmful on the recoveryperformance especially when archival area was located on the remotestorage and each scan could take a long time.To address the issue, this commit changes archive recovery so thatit skips scanning the timeline that the segment to read doesn't belong to.Author: Kyotaro Horiguchi, tweaked a bit by Fujii MasaoReviewed-by: David Steele, Pavel Suderevsky, Grigory SmolkinDiscussion:https://postgr.es/m/16159-f5a34a3a04dc67e0@postgresql.orgDiscussion:https://postgr.es/m/20200129.120222.1476610231001551715.horikyota.ntt@gmail.com
1 parentba3e76c commit4bd0ad9

File tree

1 file changed

+26
-1
lines changed
  • src/backend/access/transam

1 file changed

+26
-1
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3776,11 +3776,36 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
37763776

37773777
foreach(cell,tles)
37783778
{
3779-
TimeLineIDtli= ((TimeLineHistoryEntry*)lfirst(cell))->tli;
3779+
TimeLineHistoryEntry*hent= (TimeLineHistoryEntry*)lfirst(cell);
3780+
TimeLineIDtli=hent->tli;
37803781

37813782
if (tli<curFileTLI)
37823783
break;/* don't bother looking at too-old TLIs */
37833784

3785+
/*
3786+
* Skip scanning the timeline ID that the logfile segment to read
3787+
* doesn't belong to
3788+
*/
3789+
if (hent->begin!=InvalidXLogRecPtr)
3790+
{
3791+
XLogSegNobeginseg=0;
3792+
3793+
XLByteToSeg(hent->begin,beginseg,wal_segment_size);
3794+
3795+
/*
3796+
* The logfile segment that doesn't belong to the timeline is
3797+
* older or newer than the segment that the timeline started or
3798+
* ended at, respectively. It's sufficient to check only the
3799+
* starting segment of the timeline here. Since the timelines are
3800+
* scanned in descending order in this loop, any segments newer
3801+
* than the ending segment should belong to newer timeline and
3802+
* have already been read before. So it's not necessary to check
3803+
* the ending segment of the timeline here.
3804+
*/
3805+
if (segno<beginseg)
3806+
continue;
3807+
}
3808+
37843809
if (source==XLOG_FROM_ANY||source==XLOG_FROM_ARCHIVE)
37853810
{
37863811
fd=XLogFileRead(segno,emode,tli,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp