Skip to content

Commit 8463880

Browse files
Fix LagTrackerRead() for timeline increments
Bug was masked by error in running 004_timeline_switch.pl that was fixed recently in 7d68f22. Detective work by Alvaro Herrera and Tom Lane Author: Thomas Munro
1 parent 0874d4f commit 8463880

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/backend/replication/walsender.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -3328,7 +3328,16 @@ LagTrackerRead(int head, XLogRecPtr lsn, TimestampTz now)
33283328
WalTimeSample prev = LagTracker.last_read[head];
33293329
WalTimeSample next = LagTracker.buffer[LagTracker.read_heads[head]];
33303330

3331-
Assert(lsn >= prev.lsn);
3331+
if (lsn < prev.lsn)
3332+
{
3333+
/*
3334+
* Reported LSNs shouldn't normally go backwards, but it's
3335+
* possible when there is a timeline change. Treat as not
3336+
* found.
3337+
*/
3338+
return -1;
3339+
}
3340+
33323341
Assert(prev.lsn < next.lsn);
33333342

33343343
if (prev.time > next.time)

0 commit comments

Comments
 (0)