Fix a bug where the joined hosts for a given event were not being properly cached (#14125)

This commit is contained in:
Shay 2022-10-12 11:01:00 -07:00 committed by GitHub
parent e6e876b9b1
commit b6baa46db0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 48 deletions

1
changelog.d/14125.bugfix Normal file
View File

@ -0,0 +1 @@
Fix a bug introduced in v1.69.0rc1 where the joined hosts for a given event were not being properly cached.

View File

@ -414,7 +414,9 @@ class FederationEventHandler:
# First, precalculate the joined hosts so that the federation sender doesn't # First, precalculate the joined hosts so that the federation sender doesn't
# need to. # need to.
await self._event_creation_handler.cache_joined_hosts_for_event(event, context) await self._event_creation_handler.cache_joined_hosts_for_events(
[(event, context)]
)
await self._check_for_soft_fail(event, context=context, origin=origin) await self._check_for_soft_fail(event, context=context, origin=origin)
await self._run_push_actions_and_persist_event(event, context) await self._run_push_actions_and_persist_event(event, context)

View File

@ -1390,7 +1390,7 @@ class EventCreationHandler:
extra_users=extra_users, extra_users=extra_users,
), ),
run_in_background( run_in_background(
self.cache_joined_hosts_for_event, event, context self.cache_joined_hosts_for_events, events_and_context
).addErrback( ).addErrback(
log_failure, "cache_joined_hosts_for_event failed" log_failure, "cache_joined_hosts_for_event failed"
), ),
@ -1491,13 +1491,14 @@ class EventCreationHandler:
await self.store.remove_push_actions_from_staging(event.event_id) await self.store.remove_push_actions_from_staging(event.event_id)
raise raise
async def cache_joined_hosts_for_event( async def cache_joined_hosts_for_events(
self, event: EventBase, context: EventContext self, events_and_context: List[Tuple[EventBase, EventContext]]
) -> None: ) -> None:
"""Precalculate the joined hosts at the event, when using Redis, so that """Precalculate the joined hosts at each of the given events, when using Redis, so that
external federation senders don't have to recalculate it themselves. external federation senders don't have to recalculate it themselves.
""" """
for event, _ in events_and_context:
if not self._external_cache.is_enabled(): if not self._external_cache.is_enabled():
return return
@ -1546,7 +1547,9 @@ class EventCreationHandler:
expiry_ms=60 * 60 * 1000, expiry_ms=60 * 60 * 1000,
) )
self._external_cache_joined_hosts_updates[state_entry.state_group] = None self._external_cache_joined_hosts_updates[
state_entry.state_group
] = None
async def _validate_canonical_alias( async def _validate_canonical_alias(
self, self,