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

Commitb366e51

Browse files
committed
Avoid assertion failure with targeted recovery in standby mode.
At the end of recovery, standby mode is turned off to re-fetch the lastvalid record from archive or pg_wal. Previously, if recovery target wasreached and standby mode was turned off while the current WAL sourcewas stream, recovery could try to retrieve WAL file containing the lastvalid record unexpectedly from stream even though not in standby mode.This caused an assertion failure. That is, the assertion test confirms thatWAL file should not be retrieved from stream if standby mode is not true.This commit moves back the current WAL source to archive if it's streameven though not in standby mode, to avoid that assertion failure.This issue doesn't cause the server to crash when built with assertiondisabled. In this case, the attempt to retrieve WAL file from stream notin standby mode just fails. And then recovery tries to retrieve WAL filefrom archive or pg_wal.Back-patch to all supported branches.Author: Kyotaro HoriguchiReviewed-by: Fujii MasaoDiscussion:https://postgr.es/m/20200227.124830.2197604521555566121.horikyota.ntt@gmail.com
1 parent5c2e2a2 commitb366e51

File tree

1 file changed

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

1 file changed

+22
-1
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7397,7 +7397,11 @@ StartupXLOG(void)
73977397
* We are now done reading the xlog from stream. Turn off streaming
73987398
* recovery to force fetching the files (which would be required at end of
73997399
* recovery, e.g., timeline history file) from archive or pg_wal.
7400+
*
7401+
* Note that standby mode must be turned off after killing WAL receiver,
7402+
* i.e., calling ShutdownWalRcv().
74007403
*/
7404+
Assert(!WalRcvStreaming());
74017405
StandbyMode= false;
74027406

74037407
/*
@@ -11814,12 +11818,23 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1181411818
* values for "check trigger", "rescan timelines", and "sleep" states,
1181511819
* those actions are taken when reading from the previous source fails, as
1181611820
* part of advancing to the next state.
11821+
*
11822+
* If standby mode is turned off while reading WAL from stream, we move
11823+
* to XLOG_FROM_ARCHIVE and reset lastSourceFailed, to force fetching
11824+
* the files (which would be required at end of recovery, e.g., timeline
11825+
* history file) from archive or pg_wal. We don't need to kill WAL receiver
11826+
* here because it's already stopped when standby mode is turned off at
11827+
* the end of recovery.
1181711828
*-------
1181811829
*/
1181911830
if (!InArchiveRecovery)
1182011831
currentSource=XLOG_FROM_PG_WAL;
11821-
elseif (currentSource==0)
11832+
elseif (currentSource==0||
11833+
(!StandbyMode&&currentSource==XLOG_FROM_STREAM))
11834+
{
11835+
lastSourceFailed= false;
1182211836
currentSource=XLOG_FROM_ARCHIVE;
11837+
}
1182311838

1182411839
for (;;)
1182511840
{
@@ -12011,6 +12026,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1201112026
{
1201212027
caseXLOG_FROM_ARCHIVE:
1201312028
caseXLOG_FROM_PG_WAL:
12029+
/*
12030+
* WAL receiver must not be running when reading WAL from
12031+
* archive or pg_wal.
12032+
*/
12033+
Assert(!WalRcvStreaming());
12034+
1201412035
/* Close any old file we might have open. */
1201512036
if (readFile >=0)
1201612037
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp