Patrick Cloke
cfb6d38c47
Remove remaining usage of cursor_to_dict. ( #16564 )
2023-10-31 13:13:28 -04:00
David Robertson
de981ae567
Claim local one-time-keys in bulk ( #16565 )
...
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
2023-10-30 21:25:21 +00:00
David Robertson
fdce83ee60
Claim fallback keys in bulk ( #16570 )
2023-10-30 14:34:37 +00:00
Patrick Cloke
2bf9341406
Ensure local invited & knocking users leave before purge. ( #16559 )
...
This is mostly useful for federated rooms where some users
would get stuck in the invite or knock state when the room
was purged from their homeserver.
2023-10-27 12:50:50 -04:00
Patrick Cloke
679c691f6f
Remove more usages of cursor_to_dict. ( #16551 )
...
Mostly to improve type safety.
2023-10-26 15:12:28 -04:00
Patrick Cloke
9407d5ba78
Convert simple_select_list and simple_select_list_txn to return lists of tuples ( #16505 )
...
This should use fewer allocations and improves type hints.
2023-10-26 13:01:36 -04:00
Erik Johnston
ba47fea528
Allow multiple workers to write to receipts stream. ( #16432 )
...
Fixes #16417
2023-10-25 16:16:19 +01:00
Erik Johnston
3bc23cc45c
Fix bug that could cause a /sync
to tightloop with sqlite after restart ( #16540 )
...
This could happen if the last rows in the account data stream were inserted into `account_data`. After a restart the max account ID would be calculated without looking at the `account_data` table, and so have an old ID.
2023-10-23 13:39:25 +00:00
Patrick Cloke
12ca87f5ea
Remove the last reference to event_txn_id. ( #16521 )
...
This table was no longer used, except for a background process
which purged old entries in it.
2023-10-23 07:37:45 -04:00
Erik Johnston
e9069c9f91
Mark sync as limited if there is a gap in the timeline ( #16485 )
...
This splits thinsg into two queries, but most of the time we won't have
new event backwards extremities so this shouldn't actually add an extra
RTT for the majority of cases.
Note this removes the check for events with no prev events, but that was
part of MSC2716 work that has since been removed.
2023-10-19 15:04:18 +01:00
Patrick Cloke
49c9745b45
Avoid sending massive replication updates when purging a room. ( #16510 )
2023-10-18 12:26:01 -04:00
Mathieu Velten
bcff01b406
Improve performance of delete device messages query ( #16492 )
2023-10-18 16:42:01 +01:00
Patrick Cloke
6ad1f9eac2
Convert DeviceLastConnectionInfo to attrs. ( #16507 )
...
To improve type safety & memory usage.
2023-10-17 12:47:42 +00:00
Patrick Cloke
e3e0ae4ab1
Convert state delta processing from a dict to attrs. ( #16469 )
...
For improved type checking & memory usage.
2023-10-16 07:35:22 -04:00
Mathieu Velten
eee6474bce
Remove useless async job to delete device messages on sync ( #16491 )
2023-10-16 11:06:27 +01:00
Patrick Cloke
cc865fffc0
Convert user_get_threepids response to attrs. ( #16468 )
...
This improves type annotations by not having a dictionary of Any values.
2023-10-11 20:08:11 -04:00
Patrick Cloke
a4904dcb04
Convert simple_select_many_batch, simple_select_many_txn to tuples. ( #16444 )
2023-10-11 13:24:56 -04:00
Patrick Cloke
f1e43018b7
Inline simple_search_list/simple_search_list_txn. ( #16434 )
...
This only has a single use and is over abstracted. Inline it so that
we can improve type hints.
2023-10-10 12:16:36 -04:00
David Robertson
28fd28e92e
Add DB indices to speed up purging rooms ( #16457 )
2023-10-10 10:33:39 +01:00
reivilibre
8902b3031d
Disable statement timeout whilst purging rooms ( #16455 )
...
* Disable statement timeout whilst purging rooms
* Newsfile
Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Note the introduction version
---------
Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
2023-10-09 15:41:17 +01:00
Patrick Cloke
06bbf1029c
Convert simple_select_list_paginate_txn to return tuples. ( #16433 )
2023-10-06 11:41:57 -04:00
Patrick Cloke
7615e2bf48
Return ThumbnailInfo in more places ( #16438 )
...
Improves type hints by using concrete types instead of
dictionaries.
2023-10-06 10:12:43 -04:00
Patrick Cloke
3555790b27
Remove unused method. ( #16435 )
2023-10-05 17:42:44 -04:00
Patrick Cloke
fa907025f4
Remove manys calls to cursor_to_dict ( #16431 )
...
This avoids calling cursor_to_dict and then immediately
unpacking the values in the dict for other users. By not
creating the intermediate dictionary we can avoid allocating
the dictionary and strings for the keys, which should generally
be more performant.
Additionally this improves type hints by avoid Dict[str, Any]
dictionaries coming out of the database layer.
2023-10-05 11:07:38 -04:00
Erik Johnston
009b47badf
Factor out MultiWriter
token from RoomStreamToken
( #16427 )
2023-10-05 10:46:28 +01:00
Erik Johnston
80ec81dcc5
Some refactors around receipts stream ( #16426 )
2023-10-04 16:28:40 +01:00
David Robertson
1026776380
mypy plugin to check @cached
return types ( #14911 )
...
Co-authored-by: David Robertson <davidr@element.io>
Co-authored-by: Patrick Cloke <patrickc@matrix.org>
Co-authored-by: Erik Johnston <erik@matrix.org>
Assert that the return type of callables wrapped in @cached
and @cachedList are cachable (aka immutable).
2023-10-02 14:22:36 +00:00
Patrick Cloke
17800a0e97
Implement MSC4028: push all encrypted events. ( #16361 )
...
This unstable push rule is implemented behind an experimental
configuration flag.
2023-09-26 11:52:19 -04:00
Patrick Cloke
2763c49eca
Improve comments in StateGroupBackgroundUpdateStore. ( #16383 )
2023-09-25 18:50:47 +00:00
Patrick Cloke
7ec0a141b4
Convert more cached return values to immutable types ( #16356 )
2023-09-20 07:48:55 -04:00
Patrick Cloke
d7c89c5908
Return immutable objects for cachedList decorators ( #16350 )
2023-09-19 15:26:44 -04:00
dependabot[bot]
eee2b6642d
Bump ruff from 0.0.286 to 0.0.290 ( #16342 )
...
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Patrick Cloke <patrickc@matrix.org>
2023-09-18 11:30:43 -04:00
Hanadi
eef2b9e344
Filter locked users in the admin API ( #16328 )
...
Co-authored-by: Hanadi Tamimi <hanadi.tamimi@sdui.de>
2023-09-18 15:37:51 +01:00
Patrick Cloke
c1e244c8f7
Make cached account data/tags/admin types immutable ( #16325 )
2023-09-18 09:55:04 -04:00
Patrick Cloke
85bfd4735e
Return an immutable value from get_latest_event_ids_in_room. ( #16326 )
2023-09-18 09:29:05 -04:00
Jason Little
2a0f86f88f
Convert _insert_graph_receipts_txn
to simple_upsert
( #16299 )
2023-09-15 09:16:45 +01:00
Erik Johnston
329597022e
Some minor performance fixes for task schedular ( #16313 )
2023-09-14 16:20:47 +01:00
Erik Johnston
954921736b
Refactor get_user_by_id
( #16316 )
2023-09-14 12:46:30 +01:00
Hanadi
7afb5e0410
Fix using dehydrated devices (MSC2697) & refresh tokens ( #16288 )
...
Refresh tokens were not correctly moved to the rehydrated
device (similar to how the access token is currently handled).
This resulted in invalid refresh tokens after rehydration.
2023-09-13 08:33:39 -04:00
Patrick Cloke
d38d0dffc9
Use StrCollection in additional places. ( #16301 )
2023-09-13 07:57:19 -04:00
Patrick Cloke
16ef6f1e3c
Stop purging tables which are slated for removal. ( #16273 )
2023-09-12 07:12:31 -04:00
Erik Johnston
2b35626b6b
Refactor storing of server keys ( #16261 )
2023-09-12 11:08:04 +01:00
Erik Johnston
1cd410a783
Recheck if remote device is cached before requesting it ( #16252 )
...
This fixes a bug where we could get stuck re-requesting the device over
replication again and again.
2023-09-07 12:45:43 +00:00
Erik Johnston
8940d1b28e
Add /notifications
endpoint to workers ( #16265 )
2023-09-07 09:26:07 +00:00
Patrick Cloke
32fb264120
Merge remote-tracking branch 'origin/release-v1.92' into develop
2023-09-06 13:08:22 -04:00
Patrick Cloke
55c20da4a3
Merge remote-tracking branch 'origin/release-v1.91' into release-v1.92
2023-09-06 11:25:28 -04:00
Quentin Gliech
1940d990a3
Revert MSC3861 introspection cache, admin impersonation and account lock ( #16258 )
2023-09-06 15:19:51 +01:00
Mathieu Velten
4f1840a88a
Delete device messages asynchronously and in staged batches ( #16240 )
2023-09-06 09:30:53 +02:00
Will Hunt
1e571cd664
Fix appservices being unable to handle to_device messages for multiple users ( #16251 )
2023-09-05 15:46:57 -04:00
Erik Johnston
c9cec2daed
Fix bug where we kept re-requesting a remote server's key repeatedly. ( #16257 )
...
* Correctly handle multiple rows per server/key
* Newsfile
2023-09-05 20:27:41 +01:00
Erik Johnston
d35bed8369
Don't wake up destination transaction queue if they're not due for retry. ( #16223 )
2023-09-04 17:14:09 +01:00
Mathieu Velten
dcb2778341
Add last_seen_ts to the admin users API ( #16218 )
2023-09-04 18:13:28 +02:00
Erik Johnston
a2e0d4cd60
Fix rare bug that broke looping calls ( #16210 )
...
* Fix rare bug that broke looping calls
We can't interact with the reactor from the main thread via looping
call.
Introduced in v1.90.0 / #15791 .
* Newsfile
2023-08-30 14:18:42 +01:00
Patrick Cloke
ebd8374fb5
Stop writing to the event_txn_id table ( #16175 )
2023-08-30 11:10:56 +01:00
dependabot[bot]
001fc7bd19
Bump ruff from 0.0.277 to 0.0.286 ( #16198 )
...
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-29 09:41:43 -04:00
Patrick Cloke
33fa82a34c
Stabilize support for MSC3958 (suppress notifications from edits). ( #16113 )
2023-08-23 13:22:34 -04:00
Neil Johnson
ec662bbe41
Filter out unwanted user_agents from udv. ( #16124 )
2023-08-23 14:00:34 +01:00
Erik Johnston
86ecd341ec
Always update retry_last_ts
( #16164 )
2023-08-23 13:04:46 +01:00
Mathieu Velten
873971a8b9
Task scheduler: mark task as active if we are scheduling ASAP ( #16165 )
2023-08-23 13:37:51 +02:00
DeepBlueV7.X
19a1cda084
Properly update retry_last_ts when hitting the maximum retry interval ( #16156 )
...
* Properly update retry_last_ts when hitting the maximum retry interval
This was broken in 1.87 when the maximum retry interval got changed from
almost infinite to a week (and made configurable).
fixes #16101
Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de>
* Add changelog
* Change fix + add test
* Add comment
---------
Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de>
Co-authored-by: Mathieu Velten <mathieuv@matrix.org>
2023-08-23 09:35:23 +01:00
Shay
69048f7b48
Add an admin endpoint to allow authorizing server to signal token revocations ( #16125 )
2023-08-22 14:15:34 +00:00
Mathieu Velten
358896e1b8
Implements a task scheduler for resumable potentially long running tasks ( #15891 )
2023-08-21 14:17:13 +02:00
Erik Johnston
bd558a6dc3
Speed up state res in rare case we don't have all events ( #16116 )
...
If we don't have all the auth events in a room then not all state events will have a chain cover index. Even so, we can still use the chain cover index on the events that do have it, rather than bailing and using the slower functions.
This situation should not arise for newly persisted rooms, as we check we have the full auth chain for each event, but can happen for existing rooms.
c.f. #15245
2023-08-18 15:32:06 +01:00
Alexander Fechler
54317d34b7
Allow filtering for admins in the list accounts admin API ( #16114 )
2023-08-18 12:26:38 +01:00
Erik Johnston
0aba4a4eaa
Add cache to get_server_keys_json_for_remote
( #16123 )
2023-08-18 11:05:01 +01:00
Erik Johnston
eb0dbab15b
Fix database performance of read/write worker locks ( #16061 )
...
We were seeing serialization errors when taking out multiple read locks.
The transactions were retried, so isn't causing any failures.
Introduced in #15782 .
2023-08-17 14:07:57 +01:00
Patrick Cloke
ad3f43be9a
Run pyupgrade for python 3.7 & 3.8. ( #16110 )
2023-08-15 08:11:20 -04:00
Mathieu Velten
dac97642e4
Implements admin API to lock an user (MSC3939) ( #15870 )
2023-08-10 09:10:55 +00:00
Shay
0328b56468
Support MSC3814: Dehydrated Devices Part 2 ( #16010 )
2023-08-08 12:04:46 -07:00
reivilibre
f3dc6dc19f
Remove old rows from the cache_invalidation_stream_by_instance
table automatically. (This table is not used when Synapse is configured to use SQLite.) ( #15868 )
...
* Add a cache invalidation clean-up task
* Run the cache invalidation stream clean-up on the background worker
* Tune down
* call_later is in millis!
* Newsfile
Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* fixup! Add a cache invalidation clean-up task
* Update synapse/storage/databases/main/cache.py
Co-authored-by: Eric Eastwood <erice@element.io>
* Update synapse/storage/databases/main/cache.py
Co-authored-by: Eric Eastwood <erice@element.io>
* MILLISEC -> MS
* Expand on comment
* Move and tweak comment about Postgres
* Use `wrap_as_background_process`
---------
Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
Co-authored-by: Eric Eastwood <erice@element.io>
2023-08-08 11:10:07 +01:00
Patrick Cloke
d98a43d922
Stabilize support for MSC3970: updated transaction semantics (scope to device_id
) ( #15629 )
...
For now this maintains compatible with old Synapses by falling back
to using transaction semantics on a per-access token. A future version
of Synapse will drop support for this.
2023-08-04 07:47:18 -04:00
Erik Johnston
ae55cc1e6b
Add ability to wait for locks and add locks to purge history / room deletion ( #15791 )
...
c.f. #13476
2023-07-31 10:58:03 +01:00
Anshul Madnawat
58f8305114
Inline SQL queries using boolean parameters ( #15525 )
...
SQLite now supports TRUE and FALSE constants, simplify some
queries by inlining those instead of passing them as arguments.
2023-07-26 18:45:47 +00:00
Shay
f08d05dd2c
Actually stop reading from column user_id
of tables profiles
( #15955 )
2023-07-23 16:30:54 -07:00
Erik Johnston
fc1e534e41
Speed up updating state in large rooms ( #15971 )
...
This should speed up updating state in rooms with lots of state.
2023-07-20 15:51:28 +01:00
Olivier Wilkinson (reivilibre)
8e8431bc6e
Merge branch 'master' into develop
2023-07-18 16:45:39 +01:00
Patrick Cloke
6d81aec09f
Support room version 11 ( #15912 )
...
And fix a bug in the implementation of the updated redaction
format (MSC2174) where the top-level redacts field was not
properly added for backwards-compatibility.
2023-07-18 08:44:59 -04:00
Shay
e625c3dca0
Revert "Stop writing to column user_id
of tables profiles
and user_filters
. ( #15953 )
...
* Revert "Stop writing to column `user_id` of tables `profiles` and `user_filters` (#15787 )"
This reverts commit f25b0f8808
.
* newsfragement
2023-07-18 11:44:09 +01:00
Mathieu Velten
8eb7bb975e
Mark get_user_in_directory private since only used in tests ( #15884 )
2023-07-12 11:09:13 +02:00
Erik Johnston
e55a9b3e41
Fix downgrading to previous version of Synapse ( #15907 )
...
We do this by marking the constraint as deferrable.
2023-07-10 16:24:42 +01:00
Shay
f25b0f8808
Stop writing to column user_id
of tables profiles
and user_filters
( #15787 )
2023-07-07 09:23:27 -07:00
Erik Johnston
39d131b016
Add basic read/write lock ( #15782 )
2023-07-05 17:25:00 +01:00
Eric Eastwood
ce857c05d5
Add tracing to media /upload
endpoint ( #15850 )
...
Add tracing instrumentation to media `/upload` code paths to investigate https://github.com/matrix-org/synapse/issues/15841
2023-07-05 10:22:21 -05:00
Jason Little
4cf9f92f39
Fix could not serialize access due to concurrent DELETE
from presence_stream ( #15826 )
...
* Change update_presence to have a isolation level of READ_COMMITTED
* changelog
2023-07-05 11:44:02 +01:00
Erik Johnston
95a96b21eb
Add foreign key constraint to event_forward_extremities
. ( #15751 )
2023-07-05 09:43:19 +00:00
Michael Weimann
c8e81898b6
Add not_user_type param to the list accounts admin API ( #15844 )
...
Signed-off-by: Michael Weimann <michaelw@element.io>
2023-07-04 15:03:20 -07:00
pacien
07d7cbfe69
devices: use combined ANY clause for faster cleanup ( #15861 )
...
Old device entries for the same user were being removed in individual
SQL commands, making the batch take way longer than necessary.
This combines the commands into a single one with a IN/ANY clause.
Example of log entry before the change, regularly observed with
"log_min_duration_statement = 10000" in PostgreSQL's config:
LOG: duration: 42538.282 ms statement:
DELETE FROM device_lists_stream
WHERE user_id = '@someone' AND device_id = 'someid1'
AND stream_id < 123456789
;
DELETE FROM device_lists_stream
WHERE user_id = '@someone' AND device_id = 'someid2'
AND stream_id < 123456789
;
[repeated for each device ID of that user, potentially a lot...]
With the patch applied on my instance for the past couple of days, I
no longer notice overly long statements of that particular kind.
Signed-off-by: pacien <pacien.trangirard@pacien.net>
2023-07-03 16:39:38 +02:00
Nicolas Werner
e0c39d6bb5
Fix forgotten rooms missing in initial sync ( #15815 )
...
If you leave a room and forget it, then rejoin it, the room would be
missing from the next initial sync.
fixes #13262
Signed-off-by: Nicolas Werner <n.werner@famedly.com>
2023-06-21 14:56:31 +01:00
Eric Eastwood
0f02f0b4da
Remove experimental MSC2716 implementation to incrementally import history into existing rooms ( #15748 )
...
Context for why we're removing the implementation:
- https://github.com/matrix-org/matrix-spec-proposals/pull/2716#issuecomment-1487441010
- https://github.com/matrix-org/matrix-spec-proposals/pull/2716#issuecomment-1504262734
Anyone wanting to continue MSC2716, should also address these leftover tasks: https://github.com/matrix-org/synapse/issues/10737
Closes https://github.com/matrix-org/synapse/issues/10737 in the fact that it is not longer necessary to track those things.
2023-06-16 14:12:24 -05:00
Jason Little
21fea6b749
Prefill events after invalidate not before when persisting events ( #15758 )
...
Fixes #15757
2023-06-14 09:42:18 +01:00
Erik Johnston
c485ed1c5a
Clear event caches when we purge history ( #15609 )
...
This should help a little with #13476
---------
Co-authored-by: Patrick Cloke <patrickc@matrix.org>
2023-06-08 13:14:40 +01:00
Eric Eastwood
e536f02f68
Remove superfluous room_memberships
join from background update ( #15733 )
...
Spawning from https://github.com/matrix-org/synapse/pull/15731
2023-06-07 11:47:01 -05:00
Eric Eastwood
9d911b0da6
No need for the extra join since membership
is built-in to current_state_events
( #15731 )
...
This helps with the upstream `is_host_joined()` and `is_host_invited()` functions.
`membership` was added to `current_state_events` in https://github.com/matrix-org/synapse/pull/5706 and forced in https://github.com/matrix-org/synapse/pull/13745
2023-06-06 22:19:57 -05:00
Shay
6ee96e9366
Improve performance of user directory search ( #15729 )
2023-06-06 21:16:03 +01:00
Patrick Cloke
f880e64b11
Stabilize support for MSC3952: Intentional mentions. ( #15520 )
2023-06-06 09:11:07 +01:00
Shay
d0c4257f14
N + 3
: Read from column full_user_id
rather than user_id
of tables profiles
and user_filters
(#15649 )
2023-06-02 17:24:13 -07:00
Mathieu Velten
e0f2429d13
Add a catch-all * to the supported relation types when redacting ( #15705 )
...
This is an update to MSC3912 implementation
2023-06-02 13:13:50 +00:00
H. Shay
8af29155ec
Merge branch 'release-v1.85' into develop
2023-06-01 10:26:37 -07:00
Erik Johnston
5ed0e8c61f
Cache requests for user's devices from federation ( #15675 )
...
This should mitigate the issue where lots of different servers requests
the same user's devices all at once.
2023-06-01 13:25:20 +00:00
Shay
6d9e2fd878
Speed up background jobs populate_full_user_id_user_filters and populate_full_user_id_profiles ( #15700 )
2023-05-31 15:13:48 -07:00