Skip to content

Commit 45821f4

Browse files
spxcmssCommitfest Bot
authored and
Commitfest Bot
committed
Fix walreceiver set incorrect flushedUpto when switching primary
Signed-off-by: shipixian <[email protected]>
1 parent daa1689 commit 45821f4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/replication/walreceiverfuncs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo,
298298
walrcv->startTime = now;
299299

300300
/*
301-
* If this is the first startup of walreceiver (on this timeline),
301+
* If this is the first startup of walreceiver (on this timeline) or recptr lt last flushedLsn,
302302
* initialize flushedUpto and latestChunkStart to the starting point.
303303
*/
304-
if (walrcv->receiveStart == 0 || walrcv->receivedTLI != tli)
304+
if (walrcv->receiveStart == 0 || walrcv->receivedTLI != tli || recptr < walrcv->receiveStart)
305305
{
306306
walrcv->flushedUpto = recptr;
307307
walrcv->receivedTLI = tli;

0 commit comments

Comments
 (0)