summary refs log tree commit diff
diff options
context:
space:
mode:
authorH. Shay <hillerys@element.io>2022-04-19 12:36:53 -0700
committerErik Johnston <erik@matrix.org>2022-04-21 11:49:51 +0100
commit1736be0678ce9d7ce869337f4ccedf022f7730b0 (patch)
treed08c8048c511f79d190c43b352d7dd16de6831d8
parentfix newsfragment (diff)
downloadsynapse-1736be0678ce9d7ce869337f4ccedf022f7730b0.tar.xz
add max_short_retries to config and rename min_retry_delay -> max_short_retry_delay
-rw-r--r--synapse/config/experimental.py3
-rw-r--r--synapse/http/matrixfederationclient.py11
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(