647 Commits

Author SHA1 Message Date
Kegan Dougal
613cbd9a67 client: swap to lists-as-keys 2023-02-13 17:13:42 +00:00
Kegan Dougal
3c964de004 bugfix: ensure we don't append nothing else we can end up with null arrays
Caught by element-web cypress tests, which consistently failed.
2023-02-10 14:02:21 +00:00
Kegan Dougal
c063352508 Add account data aggregation; with tests 2023-02-10 12:53:23 +00:00
Kegan Dougal
b3d76e90be Rejig extensions layout 2023-02-10 10:56:41 +00:00
Kegan Dougal
5a946323c1 Aggregate typing responses 2023-02-10 10:46:47 +00:00
Kegan Dougal
f67eefc5bb Automatically handle ApplyDelta for each extension 2023-02-10 10:26:46 +00:00
Kegan Dougal
b35e745255 Simplify how new extensions can be hooked in 2023-02-09 12:02:32 +00:00
Kegan Dougal
3b4b6b77d6 s/ProcessLive/AppendLive/g to make it clear what extensions need to do 2023-02-09 10:27:30 +00:00
Kegan Dougal
8f1366af67 bugfix: ensure typing/receipts updates aggregate correctly
Found these by adding a bunch of tests which is now possible
with the refactoring!
2023-02-08 18:27:44 +00:00
Kegan Dougal
b25f5bd129 extensions refactor: expose a consistent interface for live updates
Previously we sometimes used initial loading code, sometimes not and
had to remember to `return`. Keep the code paths separate and let
the extension decide what to do.
2023-02-08 17:37:49 +00:00
kegsay
8a6575a7ef
Merge pull request #24 from pixlwave/main
Add a landing page.
2023-02-08 18:35:02 +01:00
Kegan Dougal
773bb6b3e5 extensions refactor: remove updateWillReturnResponse
It was a very unclear boolean with unclear semantics, when what
we really meant was "if this is a room update and there is room
data included in this response, send back extension data".
2023-02-08 16:33:52 +00:00
Kegan Dougal
d92f225e6e Factor out live updating extension code 2023-02-08 16:19:00 +00:00
Kegan Dougal
66a010f249 extensions refactor: handle processing extensions in the same way
This allows us to automatically trace and automatically process only
enabled extensions. Live update code will be modified to use the same
code paths.
2023-02-08 12:58:52 +00:00
Kegan Dougal
b7defa2723 Add missing file 2023-02-08 11:33:16 +00:00
Kegan Dougal
05ddb6812b extensions refactor: automatically handle the enabled flag
Part of a series of refactors on the extensions code.
2023-02-08 11:30:54 +00:00
Kegan Dougal
27485f90cc bugfix: allow extensions to be enabled late; with regression tests 2023-02-07 17:36:43 +00:00
Kegan Dougal
7442b8a92e bugfix: aggregate receipts with live updates 2023-02-07 13:58:34 +00:00
Kegan Dougal
7fa433f732 bugfix: fix a bug with list ops when sorting with unread counts; fix a bug which could cause typing/receipts to not be live streamed
Previously, we would not send unread count INCREASES to the client,
as we would expect the actual event update to wake up the client conn.
This was great because it meant the event+unread count arrived atomically
on the client. This was implemented as "parse unread counts first, then events".

However, this introduced a bug when there were >1 user in the same room. In this
scenario, one poller may get the event first, which would go through to the client.
The subsequent unread count update would then be dropped and not sent to the client.
This would just be an unfortunate UI bug if it weren't for sorting by_notification_count
and sorting by_notification_level. Both of these sort operations use the unread counts
to determine room list ordering. This list would be updated on the server, but no
list operation would be sent to the client, causing the room lists to de-sync, and
resulting in incorrect DELETE/INSERT ops. This would manifest as duplicate rooms
on the room list.

In the process of fixing this, also fix a bug where typing notifications would not
always be sent to the client - it would only do so when piggybacked due to incorrect
type switches.

Also fix another bug which prevented receipts from always being sent to the client.
This was caused by the extensions handler not checking if the receipt extension had
data to determine if it should return. This the interacted with an as-yet unfixed bug
which cleared the extension on subequent updates, causing the receipt to be lost entirely.
A fix for this will be inbound soon.
2023-02-07 13:34:26 +00:00
Doug
45b7c0c4d4 Add a landing page. 2023-02-06 17:02:59 +00:00
Kegan Dougal
2139eda047 tests: add test for full connection buffers and expiry
Fixed a bug in notification code which could cause integration
tests to not be as deterministic as intended; should fix flakey
tests.
2023-02-03 10:00:45 +00:00
Kegan Dougal
fdc53dd365 bugfix: don't deadlock when connections expire
When connections expire, the user cache listener is removed.
This acquires a write lock.

When user cache events are emitted, a read lock is acquired
_and held_ when invoking listeners.

Unfortunately, invoking a listener can cause a connection to
expire in the case of a full buffer, which would then deadlock
and prevent new user cache listeners from being added.
2023-02-02 18:16:34 +00:00
Kegan Dougal
a2888b6d41 Add Sort benchmark 2023-02-02 15:00:34 +00:00
Kegan Dougal
36c66be95c bugfix: move loadPos checking to be entirely inside connstate
Fixes a race condition where we sometimes checked the position
before sending it to the buffer.
2023-02-02 14:41:23 +00:00
Kegan Dougal
941b8d8a60 Use the same go version in tests as in the Dockerfile (1.19).. again 2023-02-02 12:11:14 +00:00
Kegan Dougal
ac6d7d1845 Use the same go version in tests as in the Dockerfile (1.19) 2023-02-02 12:07:44 +00:00
Kegan Dougal
fc7f2a183b bugfix: fix data race in poller termination code
Just swap to using atomic.Bool as it's easier. Remove the
unnecessary channel.
2023-02-02 12:04:22 +00:00
Kegan Dougal
ff212bac48 bugfix: fix data races UserCache listener and cancelOutstandingReq
The user cache listeners slice is written to by HTTP goroutines
when clients make requests, and is read by the callbacks from v2
pollers. This slice wasn't protected from bad reads, only writes
were protected. Expanded the mutex to be RW to handle this.

cancelOutstandingReq is the context cancellation function to terminate
previous requests when a new request arrives. Whilst the request itself
is held in a mutex, invoking this cancellation function was not held
by anything. Added an extra mutex for this.
2023-02-02 11:43:18 +00:00
Kegan Dougal
8bccdb7342 perf: swap to pointers for s.allRooms
The RoomFinder accesses s.allRooms and is used when sorting the
room list, where we would expect many accesses. Previously, we
returned copies of room metadata, which caused significant amounts
of GC churn, enough to show up on traces.

Swap to using pointers and rename the function to `ReadOnlyRoom(roomID)`
to indicate that it isn't safe to write to this return value.
2023-02-02 11:26:08 +00:00
Kegan Dougal
4a2f45315a v0.99.0 v0.99.0 2023-02-01 12:15:52 +00:00
Kegan Dougal
a09bd2b854 Add more useful trace logs 2023-02-01 12:13:42 +00:00
Kegan Dougal
7eb139191f Suppress duplicate typing events from waking up connections 2023-02-01 11:51:06 +00:00
Kegan Dougal
ed14c8d7bd Maybe add M1 Mac support in pre-built docker images 2023-02-01 11:04:36 +00:00
Kegan Dougal
c327fe7ed2 Add more timeline trickling tests 2023-02-01 11:04:36 +00:00
David Baker
e51b842d5b
Oops, wrong repo! 2023-02-01 09:57:29 +00:00
David Baker
94204625e2
Update docker.yml 2023-02-01 09:56:25 +00:00
kegsay
f2efb3caa9
Point to correct docker repo 2023-01-23 17:29:13 +00:00
kegsay
ff2a8c07ae
Merge pull request #2 from matrix-org/kegan/lists-as-keys
BREAKING: Change the API to refer to lists by keys not index positions
2023-01-23 16:35:19 +00:00
Kegan Dougal
425b5d1284 Unbreak tests 2023-01-23 13:52:01 +00:00
Kegan Dougal
5d29512ac5 Merge branch 'main' into kegan/lists-as-keys 2023-01-23 13:25:30 +00:00
Kegan Dougal
5f1b95b914 feat: support timeline 'trickling' by resending when the limit changes
This allows you to send `timeline_limit: 1` in one request, then
swap to `timeline_limit: 10` in the 2nd request and get 10 events,
without it affecting the window (no ops or required_state resent).

This is being added to support fast preloading on mobile devices,
where timeline_limit: 1 is used to populate the room preview in the
room list and then timeline_limit: 20 is used to quickly pre-cache
a screen full of messages in case the user clicks through to the room.
2023-01-20 18:48:10 +00:00
Kegan Dougal
b3dfb02b57 v0.99.0-rc1 v0.99.0-rc1 2023-01-20 09:45:35 +00:00
Kegan Dougal
2ae1ff7f15 Unbreak tests 2023-01-18 15:31:44 +00:00
kegsay
d5af0266c8
Merge branch 'main' into kegan/lists-as-keys 2023-01-18 15:25:03 +00:00
Kegan Dougal
a7eed93722 Add comprehensive regression test for GlobalSnapshot(); ensure we clear db conns when tests end 2023-01-18 14:54:26 +00:00
Kegan Dougal
0ec1088b39 bugfix: fix a critical bug which caused memberships to be empty on all rooms
This meant no traffic would live stream to client connections.
Regression tests to follow.
2023-01-18 11:51:10 +00:00
Kegan Dougal
d1eaecc46c Add more tracing tasks and logs 2023-01-18 11:41:20 +00:00
Kegan Dougal
cb752f0d88 bugfix: don't send notification count updates eagerly if they increase
This results in flakey tests and a bad UX because one SS response can
say "the count changed from 0 to 1" but the message takes another
SS response. We _only_ send notification counts if they _decrease_,
and piggyback increases on the events in question which caused the
counts to go up.
2023-01-16 12:21:48 +00:00
Kegan Dougal
22abc32ca6 perf/bugfix: refactor event transaction_id handling
- Scope transaction IDs to the device ID (access token) rather
  than the user ID, as this is more accurate with the spec.
- Batch up all transaction ID lookups for all rooms being returned
  into a single query. Previously, we would sequentially call SELECT
  n times, one per room being returned, which was taking lots of time
  just due to RTTs to the database server (often this table is empty).
2023-01-16 11:55:37 +00:00
Kegan Dougal
0da350dd1a Move e2e/txn interfaces closer to where they are used; rather than sync2 where they were used previously 2023-01-16 10:53:48 +00:00