mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-17 14:54:21 -05:00
Improve backfill robustness by trying more servers. (#13890)
Co-authored-by: Eric Eastwood <erice@element.io>
This commit is contained in:
parent
5f659d4a88
commit
73ecff7e9e
1
changelog.d/13890.misc
Normal file
1
changelog.d/13890.misc
Normal file
@ -0,0 +1 @@
|
||||
Improve backfill robustness by trying more servers when we get a `4xx` error back.
|
@ -417,6 +417,15 @@ class FederationHandler:
|
||||
|
||||
async def try_backfill(domains: Collection[str]) -> bool:
|
||||
# TODO: Should we try multiple of these at a time?
|
||||
|
||||
# Number of contacted remote homeservers that have denied our backfill
|
||||
# request with a 4xx code.
|
||||
denied_count = 0
|
||||
|
||||
# Maximum number of contacted remote homeservers that can deny our
|
||||
# backfill request with 4xx codes before we give up.
|
||||
max_denied_count = 5
|
||||
|
||||
for dom in domains:
|
||||
# We don't want to ask our own server for information we don't have
|
||||
if dom == self.server_name:
|
||||
@ -435,13 +444,33 @@ class FederationHandler:
|
||||
continue
|
||||
except HttpResponseException as e:
|
||||
if 400 <= e.code < 500:
|
||||
raise e.to_synapse_error()
|
||||
logger.warning(
|
||||
"Backfill denied from %s because %s [%d/%d]",
|
||||
dom,
|
||||
e,
|
||||
denied_count,
|
||||
max_denied_count,
|
||||
)
|
||||
denied_count += 1
|
||||
if denied_count >= max_denied_count:
|
||||
return False
|
||||
continue
|
||||
|
||||
logger.info("Failed to backfill from %s because %s", dom, e)
|
||||
continue
|
||||
except CodeMessageException as e:
|
||||
if 400 <= e.code < 500:
|
||||
raise
|
||||
logger.warning(
|
||||
"Backfill denied from %s because %s [%d/%d]",
|
||||
dom,
|
||||
e,
|
||||
denied_count,
|
||||
max_denied_count,
|
||||
)
|
||||
denied_count += 1
|
||||
if denied_count >= max_denied_count:
|
||||
return False
|
||||
continue
|
||||
|
||||
logger.info("Failed to backfill from %s because %s", dom, e)
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user