From 1736be0678ce9d7ce869337f4ccedf022f7730b0 Mon Sep 17 00:00:00 2001 From: "H. Shay" Date: Tue, 19 Apr 2022 12:36:53 -0700 Subject: add max_short_retries to config and rename min_retry_delay -> max_short_retry_delay --- synapse/config/experimental.py | 3 ++- synapse/http/matrixfederationclient.py | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index 2386d38df0..adb98feb60 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -85,5 +85,6 @@ class ExperimentalConfig(Config): # Allow for the configuration of max request retries and min/max retry delays # in the matrix federation client self.max_long_retry_delay = experimental.get("max_long_retry_delay", 60) - self.min_retry_delay = experimental.get("min_retry_delay", 2) + self.max_short_retry_delay = experimental.get("max_short_retry_delay", 2) self.max_long_retries = experimental.get("max_long_retries", 10) + self.max_short_retries = experimental.get("max_short_retries", 3) \ No newline at end of file diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py index 5c72fd74b5..df99c53041 100644 --- a/synapse/http/matrixfederationclient.py +++ b/synapse/http/matrixfederationclient.py @@ -92,7 +92,6 @@ incoming_responses_counter = Counter( # need a generous limit here. MAX_RESPONSE_SIZE = 100 * 1024 * 1024 -MAX_SHORT_RETRIES = 3 MAXINT = sys.maxsize @@ -346,9 +345,11 @@ class MatrixFederationHttpClient: self._store = hs.get_datastores().main self.version_string_bytes = hs.version_string.encode("ascii") self.default_timeout = 60 + self.max_long_retry_delay = hs.config.experimental.max_long_retry_delay - self.min_retry_delay = hs.config.experimental.min_retry_delay + self.max_short_retry_delay = hs.config.experimental.max_short_retry_delay self.max_long_retries = hs.config.experimental.max_long_retries + self.max_short_retries = hs.config.experimental.max_short_retries def schedule(x): self.reactor.callLater(_EPSILON, x) @@ -513,7 +514,7 @@ class MatrixFederationHttpClient: if long_retries: retries_left = self.max_long_retries else: - retries_left = MAX_SHORT_RETRIES + retries_left = self.max_short_retries url_bytes = request.uri url_str = url_bytes.decode("ascii") @@ -662,8 +663,8 @@ class MatrixFederationHttpClient: delay = min(delay, self.max_long_retry_delay) delay *= random.uniform(0.8, 1.4) else: - delay = 0.5 * 2 ** (MAX_SHORT_RETRIES - retries_left) - delay = min(delay, self.min_retry_delay) + delay = 0.5 * 2 ** (self.max_short_retries - retries_left) + delay = min(delay, self.max_short_retry_delay) delay *= random.uniform(0.8, 1.4) logger.debug( -- cgit 1.4.1