diff --git a/synapse/handlers/e2e_keys.py b/synapse/handlers/e2e_keys.py
index 668cec513b..f78e66ad0a 100644
--- a/synapse/handlers/e2e_keys.py
+++ b/synapse/handlers/e2e_keys.py
@@ -291,13 +291,20 @@ class E2eKeysHandler:
# Only try and fetch keys for destinations that are not marked as
# down.
- filtered_destinations = await filter_destinations_by_retry_limiter(
- remote_queries_not_in_cache.keys(),
- self.clock,
- self.store,
- # Let's give an arbitrary grace period for those hosts that are
- # only recently down
- retry_due_within_ms=60 * 1000,
+ unfiltered_destinations = remote_queries_not_in_cache.keys()
+ filtered_destinations = set(
+ await filter_destinations_by_retry_limiter(
+ unfiltered_destinations,
+ self.clock,
+ self.store,
+ # Let's give an arbitrary grace period for those hosts that are
+ # only recently down
+ retry_due_within_ms=60 * 1000,
+ )
+ )
+ failures.update(
+ (dest, _NOT_READY_FOR_RETRY_FAILURE)
+ for dest in (unfiltered_destinations - filtered_destinations)
)
await concurrently_execute(
@@ -1641,6 +1648,9 @@ def _check_device_signature(
raise SynapseError(400, "Invalid signature", Codes.INVALID_SIGNATURE)
+_NOT_READY_FOR_RETRY_FAILURE = {"status": 503, "message": "Not ready for retry"}
+
+
def _exception_to_failure(e: Exception) -> JsonDict:
if isinstance(e, SynapseError):
return {"status": e.code, "errcode": e.errcode, "message": str(e)}
@@ -1649,7 +1659,7 @@ def _exception_to_failure(e: Exception) -> JsonDict:
return {"status": e.code, "message": str(e)}
if isinstance(e, NotRetryingDestination):
- return {"status": 503, "message": "Not ready for retry"}
+ return _NOT_READY_FOR_RETRY_FAILURE
# include ConnectionRefused and other errors
#
|