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

Commitef34ab4

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 parentd924944 commitef34ab4

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
@@ -7392,7 +7392,11 @@ StartupXLOG(void)
73927392
* We are now done reading the xlog from stream. Turn off streaming
73937393
* recovery to force fetching the files (which would be required at end of
73947394
* recovery, e.g., timeline history file) from archive or pg_wal.
7395+
*
7396+
* Note that standby mode must be turned off after killing WAL receiver,
7397+
* i.e., calling ShutdownWalRcv().
73957398
*/
7399+
Assert(!WalRcvStreaming());
73967400
StandbyMode= false;
73977401

73987402
/*
@@ -11855,12 +11859,23 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1185511859
* values for "check trigger", "rescan timelines", and "sleep" states,
1185611860
* those actions are taken when reading from the previous source fails, as
1185711861
* part of advancing to the next state.
11862+
*
11863+
* If standby mode is turned off while reading WAL from stream, we move
11864+
* to XLOG_FROM_ARCHIVE and reset lastSourceFailed, to force fetching
11865+
* the files (which would be required at end of recovery, e.g., timeline
11866+
* history file) from archive or pg_wal. We don't need to kill WAL receiver
11867+
* here because it's already stopped when standby mode is turned off at
11868+
* the end of recovery.
1185811869
*-------
1185911870
*/
1186011871
if (!InArchiveRecovery)
1186111872
currentSource=XLOG_FROM_PG_WAL;
11862-
elseif (currentSource==0)
11873+
elseif (currentSource==0||
11874+
(!StandbyMode&&currentSource==XLOG_FROM_STREAM))
11875+
{
11876+
lastSourceFailed= false;
1186311877
currentSource=XLOG_FROM_ARCHIVE;
11878+
}
1186411879

1186511880
for (;;)
1186611881
{
@@ -12054,6 +12069,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1205412069
{
1205512070
caseXLOG_FROM_ARCHIVE:
1205612071
caseXLOG_FROM_PG_WAL:
12072+
/*
12073+
* WAL receiver must not be running when reading WAL from
12074+
* archive or pg_wal.
12075+
*/
12076+
Assert(!WalRcvStreaming());
12077+
1205712078
/* Close any old file we might have open. */
1205812079
if (readFile >=0)
1205912080
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp