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

Fix performance of responding to user key requests over federation #10221

Merged
merged 5 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/10221.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix performance regression in responding to user key requests over federation. Introduced in v1.34.0rc1.
2 changes: 2 additions & 0 deletions synapse/config/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ from synapse.config import (
database,
emailconfig,
experimental,
federation,
groups,
jwt,
key,
Expand Down Expand Up @@ -87,6 +88,7 @@ class RootConfig:
tracer: tracer.TracerConfig
redis: redis.RedisConfig
modules: modules.ModulesConfig
federation: federation.FederationConfig

config_classes: List = ...
def __init__(self) -> None: ...
Expand Down
9 changes: 8 additions & 1 deletion synapse/storage/databases/main/end_to_end_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ def __init__(self, database: DatabasePool, db_conn: Connection, hs: "HomeServer"


class EndToEndKeyWorkerStore(EndToEndKeyBackgroundStore):
def __init__(self, database: DatabasePool, db_conn: Connection, hs: "HomeServer"):
super().__init__(database, db_conn, hs)

self._allow_device_name_lookup_over_federation = (
self.hs.config.federation.allow_device_name_lookup_over_federation
)

async def get_e2e_device_keys_for_federation_query(
self, user_id: str
) -> Tuple[int, List[JsonDict]]:
Expand All @@ -85,7 +92,7 @@ async def get_e2e_device_keys_for_federation_query(
result["keys"] = keys

device_display_name = None
if self.hs.config.allow_device_name_lookup_over_federation:
if self._allow_device_name_lookup_over_federation:
device_display_name = device.display_name
if device_display_name:
result["device_display_name"] = device_display_name
Expand Down