12 Commits

Author SHA1 Message Date
David Robertson
4897acf3d6
Add the ability to reset the JoinedRoomsTracker
Not used yet; pulled out of #329.
2023-11-02 15:14:42 +00:00
David Robertson
47b7fac656
Only send leaves to previously-joined leavers 2023-10-17 18:03:43 +01:00
Till Faelligen
2521d9ccb7
Partly revert changes of #264 2023-08-24 14:27:34 +02:00
Till Faelligen
3cc3df53dc
Add IsUserInvited to filter out rooms 2023-08-21 12:51:53 +02:00
David Robertson
03ae9b8ee7
Comments 2023-06-06 13:52:02 +01:00
Kegan Dougal
be8543a21a add extensions for typing and receipts; bugfixes and additional perf improvements
Features:
 - Add `typing` extension.
 - Add `receipts` extension.
 - Add comprehensive prometheus `/metrics` activated via `SYNCV3_PROM`.
 - Add `SYNCV3_PPROF` support.
 - Add `by_notification_level` sort order.
 - Add `include_old_rooms` support.
 - Add support for `$ME` and `$LAZY`.
 - Add correct filtering when `*,*` is used as `required_state`.
 - Add `num_live` to each room response to indicate how many timeline entries are live.

Bug fixes:
 - Use a stricter comparison function on ranges: fixes an issue whereby UTs fail on go1.19 due to change in sorting algorithm.
 - Send back an `errcode` on HTTP errors (e.g expired sessions).
 - Remove `unsigned.txn_id` on insertion into the DB. Otherwise other users would see other users txn IDs :(
 - Improve range delta algorithm: previously it didn't handle cases like `[0,20] -> [20,30]` and would panic.
 - Send HTTP 400 for invalid range requests.
 - Don't publish no-op unread counts which just adds extra noise.
 - Fix leaking DB connections which could eventually consume all available connections.
 - Ensure we always unblock WaitUntilInitialSync even on invalid access tokens. Other code relies on WaitUntilInitialSync() actually returning at _some_ point e.g on startup we have N workers which bound the number of concurrent pollers made at any one time, we need to not just hog a worker forever.

Improvements:
 - Greatly improve startup times of sync3 handlers by improving `JoinedRoomsTracker`: a modest amount of data would take ~28s to create the handler, now it takes 4s.
 - Massively improve initial initial v3 sync times, by refactoring `JoinedRoomsTracker`, from ~47s to <1s.
 - Add `SlidingSyncUntil...` in tests to reduce races.
 - Tweak the API shape of JoinedUsersForRoom to reduce state block processing time for large rooms from 63s to 39s.
 - Add trace task for initial syncs.
 - Include the proxy version in UA strings.
 - HTTP errors now wait 1s before returning to stop clients tight-looping on error.
 - Pending event buffer is now 2000.
 - Index the room ID first to cull the most events when returning timeline entries. Speeds up `SelectLatestEventsBetween` by a factor of 8.
 - Remove cancelled `m.room_key_requests` from the to-device inbox. Cuts down the amount of events in the inbox by ~94% for very large (20k+) inboxes, ~50% for moderate sized (200 events) inboxes. Adds book-keeping to remember the unacked to-device position for each client.
2022-12-14 18:53:55 +00:00
Kegan Dougal
7e7a8a98ce feat/bugfix: Add invited|joined_count to room response JSON
This is so clients can accurately calculate the push rule:
```
{"kind":"room_member_count","is":"2"}
```
Also fixed a bug in the global room metadata for the joined/invited
counts where it could be wrong because of Synapse sending duplicate
join events as we were tracking +-1 deltas. We now calculate these
counts based on the set of user IDs in a specific membership state.
2022-08-30 17:27:58 +01:00
Kegan Dougal
ba78a33bb8 bugfix: use a map to store joined room tracker info
Previously we used a slice as this is slightly cheaper, but
since Synapse can return multiple join events in the timeline
it could cause a user ID to be present multiple times in a room.

When this happened, it would cause the `UserCache` callbacks to
be invoked twice for every event, clearly not ideal. By using a
set instead, we make sure that we don't add the same user more
than one time.

Ref: https://github.com/matrix-org/synapse/issues/9768
2022-08-16 11:13:03 +01:00
Kegan Dougal
ef6db93bf1 Flesh out invite behaviour a bit more when they transition to joined rooms
Notably, send required_state correctly.
2022-03-30 15:42:01 +01:00
Kegan Dougal
70f54fe2d2 Better comments 2022-03-23 14:13:59 +00:00
Kegan Dougal
987b510a1c Add security tests
Specifically to ensure that single proxy multiple user doesn't leak
events to other users.
2022-02-04 18:23:25 +00:00
Kegan Dougal
e20a8ad067 Move synclive to sync3 2021-10-05 16:22:02 +01:00