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

Commit a7e506d

Browse files
authored
Reduce amount of state we pull out when attempting to send catchup PDUs. (#12963)
* Don't pull out state for catchup * Newsfile * Merge newsfile
1 parent d2fd7f7 commit a7e506d

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

changelog.d/12963.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reduce the amount of state we pull from the DB.

synapse/federation/sender/per_destination_queue.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from synapse.metrics.background_process_metrics import run_as_background_process
3838
from synapse.types import ReadReceipt
3939
from synapse.util.retryutils import NotRetryingDestination, get_retry_limiter
40+
from synapse.visibility import filter_events_for_server
4041

4142
if TYPE_CHECKING:
4243
import synapse.server
@@ -77,6 +78,7 @@ def __init__(
7778
):
7879
self._server_name = hs.hostname
7980
self._clock = hs.get_clock()
81+
self._storage_controllers = hs.get_storage_controllers()
8082
self._store = hs.get_datastores().main
8183
self._transaction_manager = transaction_manager
8284
self._instance_name = hs.get_instance_name()
@@ -442,6 +444,12 @@ async def _catch_up_transmission_loop(self) -> None:
442444
"This should not happen." % event_ids
443445
)
444446

447+
logger.info(
448+
"Catching up destination %s with %d PDUs",
449+
self._destination,
450+
len(catchup_pdus),
451+
)
452+
445453
# We send transactions with events from one room only, as its likely
446454
# that the remote will have to do additional processing, which may
447455
# take some time. It's better to give it small amounts of work
@@ -487,19 +495,20 @@ async def _catch_up_transmission_loop(self) -> None:
487495
):
488496
continue
489497

490-
# Filter out events where the server is not in the room,
491-
# e.g. it may have left/been kicked. *Ideally* we'd pull
492-
# out the kick and send that, but it's a rare edge case
493-
# so we don't bother for now (the server that sent the
494-
# kick should send it out if its online).
495-
hosts = await self._state.get_hosts_in_room_at_events(
496-
p.room_id, [p.event_id]
497-
)
498-
if self._destination not in hosts:
499-
continue
500-
501498
new_pdus.append(p)
502499

500+
# Filter out events where the server is not in the room,
501+
# e.g. it may have left/been kicked. *Ideally* we'd pull
502+
# out the kick and send that, but it's a rare edge case
503+
# so we don't bother for now (the server that sent the
504+
# kick should send it out if its online).
505+
new_pdus = await filter_events_for_server(
506+
self._storage_controllers,
507+
self._destination,
508+
new_pdus,
509+
redact=False,
510+
)
511+
503512
# If we've filtered out all the extremities, fall back to
504513
# sending the original event. This should ensure that the
505514
# server gets at least some of missed events (especially if

0 commit comments

Comments
 (0)