Skip to content
Snippets Groups Projects
Unverified Commit 79828917 authored by Sean Quah's avatar Sean Quah Committed by GitHub
Browse files

Fix missing cache invalidation in application service code (#14670)


#11915 introduced the `@cached` `is_interested_in_room` method in
Synapse 1.55.0, which depends upon `get_aliases_for_room`. Add a missing
cache invalidation callback so that the `is_interested_in_room` cache is
invalidated when `get_aliases_for_room` is invalidated.

#13787 made `get_rooms_for_user` `@cached`. Add a missing cache
invalidation callback so that the `is_interested_in_presence` cache is
invalidated when `get_rooms_for_user` is invalidated.

Signed-off-by: default avatarSean Quah <seanq@matrix.org>
parent b5b5f660
No related branches found
No related tags found
No related merge requests found
Fix bugs introduced in 1.55.0 and 1.69.0 where application services would not be notified of events in the correct rooms, due to stale caches.
...@@ -245,7 +245,9 @@ class ApplicationService: ...@@ -245,7 +245,9 @@ class ApplicationService:
return True return True
# likewise with the room's aliases (if it has any) # likewise with the room's aliases (if it has any)
alias_list = await store.get_aliases_for_room(room_id) alias_list = await store.get_aliases_for_room(
room_id, on_invalidate=cache_context.invalidate
)
for alias in alias_list: for alias in alias_list:
if self.is_room_alias_in_namespace(alias): if self.is_room_alias_in_namespace(alias):
return True return True
...@@ -311,7 +313,9 @@ class ApplicationService: ...@@ -311,7 +313,9 @@ class ApplicationService:
# Find all the rooms the sender is in # Find all the rooms the sender is in
if self.is_interested_in_user(user_id.to_string()): if self.is_interested_in_user(user_id.to_string()):
return True return True
room_ids = await store.get_rooms_for_user(user_id.to_string()) room_ids = await store.get_rooms_for_user(
user_id.to_string(), on_invalidate=cache_context.invalidate
)
# Then find out if the appservice is interested in any of those rooms # Then find out if the appservice is interested in any of those rooms
for room_id in room_ids: for room_id in room_ids:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment