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

Commit762bd37

Browse files
committed
Change the order that pg_xlog and WAL archive are polled for WAL segments.
If there is a WAL segment with same ID but different TLI present in boththe WAL archive and pg_xlog, prefer the one with higher TLI. Before thispatch, the archive was polled first, for all expected TLIs, and only if nofile was found was pg_xlog scanned. This was a change in behavior from 9.3,which first scanned archive and pg_xlog for the highest TLI, then archiveand pg_xlog for the next highest TLI and so forth. This patch reverts thebehavior back to what it was in 9.2.The reason for this is that if for example you try to do archive recoveryto timeline 2, which branched off timeline 1, but the WAL for timeline 2 isnot archived yet, we would replay past the timeline switch point ontimeline 1 using the archived files, before even looking timeline 2's filesin pg_xlogReport and patch by Kyotaro Horiguchi. Backpatch to 9.3 where the behaviorwas changed.
1 parentf208fb4 commit762bd37

File tree

1 file changed

+10
-13
lines changed
  • src/backend/access/transam

1 file changed

+10
-13
lines changed

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9576,17 +9576,15 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
95769576
/*-------
95779577
* Standby mode is implemented by a state machine:
95789578
*
9579-
* 1. Read from archive (XLOG_FROM_ARCHIVE)
9580-
*2. Read from pg_xlog (XLOG_FROM_PG_XLOG)
9581-
*3. Check trigger file
9582-
*4. Read from primary server via walreceiver (XLOG_FROM_STREAM)
9583-
*5. Rescan timelines
9584-
*6. Sleep 5 seconds, and loop back to 1.
9579+
* 1. Read fromeitherarchiveor pg_xlog(XLOG_FROM_ARCHIVE), or just
9580+
* pg_xlog (XLOG_FROM_XLOG)
9581+
*2. Check trigger file
9582+
*3. Read from primary server via walreceiver (XLOG_FROM_STREAM)
9583+
*4. Rescan timelines
9584+
*5. Sleep 5 seconds, and loop back to 1.
95859585
*
95869586
* Failure to read from the current source advances the state machine to
9587-
* the next state. In addition, successfully reading a file from pg_xlog
9588-
* moves the state machine from state 2 back to state 1 (we always prefer
9589-
* files in the archive over files in pg_xlog).
9587+
* the next state.
95909588
*
95919589
* 'currentSource' indicates the current state. There are no currentSource
95929590
* values for "check trigger", "rescan timelines", and "sleep" states,
@@ -9614,9 +9612,6 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
96149612
switch (currentSource)
96159613
{
96169614
caseXLOG_FROM_ARCHIVE:
9617-
currentSource=XLOG_FROM_PG_XLOG;
9618-
break;
9619-
96209615
caseXLOG_FROM_PG_XLOG:
96219616

96229617
/*
@@ -9781,7 +9776,9 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
97819776
* Try to restore the file from archive, or read an existing
97829777
* file from pg_xlog.
97839778
*/
9784-
readFile=XLogFileReadAnyTLI(readSegNo,DEBUG2,currentSource);
9779+
readFile=XLogFileReadAnyTLI(readSegNo,DEBUG2,
9780+
currentSource==XLOG_FROM_ARCHIVE ?XLOG_FROM_ANY :
9781+
currentSource);
97859782
if (readFile >=0)
97869783
return true;/* success! */
97879784

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp