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

Commit

Permalink
Stop updating the converted_to_destinations column
Browse files Browse the repository at this point in the history
From now on, the `converted_to_destinations` column indicates rows that
need converting to outbound pokes, but does not indicate whether the
conversion has already taken place.

Signed-off-by: Sean Quah <seanq@matrix.org>
  • Loading branch information
Sean Quah committed Nov 22, 2022
1 parent 437d6d1 commit 4c6fd81
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 37 deletions.
2 changes: 0 additions & 2 deletions synapse/handlers/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,6 @@ async def _handle_new_device_update_async(self) -> None:
user_id=user_id,
device_id=device_id,
room_id=room_id,
stream_id=stream_id,
hosts=hosts,
context=opentracing_context,
)
Expand Down Expand Up @@ -860,7 +859,6 @@ async def handle_room_un_partial_stated(self, room_id: str) -> None:
user_id=user_id,
device_id=device_id,
room_id=room_id,
stream_id=None,
hosts=potentially_changed_hosts,
context=None,
)
Expand Down
42 changes: 9 additions & 33 deletions synapse/storage/databases/main/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2072,49 +2072,25 @@ async def add_device_list_outbound_pokes(
user_id: str,
device_id: str,
room_id: str,
stream_id: Optional[int],
hosts: Collection[str],
context: Optional[Dict[str, str]],
) -> None:
"""Queue the device update to be sent to the given set of hosts,
calculated from the room ID.
Marks the associated row in `device_lists_changes_in_room` as handled,
if `stream_id` is provided.
"""
if not hosts:
return

def add_device_list_outbound_pokes_txn(
txn: LoggingTransaction, stream_ids: List[int]
) -> None:
if hosts:
self._add_device_outbound_poke_to_stream_txn(
txn,
user_id=user_id,
device_id=device_id,
hosts=hosts,
stream_ids=stream_ids,
context=context,
)

if stream_id:
self.db_pool.simple_update_txn(
txn,
table="device_lists_changes_in_room",
keyvalues={
"user_id": user_id,
"device_id": device_id,
"stream_id": stream_id,
"room_id": room_id,
},
updatevalues={"converted_to_destinations": True},
)

if not hosts:
# If there are no hosts then we don't try and generate stream IDs.
return await self.db_pool.runInteraction(
"add_device_list_outbound_pokes",
add_device_list_outbound_pokes_txn,
[],
self._add_device_outbound_poke_to_stream_txn(
txn,
user_id=user_id,
device_id=device_id,
hosts=hosts,
stream_ids=stream_ids,
context=context,
)

async with self._device_list_id_gen.get_next_mult(len(hosts)) as stream_ids:
Expand Down
3 changes: 1 addition & 2 deletions tests/storage/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def add_device_change(self, user_id, device_ids, host):
"""

for device_id in device_ids:
stream_id = self.get_success(
self.get_success(
self.store.add_device_change_to_streams(
user_id, [device_id], ["!some:room"]
)
Expand All @@ -39,7 +39,6 @@ def add_device_change(self, user_id, device_ids, host):
user_id=user_id,
device_id=device_id,
room_id="!some:room",
stream_id=stream_id,
hosts=[host],
context={},
)
Expand Down

0 comments on commit 4c6fd81

Please sign in to comment.