MatrixSynapse/synapse/util/caches
Eric Eastwood 29269d9d3f
Fix `have_seen_event` cache not being invalidated (#13863)
Fix https://github.com/matrix-org/synapse/issues/13856
Fix https://github.com/matrix-org/synapse/issues/13865

> Discovered while trying to make Synapse fast enough for [this MSC2716 test for importing many batches](https://github.com/matrix-org/complement/pull/214#discussion_r741678240). As an example, disabling the `have_seen_event` cache saves 10 seconds for each `/messages` request in that MSC2716 Complement test because we're not making as many federation requests for `/state` (speeding up `have_seen_event` itself is related to https://github.com/matrix-org/synapse/issues/13625) 
> 
> But this will also make `/messages` faster in general so we can include it in the [faster `/messages` milestone](https://github.com/matrix-org/synapse/milestone/11).
> 
> *-- https://github.com/matrix-org/synapse/issues/13856*


### The problem

`_invalidate_caches_for_event` doesn't run in monolith mode which means we never even tried to clear the `have_seen_event` and other caches. And even in worker mode, it only runs on the workers, not the master (AFAICT).

Additionally there was bug with the key being wrong so `_invalidate_caches_for_event` never invalidates the `have_seen_event` cache even when it does run.

Because we were using the `@cachedList` wrong, it was putting items in the cache under keys like `((room_id, event_id),)` with a `set` in a `set` (ex. `(('!TnCIJPKzdQdUlIyXdQ:test', '$Iu0eqEBN7qcyF1S9B3oNB3I91v2o5YOgRNPwi_78s-k'),)`) and we we're trying to invalidate with just `(room_id, event_id)` which did nothing.
2022-09-27 15:55:43 -05:00
..
__init__.py Fix a memory leak when running the unit tests. (#13798) 2022-09-14 15:29:05 +00:00
cached_call.py Add missing type hints to `synapse.logging.context` (#11556) 2021-12-14 17:35:28 +00:00
deferred_cache.py Speed up `@cachedList` (#13591) 2022-08-23 14:53:27 +00:00
descriptors.py Fix `have_seen_event` cache not being invalidated (#13863) 2022-09-27 15:55:43 -05:00
dictionary_cache.py Make DictionaryCache have better expiry properties (#13292) 2022-07-21 17:13:44 +01:00
expiringcache.py Track cache invalidations (#12000) 2022-02-15 14:31:04 +00:00
lrucache.py Optimise async get event lookups (#13435) 2022-08-04 15:49:55 +01:00
response_cache.py Improve opentracing support for `ResponseCache` (#11607) 2021-12-20 18:12:08 +00:00
stream_change_cache.py More types for synapse.util, part 1 (#10888) 2021-10-06 11:20:49 +01:00
treecache.py Speed up `@cachedList` (#13591) 2022-08-23 14:53:27 +00:00
ttlcache.py Remove unused `# type: ignore`s (#12531) 2022-04-27 14:03:44 +01:00