From 6b6b420b9f467d053fd1fe3d1872f94c0bcf8300 Mon Sep 17 00:00:00 2001 From: sergekh2 <104387024+sergekh2@users.noreply.github.com> Date: Tue, 2 Aug 2022 01:43:48 -0700 Subject: [PATCH] Fix issue with sync API not advancing. (#2603) Issue: During conversation, under some conditions, sync cookie is not advanced, and, as a result, client loops on the same sync API call creating high traffic and CPU load. Fix: pdu component of cookie was updated incorrectly. --- syncapi/streams/stream_pdu.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syncapi/streams/stream_pdu.go b/syncapi/streams/stream_pdu.go index 1832adbe5..1003208fd 100644 --- a/syncapi/streams/stream_pdu.go +++ b/syncapi/streams/stream_pdu.go @@ -261,9 +261,9 @@ func (p *PDUStreamProvider) addRoomDeltaToResponse( var pos types.StreamPosition if _, pos, err = p.DB.PositionInTopology(ctx, mostRecentEventID); err == nil { switch { - case r.Backwards && pos > latestPosition: + case r.Backwards && pos < latestPosition: fallthrough - case !r.Backwards && pos < latestPosition: + case !r.Backwards && pos > latestPosition: latestPosition = pos } }