question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

caching on `have_seen_event` is somewhat broken

See original GitHub issue

As discovered in https://github.com/matrix-org/synapse/pull/13863#discussion_r977053643 and discussed in #synapse-dev. Part of https://github.com/matrix-org/synapse/issues/13856

The cache on have_seen_event uses a TreeCache, which means the cache is structured as {room_id: {event_id: result}}. However, _have_seen_events_dict tries to use it with @cachedList, which stores entries as {(room_id, event_id): result}. As a result, caching is inefficient, and cache invalidation is unreliable.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
erikjohnstoncommented, Sep 22, 2022

I think that the usage of @cachedList is wrong. It expects to be given the same number of arguments as the underlying cached function, just with one of the arguments being an iterable

https://github.com/matrix-org/synapse/blob/cfe486b0410c045e4db12c694ed5388365f5b54b/synapse/storage/databases/main/events_worker.py#L1485-L1488

I think that should actually be:

 @cachedList(cached_method_name="have_seen_event", list_name="event_ids") 
 async def _have_seen_events_dict( 
     self, room_id: str, event_ids: Collection[str],
 ) -> Dict[str, bool]: 
0reactions
richvdhcommented, Sep 22, 2022

oh right, that’s quite a lot easier.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How Do I Fix My Caching Problems Or Clear Web Browser's ...
Try holding down the Shift key while pressing the Refresh button. Close your browser and re-open it (make sure you are NOT on...
Read more >
What is a cache? And why does clearing it fix things? - Zapier
We've all done it, noticed that things work again, and proceeded to not think about the browser cache ever again (until something else...
Read more >
Advanced topics on caching in Apollo Client
Advanced topics on caching in Apollo Client. This article describes special cases and considerations when using the Apollo Client cache. Bypassing the cache....
Read more >
Warning! WP Super Cache caching was broken | WordPress.org
WP Super Cache caching was broken but has been fixed! The script advanced-cache.php could not load wp-cache-phase1.php. The file /home/XXXXX/public_html/XXXXX/ ...
Read more >
HTTP caching - MDN Web Docs
The HTTP cache stores a response associated with a request and reuses the ... and CSS resources that a client uses are out...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found