-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle gappy state blocks in a performant way #329
Conversation
9055551
to
91432b1
Compare
6167aad
to
6db1d22
Compare
Remove PrependTimelineEvents Update unit test Tweak variable names, add ReplacedExistingSnapshot
Remove redundant comment Improve errmsg
6db1d22
to
db7e94d
Compare
|
||
t.Log("Alice should see the two most recent message in the timeline only. The room name should change too.") | ||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{}) | ||
m.MatchResponse(t, res, m.MatchRoomSubscription(roomID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also check the prev batch token
Needs proxy fixes to the prev_batch token handling
even if the initial load returns no rooms. This is an exceedingly rare situation since most people have accounts with rooms before using the proxy. But it does help first-time users and naive test authors.
pubsub/v2.go
Outdated
@@ -25,6 +25,7 @@ type V2Listener interface { | |||
OnDeviceMessages(p *V2DeviceMessages) | |||
OnExpiredToken(p *V2ExpiredToken) | |||
OnInvalidateRoom(p *V2InvalidateRoom) | |||
OnStateRedaction(p *V2StateRedaction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled out to #359
state/accumulator_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to have a unit test of the new snapshotting logic in Intialise, if I didn't add one already.
state/storage.go
Outdated
joins map[string]Event, | ||
invites map[string][]json.RawMessage, | ||
leaves map[string]json.RawMessage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May not need the data here---just the user IDs.
// ForcePrevBatch is nonempty when the proxy doesn't know the timeline event immediately | ||
// prior to this one. Its value is the prevBatch for this event. If set, this token MUST | ||
// be sent to sync3 clients (or else there'll be a gap in their timeline). | ||
ForcePrevBatch string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: do we still need this? Should it be pulled out to another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The motivation was:
sliding-sync/sync3/handler/connstate_live.go
Lines 237 to 243 in b8e34a7
// Normally live events don't need a prevBatch because they follow up | |
// from a previous sync response with a prevBatch. BUT after a gappy poll | |
// where the user has joined a room, the first time they see a timeline event | |
// for this room is here. So we need to provide them a prevBatch token. | |
if roomEventUpdate.EventData.ForcePrevBatch != "" { | |
r.PrevBatch = roomEventUpdate.EventData.ForcePrevBatch | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the scenario here is seeing in a live update that you've joined a room via a gappy poll.
I think this should actually be impossible now, because we'll kill your connection.
if s.anchorLoadPosition <= 0 { | ||
if s.anchorLoadPosition < 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we do this again?
RoomID: roomA.RoomID, | ||
JSON: newEvent, | ||
} | ||
dispatcher.OnNewEvent(context.Background(), roomA.RoomID, newEventWrapped, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this change to OnNewEvent?
m.MatchResponse( | ||
t, | ||
syncResp, | ||
m.MatchRoomSubscription( | ||
roomID, | ||
m.MatchRoomName("potato"), | ||
MatchRoomTimelineMostRecent(1, []Event{{ID: latestMessageID}}), | ||
MatchRoomTimelineMostRecent(1, []Event{{ID: lastMsgID}}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to take another look at this, I have no memory of this place.
786691a
to
ebe2641
Compare
Not used yet; pulled out of #329.
Superseded by #363. |
I don't fully remember the details, but may as well pluck this from the previous PR.
#310 was getting out of control. I did an interactive rebase, threw some things away, and wrote some new things. This is the result.
This PR:
(3) was the hard part. When I looked at the data in the user cache, the important bits to get right after an invalidation were membership-related. Everything else either didn't look like it ought to be affected by an invalidation, or I didn't care enough to reload them (Spaces). This needs proper testing and I haven't got anything which does that yet.
We could maybe land (3) separately, but either way we need (3) before (1) and (2).
This lacks testing. We probably want an integration test to test a bunch of membership transitions in the gap: