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

Make get_room_version use cached get_room_version_id. #11808

Merged
merged 7 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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/11808.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make method `get_room_version` use cached `get_room_version_id`.
14 changes: 7 additions & 7 deletions synapse/storage/databases/main/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ async def get_room_version(self, room_id: str) -> RoomVersion:
Typically this happens if support for the room's version has been
removed from Synapse.
"""
return await self.db_pool.runInteraction(
"get_room_version_txn",
self.get_room_version_txn,
room_id,
)
room_version_id = await self.get_room_version_id(room_id)
return self.__retrieve_and_check_room_version(room_id, room_version_id)

def get_room_version_txn(
self, txn: LoggingTransaction, room_id: str
Expand All @@ -82,14 +79,17 @@ def get_room_version_txn(
removed from Synapse.
"""
room_version_id = self.get_room_version_id_txn(txn, room_id)
v = KNOWN_ROOM_VERSIONS.get(room_version_id)
return self.__retrieve_and_check_room_version(room_id, room_version_id)

def __retrieve_and_check_room_version(
lukasdenk marked this conversation as resolved.
Show resolved Hide resolved
self, room_id: str, room_version_id: str
) -> RoomVersion:
v = KNOWN_ROOM_VERSIONS.get(room_version_id)
if not v:
raise UnsupportedRoomVersionError(
"Room %s uses a room version %s which is no longer supported"
% (room_id, room_version_id)
)

return v

@cached(max_entries=10000)
Expand Down