Skip to content

Commit a963f57

Browse files
authoredJun 6, 2024··
Don't try and resync devices for down hosts (#17273)
It's just a waste of time if we won't even query the remote host as its marked as down.
1 parent 3f06bbc commit a963f57

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed
 

‎changelog.d/17273.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Don't try and resync devices for remote users whose servers are marked as down.

‎synapse/handlers/e2e_keys.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
from synapse.util import json_decoder
4646
from synapse.util.async_helpers import Linearizer, concurrently_execute
4747
from synapse.util.cancellation import cancellable
48-
from synapse.util.retryutils import NotRetryingDestination
48+
from synapse.util.retryutils import (
49+
NotRetryingDestination,
50+
filter_destinations_by_retry_limiter,
51+
)
4952

5053
if TYPE_CHECKING:
5154
from synapse.server import HomeServer
@@ -268,10 +271,8 @@ async def query_devices(
268271
"%d destinations to query devices for", len(remote_queries_not_in_cache)
269272
)
270273

271-
async def _query(
272-
destination_queries: Tuple[str, Dict[str, Iterable[str]]]
273-
) -> None:
274-
destination, queries = destination_queries
274+
async def _query(destination: str) -> None:
275+
queries = remote_queries_not_in_cache[destination]
275276
return await self._query_devices_for_destination(
276277
results,
277278
cross_signing_keys,
@@ -281,9 +282,20 @@ async def _query(
281282
timeout,
282283
)
283284

285+
# Only try and fetch keys for destinations that are not marked as
286+
# down.
287+
filtered_destinations = await filter_destinations_by_retry_limiter(
288+
remote_queries_not_in_cache.keys(),
289+
self.clock,
290+
self.store,
291+
# Let's give an arbitrary grace period for those hosts that are
292+
# only recently down
293+
retry_due_within_ms=60 * 1000,
294+
)
295+
284296
await concurrently_execute(
285297
_query,
286-
remote_queries_not_in_cache.items(),
298+
filtered_destinations,
287299
10,
288300
delay_cancellation=True,
289301
)

0 commit comments

Comments
 (0)
Please sign in to comment.