Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 72ee9fa

Browse files
author
Sean Quah
committed
Fix missing cache invalidation in application service code
#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: Sean Quah <[email protected]>
1 parent b5b5f66 commit 72ee9fa

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

changelog.d/14670.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
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.

synapse/appservice/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ async def is_interested_in_room(
245245
return True
246246

247247
# likewise with the room's aliases (if it has any)
248-
alias_list = await store.get_aliases_for_room(room_id)
248+
alias_list = await store.get_aliases_for_room(
249+
room_id, on_invalidate=cache_context.invalidate
250+
)
249251
for alias in alias_list:
250252
if self.is_room_alias_in_namespace(alias):
251253
return True
@@ -311,7 +313,9 @@ async def is_interested_in_presence(
311313
# Find all the rooms the sender is in
312314
if self.is_interested_in_user(user_id.to_string()):
313315
return True
314-
room_ids = await store.get_rooms_for_user(user_id.to_string())
316+
room_ids = await store.get_rooms_for_user(
317+
user_id.to_string(), on_invalidate=cache_context.invalidate
318+
)
315319

316320
# Then find out if the appservice is interested in any of those rooms
317321
for room_id in room_ids:

0 commit comments

Comments
 (0)