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

Batch look-ups to see if rooms are partial stated. #14917

Merged
merged 14 commits into from
Jan 26, 2023
2 changes: 1 addition & 1 deletion synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ async def simple_select_many_batch(
keyvalues: Optional[Dict[str, Any]] = None,
desc: str = "simple_select_many_batch",
batch_size: int = 100,
) -> List[Any]:
) -> List[Dict[str, Any]]:
"""Executes a SELECT query on the named table, which may return zero or
more rows, returning the result as a list of dicts.

Expand Down
19 changes: 9 additions & 10 deletions synapse/storage/databases/main/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Collection,
Dict,
List,
Literal,
Mapping,
Optional,
Sequence,
Expand Down Expand Up @@ -1285,17 +1286,15 @@ async def is_partial_state_room_batched(
complete.
"""

entries = set(
await self.db_pool.simple_select_many_batch(
table="partial_state_rooms",
column="room_id",
iterable=room_ids,
retcols=("room_id",),
desc="is_partial_state_room",
)
rows: List[Dict[str, Literal[1]]] = await self.db_pool.simple_select_many_batch(
clokep marked this conversation as resolved.
Show resolved Hide resolved
table="partial_state_rooms",
column="1",
iterable=room_ids,
retcols=("room_id",),
desc="is_partial_state_room",
clokep marked this conversation as resolved.
Show resolved Hide resolved
)

return {room_id: room_id in entries for room_id in room_ids}
partial_state_rooms = {room_id for row_dict in rows for room_id in row_dict}
return {room_id: room_id in partial_state_rooms for room_id in room_ids}

async def get_join_event_id_and_device_lists_stream_id_for_partial_state(
self, room_id: str
Expand Down