Skip to content

Commit 478de5f

Browse files
author
Commitfest Bot
committed
[CF 5199] v2 - Fix standby may crash when switching-over in certain special cases
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5199 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CAAccyYKzMZiq5xOjUkjhvxth8V+yiNuyX=9xcnLM_yBM9oYWFQ@mail.gmail.com Author(s): pixian shi
2 parents b498af4 + cef956e commit 478de5f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/replication/walreceiverfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,10 @@ RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo,
312312
walrcv->startTime = now;
313313

314314
/*
315-
* If this is the first startup of walreceiver (on this timeline),
315+
* If this is the first startup of walreceiver (on this timeline) or recptr lt last flushedLsn,
316316
* initialize flushedUpto and latestChunkStart to the starting point.
317317
*/
318-
if (walrcv->receiveStart == 0 || walrcv->receivedTLI != tli)
318+
if (walrcv->receiveStart == 0 || walrcv->receivedTLI != tli || recptr < walrcv->receiveStart)
319319
{
320320
walrcv->flushedUpto = recptr;
321321
walrcv->receivedTLI = tli;

0 commit comments

Comments
 (0)