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

Commit

Permalink
Store when we partial-joined
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Sep 23, 2022
1 parent e986a7f commit de0002b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
7 changes: 6 additions & 1 deletion synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,12 @@ async def do_invite_join(
# Mark the room as having partial state.
# The background process is responsible for unmarking this flag,
# even if the join fails.
await self.store.store_partial_state_room(room_id, ret.servers_in_room)
await self.store.store_partial_state_room(
room_id,
ret.servers_in_room,
ret.event.event_id,
self.store.get_device_stream_token(),
)

try:
max_stream_id = (
Expand Down
23 changes: 21 additions & 2 deletions synapse/storage/databases/main/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,28 +1777,47 @@ async def store_partial_state_room(
self,
room_id: str,
servers: Collection[str],
join_event_id: str,
device_lists_stream_id: int,
) -> None:
"""Mark the given room as containing events with partial state
"""Mark the given room as containing events with partial state.
We also store additional data that describes _when_ we first partial-joined this
room, which helps us to keep other homeservers in sync when we finally fully
join this room.
Args:
room_id: the ID of the room
servers: other servers known to be in the room
join_event_id: the event ID of the join membership event returned in the
(partial) /send_join response.
device_lists_stream_id: the device_lists stream ID at the time when we first
joined the room.
"""
await self.db_pool.runInteraction(
"store_partial_state_room",
self._store_partial_state_room_txn,
room_id,
servers,
join_event_id,
device_lists_stream_id,
)

def _store_partial_state_room_txn(
self, txn: LoggingTransaction, room_id: str, servers: Collection[str]
self,
txn: LoggingTransaction,
room_id: str,
servers: Collection[str],
join_event_id: str,
device_lists_stream_id: int,
) -> None:
DatabasePool.simple_insert_txn(
txn,
table="partial_state_rooms",
values={
"room_id": room_id,
"device_lists_stream_id": device_lists_stream_id,
"join_event_id": join_event_id,
},
)
DatabasePool.simple_insert_many_txn(
Expand Down

0 comments on commit de0002b

Please sign in to comment.