summary refs log tree commit diff
path: root/synapse/storage/databases/main/cache.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Don't invalidate all `get_relations_for_event` on history purge (#17083)Erik Johnston2024-05-291-3/+15
| | | | This is a tree cache already, so may as well move the room ID to the front and use that
* Don't invalidate the entire event cache when we purge history (#16905)Erik Johnston2024-02-131-1/+1
| | | | | We do this by adding support to the LRU cache for "extra indices" based on the cached value. This allows us to efficiently map from room ID to the cached events and only invalidate those.
* Correctly mention previous copyright (#16820)Erik Johnston2024-01-231-0/+1
| | | | | During the migration the automated script to update the copyright headers accidentally got rid of some of the existing copyright lines. Reinstate them.
* Update license headersPatrick Cloke2023-11-211-10/+16
|
* Bulk-invalidate e2e cached queries after claiming keys (#16613)David Robertson2023-11-091-4/+71
| | | | Co-authored-by: Patrick Cloke <patrickc@matrix.org>
* Avoid sending massive replication updates when purging a room. (#16510)Patrick Cloke2023-10-181-0/+8
|
* Revert MSC3861 introspection cache, admin impersonation and account lock ↵Quentin Gliech2023-09-061-13/+0
| | | | (#16258)
* Add an admin endpoint to allow authorizing server to signal token ↵Shay2023-08-221-0/+13
| | | | revocations (#16125)
* Remove old rows from the `cache_invalidation_stream_by_instance` table ↵reivilibre2023-08-081-0/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix forgotten rooms missing in initial sync (#15815)Nicolas Werner2023-06-211-0/+13
| | | | | | | | 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>
* Clear event caches when we purge history (#15609)Erik Johnston2023-06-081-0/+134
| | | | | | | This should help a little with #13476 --------- Co-authored-by: Patrick Cloke <patrickc@matrix.org>
* Update code to refer to "workers". (#15606)Patrick Cloke2023-05-161-7/+7
| | | | A bunch of comments and variables are out of date and use obsolete terms.
* Check databases/__init__ and main/cache with mypy. (#15496)Patrick Cloke2023-04-271-7/+9
|
* Remove support for aggregating reactions (#15172)Richard van der Hoff2023-02-281-3/+0
| | | | | | | | | | It turns out that no clients rely on server-side aggregation of `m.annotation` relationships: it's just not very useful as currently implemented. It's also non-trivial to calculate. I want to remove it from MSC2677, so to keep the implementation in line, let's remove it here.
* Always notify replication when a stream advances (#14877)Erik Johnston2023-01-201-0/+1
| | | This ensures that all other workers are told about stream updates in a timely manner, without having to remember to manually poke replication.
* Update all stream IDs after processing replication rows (#14723)Nick Mills-Barrett2023-01-041-3/+8
| | | | | | | | | | | | | | This creates a new store method, `process_replication_position` that is called after `process_replication_rows`. By moving stream ID advances here this guarantees any relevant cache invalidations will have been applied before the stream is advanced. This avoids race conditions where Python switches between threads mid way through processing the `process_replication_rows` method where stream IDs may be advanced before caches are invalidated due to class resolution ordering. See this comment/issue for further discussion: https://github.com/matrix-org/synapse/issues/14158#issuecomment-1344048703
* Batch fetch bundled references (#14508)Patrick Cloke2022-11-221-0/+1
| | | | | | | | | Avoid an n+1 query problem and fetch the bundled aggregations for m.reference relations in a single query instead of a query per event. This applies similar logic for as was previously done for edits in 8b309adb436c162510ed1402f33b8741d71fc058 (#11660; threads in b65acead428653b988351ae8d7b22127a22039cd (#11752); and annotations in 1799a54a545618782840a60950ef4b64da9ee24d (#14491).
* Invalidate rooms for user caches when receiving membership events (#14155)Nick Mills-Barrett2022-10-171-0/+4
| | | | | This should fix a race where the event notification comes in over replication before the state replication, leaving a window during which a sync may get an incorrect list of rooms for the user.
* Accept threaded receipts for events related to the root event. (#14174)Patrick Cloke2022-10-141-0/+1
| | | | | | | | | The root node of a thread (and events related to it) are considered "part of a thread" when validating receipts. This allows clients which show the root node in both the main timeline and the threaded timeline to easily send receipts in either. Note that threaded notifications are not created for these events, these events created notifications on the main timeline.
* Properly invalidate get_thread_id cache. (#14163)Patrick Cloke2022-10-141-0/+1
| | | This was missed in 2b6d41ebd685fb546e52acdbcb0024dfcf5a5db1 (#13824).
* Add an API for listing threads in a room. (#13394)Patrick Cloke2022-10-131-0/+1
| | | | | | | | | Implement the /threads endpoint from MSC3856. This is currently unstable and behind an experimental configuration flag. It includes a background update to backfill data, results from the /threads endpoint will be partial until that finishes.
* Remove the experimental implementation of MSC3772. (#14094)Patrick Cloke2022-10-121-3/+0
| | | MSC3772 has been abandoned.
* Optimise get_rooms_for_user (drop with_stream_ordering) (#13787)Nick Mills-Barrett2022-09-291-0/+1
|
* Simplify cache invalidation after event persist txn (#13796)Nick Mills-Barrett2022-09-261-13/+21
| | | | | This moves all the invalidations into a single place and de-duplicates the code involved in invalidating caches for a given event by using the base class method.
* Add cache invalidation across workers to module API (#13667)Mathieu Velten2022-09-211-6/+14
| | | Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
* Use cache store remove base slaved (#13329)Nick Mills-Barrett2022-07-211-0/+26
| | | This comes from two identical definitions in each of the base stores, and means the base slaved store is now empty and can be removed.
* Revert "Make all `process_replication_rows` methods async (#13304)" (#13312)Erik Johnston2022-07-181-2/+2
| | | This reverts commit 5d4028f217f178fcd384d5bfddd92225b4e78c51.
* Make all `process_replication_rows` methods async (#13304)Nick Mills-Barrett2022-07-171-2/+2
| | | | | More prep work for asyncronous caching, also makes all process_replication_rows methods consistent (presence handler already is so). Signed off by Nick @ Beeper (@Fizzadar)
* Async get event cache prep (#13242)Nick Mills-Barrett2022-07-151-2/+5
| | | | | Some experimental prep work to enable external event caching based on #9379 & #12955. Doesn't actually move the cache at all, just lays the groundwork for async implemented caches. Signed off by Nick @ Beeper (@Fizzadar)
* Add index to cache invalidations (#12747)Erik Johnston2022-05-171-0/+8
| | | | | For workers that rarely write to the cache the `get_all_updated_caches` query can become expensive if the worker falls behind when reading the cache.
* Add cache for `get_membership_from_event_ids` (#12272)Erik Johnston2022-03-251-0/+4
| | | | | This should speed up push rule calculations for rooms with large numbers of local users when the main push rule cache fails. Co-authored-by: reivilibre <oliverw@matrix.org>
* Add some missing type hints to cache datastore. (#12216)Patrick Cloke2022-03-161-21/+36
|
* Allow retrieving the relations of a redacted event. (#12130)Patrick Cloke2022-03-101-0/+4
| | | | | | | | | This is allowed per MSC2675, although the original implementation did not allow for it and would return an empty chunk / not bundle aggregations. The main thing to improve is that the various caches get cleared properly when an event is redacted, and that edits must not leak if the original event is redacted (as that would presumably leak something similar to the original event content).
* Invalidate caches when an event with a relation is redacted. (#12121)Patrick Cloke2022-03-071-0/+2
| | | | | The caches for the target of the relation must be cleared so that the bundled aggregations are re-calculated after the redaction is processed.
* Invalidate the get_users_in_room{_with_profile} caches only when necessary. ↵Patrick Cloke2022-02-021-5/+11
| | | | | | | (#11878) The get_users_in_room and get_users_in_room_with_profiles are now only invalidated when the membership of a room changes, instead of during any state change in the room.
* Type hint the constructors of the data store classes (#11555)Sean Quah2021-12-131-2/+7
|
* Add type hints for most `HomeServer` parameters (#11095)Sean Quah2021-10-221-2/+5
|
* add a cache to have_seen_event (#9953)Richard van der Hoff2021-06-011-0/+1
| | | Empirically, this helped my server considerably when handling gaps in Matrix HQ. The problem was that we would repeatedly call have_seen_events for the same set of (50K or so) auth_events, each of which would take many minutes to complete, even though it's only an index scan.
* Combine `LruCache.invalidate` and `invalidate_many` (#9973)Richard van der Hoff2021-05-271-3/+3
| | | | | | | | | | * Make `invalidate` and `invalidate_many` do the same thing ... so that we can do either over the invalidation replication stream, and also because they always confused me a bit. * Kill off `invalidate_many` * changelog
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Separate `get_current_token` into two. (#8113)Erik Johnston2020-08-191-2/+2
| | | | | | | | | | | | The function is used for two purposes: 1) for subscribers of streams to get a token they can use to get further updates with, and 2) for replication to track position of the writers of the stream. For streams with a single writer the two scenarios produce the same result, however the situation becomes complicated for streams with multiple writers. The current `MultiWriterIdGenerator` does not correctly handle the first case (which is not an issue as its only used for the `caches` stream which nothing subscribes to outside of replication).
* Revert #7736 (#8039)Brendan Abolivier2020-08-061-1/+0
|
* Rename database classes to make some sense (#8033)Erik Johnston2020-08-051-0/+307