149 Commits

Author SHA1 Message Date
Kegan Dougal
5dae70069b Clean the syncv3_snapshots table periodically
Also cleans the transaction table periodically.

Fixes https://github.com/matrix-org/sliding-sync/issues/372

On testing, this cuts db size to about 1/3 of its original size.
2024-04-22 08:55:05 +01:00
Kegan Dougal
6d6a2d6c08 Add a sensible timeline_limit cap
To avoid pathological cases where large timeline limits are requested.
2024-02-21 13:22:20 +00:00
Kegan Dougal
62b3662e29 Interface out store functions from UserCache to make tests happier 2023-11-14 16:12:04 +00:00
Kegan Dougal
a25b2ee39d fix avatar updates; add e2e test for rejoining 2023-11-14 13:56:06 +00:00
David Robertson
cbd3c3c5c0
Merge pull request #363 from matrix-org/dmr/resnapshot-3 2023-11-10 11:38:12 +00:00
Kegan Dougal
6f2a00a2ce Review comments 2023-11-06 12:33:30 +00:00
Kegan Dougal
7e06813fe2 Fix #365: only return the last joined range
If we returned multiple distinct ranges, we always assumed that
the history visibility was "joined", so we would never return
events in the invite/shared state. This would be fine if the client
had a way to fetch those events sent before they were joined, but
they did not have a way as the prev_batch token would not be set
correctly. We now only return a single range of events and the prev
batch for /that/ range only, and defer to the upstream HS for
history visibility calculations.

Add end-to-end test to assert this new behaviour works.
2023-11-06 11:54:15 +00:00
David Robertson
2044af96de
Comment improvements 2023-11-03 15:47:00 +00:00
David Robertson
f0ea7cbd4d
Add FetchMemberships function
Pulled out of #329.
2023-11-02 15:47:17 +00:00
David Robertson
84a5ae5dc4
A batch of useful comments
pulled out of #329
2023-10-19 14:17:39 +01:00
David Robertson
cd8390fe2f
Give the accumulator an invites table ptr 2023-10-10 17:06:10 +01:00
Kegan Dougal
aae5b053b3 Remove temporary metric
This can cause issues on large instances where it causes the /metrics response
size to exceed the `-promscrape.maxScrapeSize`.
2023-10-02 09:45:40 +01:00
David Robertson
d3ba1f1c30
Move TimelineResponse back to sync2 2023-09-19 12:41:25 +01:00
David Robertson
957bdee9d2
Merge branch 'main' into dmr/invalidate-timelines 2023-09-19 12:40:13 +01:00
David Robertson
ea9cfc3be3
Update comment 2023-09-14 11:08:28 +01:00
David Robertson
df01e50438
Pass TimelineResponse struct around 2023-09-13 19:17:53 +01:00
David Robertson
1b14ac3d1f
Fix heroes pointer nonsense 2023-09-12 12:19:42 +01:00
David Robertson
6628cd33d4
Reload global metadata 2023-09-08 18:18:26 +01:00
David Robertson
773a28cf14
Make circularSlice generic 2023-09-08 18:17:13 +01:00
David Robertson
777cb357fe
Factor out AccumulateResult struct 2023-09-07 20:41:11 +01:00
Till Faelligen
f02826632b
Rename field 2023-09-07 13:37:54 +02:00
Till Faelligen
337844715f
Unregister metric 2023-09-07 10:15:44 +02:00
Till Faelligen
8baa252aa1
Add temporary prometheus metrics for snapshot size 2023-09-07 10:02:50 +02:00
Till Faelligen
d1689085e1
Improve performace when getting room state after event position 2023-08-18 17:02:12 +02:00
David Robertson
9fc5c91c47
LazyLoadTimelines: ignore messages from ignored senders 2023-08-03 19:07:33 +01:00
Kegan Dougal
6623ddb9e3 Do not make snapshots for lone leave events
Specifically this is targetting invite rejections, where the leave
event is inside the leave block of the sync v2 response.

Previously, we would make a snapshot with this leave event. If the
proxy wasn't in this room, it would mean the room state would just
be the leave event, which is wrong. If the proxy was in the room,
then state would correctly be rolled forward.
2023-07-31 17:53:15 +01:00
Kegan Dougal
a5c11f33a2 Bugfixes to ensure identical hero slices to before 2023-07-19 18:29:02 +01:00
Kegan Dougal
019661eb76 Calculate heroes from the returned joined/invited members 2023-07-19 18:23:09 +01:00
David Robertson
81b187d764
Merge pull request #208 from matrix-org/dmr/avatars2 2023-07-19 13:18:14 +01:00
David Robertson
7097c1d279
Track heroes' avatars 2023-07-18 12:44:26 +01:00
David Robertson
5913fbb0f3
Parse m.room.avatar 2023-07-18 12:44:25 +01:00
Kegan Dougal
fc04171c7c Combine invite/join calcs into 1 query for speed 2023-07-17 10:48:21 +01:00
kegsay
e6bb5558c5
Merge pull request #204 from matrix-org/kegan/metadata-fix
bugfix: ensure metadata maps are always init'd
2023-07-14 03:21:00 -07:00
Kegan Dougal
2c5df875af Skip spaces which are no longer valid 2023-07-14 10:37:25 +01:00
Kegan Dougal
8bed1037ac bugfix: ensure metadata maps are always init'd
If they aren't, we can panic on nil map access. Some of this code failed
to `, ok :=` the map access which would return a zero-initialised metadata
which has nil maps.
2023-07-14 10:32:53 +01:00
Kegan Dougal
de1cf98df3 Log when we go slow 2023-07-14 10:29:21 +01:00
Kegan Dougal
2d773ab776 Try to bail early 2023-07-13 18:39:53 +01:00
Kegan Dougal
baa5d05d31 Use the rooms table initially when querying latest nids 2023-07-13 18:19:00 +01:00
Kegan Dougal
c47665f1e8 Actually honour max conns globally, not per storage struct 2023-07-12 17:36:59 +01:00
kegsay
fc1fce54e4
Merge pull request #172 from matrix-org/kegan/max-db-conns-test
Test varying DB max conns
2023-06-19 18:48:14 +01:00
David Robertson
5081642612
Reduce DB Conn usage when fetching room state 2023-06-19 18:30:31 +01:00
David Robertson
1717408dc3
Use fewer DB conns when events into the UserCache 2023-06-19 17:58:56 +01:00
Kegan Dougal
5178d71f98 Don't take out another txn when LLing timelines; allow max_conns=1 to work 2023-06-19 17:52:10 +01:00
Kegan Dougal
4c661fbdd1 Add db conns test; uncomment DBMaxConns to break the world 2023-06-19 15:56:22 +01:00
kegsay
409431fdcc
Merge pull request #156 from matrix-org/kegan/accurate-load-positions
Remove global load position
2023-06-15 12:04:36 +01:00
Kegan Dougal
cb15252967 Set sensible DB conn limits 2023-06-14 10:24:25 +01:00
Kegan Dougal
5d619fdfb5 Add LatestEvents struct and use it
This provides a back-channel to send event NIDs
from LL timeilnes to connections.
2023-06-13 10:02:52 +01:00
Kegan Dougal
efaf2648eb Merge branch 'main' into kegan/accurate-load-positions 2023-06-13 08:44:21 +01:00
Kegan Dougal
c8d0c7a993 Rename confusing var name; use hasLoaded flag instead of loadPosition 2023-06-13 08:43:59 +01:00
David Robertson
ecd4df4f1a
Comments! 2023-06-10 14:11:20 +01:00