From 44de53bb79f961147386ea2a8bfbeb54b007cd41 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 6 Jun 2022 18:46:11 +0300 Subject: Reduce state pulled from DB due to sending typing and receipts over federation (#12964) Reducing the amount of state we pull from the DB is useful as fetching state is expensive in terms of DB, CPU and memory. --- synapse/storage/controllers/state.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'synapse/storage/controllers') diff --git a/synapse/storage/controllers/state.py b/synapse/storage/controllers/state.py index 63a78ebc87..3b4cdb67eb 100644 --- a/synapse/storage/controllers/state.py +++ b/synapse/storage/controllers/state.py @@ -23,6 +23,7 @@ from typing import ( List, Mapping, Optional, + Set, Tuple, ) @@ -482,3 +483,10 @@ class StateStorageController: room_id, StateFilter.from_types((key,)) ) return state_map.get(key) + + async def get_current_hosts_in_room(self, room_id: str) -> Set[str]: + """Get current hosts in room based on current state.""" + + await self._partial_state_room_tracker.await_full_state(room_id) + + return await self.stores.main.get_current_hosts_in_room(room_id) -- cgit 1.4.1