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

Update docstrings to explain the impact of partial state #13750

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/13750.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the docstrings for `get_users_in_room` and `get_current_hosts_in_room` to explain the impact of partial state.
17 changes: 16 additions & 1 deletion synapse/storage/databases/main/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,15 @@ async def get_users_in_room(self, room_id: str) -> List[str]:
(aka. with the lowest depth). This is done to match the sort in
`get_current_hosts_in_room()` and so we can re-use the cache but it's
not horrible to have here either.
"""

Uses `m.room.member`s in the room state at the current forward extremities to
determine which users are in the room.

Will return inaccurate results for rooms with partial state, since the state for
the forward extremities of those rooms will exclude most members. We may also
calculate room state incorrectly for such rooms and believe that a member is or
is not in the room when the opposite is true.
"""
return await self.db_pool.runInteraction(
"get_users_in_room", self.get_users_in_room_txn, room_id
)
Expand Down Expand Up @@ -1022,6 +1029,14 @@ async def get_current_hosts_in_room(self, room_id: str) -> List[str]:
longest is good because they're most likely to have anything we ask
about.

Uses `m.room.member`s in the room state at the current forward extremities to
determine which hosts are in the room.

Will return inaccurate results for rooms with partial state, since the state for
the forward extremities of those rooms will exclude most members. We may also
calculate room state incorrectly for such rooms and believe that a host is or
is not in the room when the opposite is true.

Returns:
Returns a list of servers sorted by longest in the room first. (aka.
sorted by join with the lowest depth first).
Expand Down