From 58ada265bb9d5fbd34d5c8df734b8c6a56cf8816 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 12 Sep 2019 12:23:18 +0100 Subject: [PATCH] Fix bug in calculating the federation retry backoff period This was intended to introduce an element of jitter; instead it gave you a 30/60 chance of resetting to zero. --- changelog.d/6025.bugfix | 1 + synapse/util/retryutils.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelog.d/6025.bugfix diff --git a/changelog.d/6025.bugfix b/changelog.d/6025.bugfix new file mode 100644 index 000000000000..50d7f9aab5e0 --- /dev/null +++ b/changelog.d/6025.bugfix @@ -0,0 +1 @@ +Fix bug in calculating the federation retry backoff period. \ No newline at end of file diff --git a/synapse/util/retryutils.py b/synapse/util/retryutils.py index 5b16a8161735..33263fe20f20 100644 --- a/synapse/util/retryutils.py +++ b/synapse/util/retryutils.py @@ -193,8 +193,9 @@ def __exit__(self, exc_type, exc_val, exc_tb): else: # We couldn't connect. if self.retry_interval: - self.retry_interval *= RETRY_MULTIPLIER - self.retry_interval *= int(random.uniform(0.8, 1.4)) + self.retry_interval = int( + self.retry_interval * RETRY_MULTIPLIER * random.uniform(0.8, 1.4) + ) if self.retry_interval >= MAX_RETRY_INTERVAL: self.retry_interval = MAX_RETRY_INTERVAL