summary refs log tree commit diff
path: root/synapse/server.py
diff options
context:
space:
mode:
authorSean Quah <8349537+squahtx@users.noreply.github.com>2023-01-13 00:16:21 +0000
committerGitHub <noreply@github.com>2023-01-13 00:16:21 +0000
commit772e8c23856e27960caba4dd87af42401b6c0cac (patch)
tree11d8c1cb6bb8780277d4caa5d67bb2334b0222f4 /synapse/server.py
parentMerge branch 'release-v1.75' into develop (diff)
downloadsynapse-772e8c23856e27960caba4dd87af42401b6c0cac.tar.xz
Fix stack overflow in `_PerHostRatelimiter` due to synchronous requests (#14812)
When there are many synchronous requests waiting on a
`_PerHostRatelimiter`, each request will be started recursively just
after the previous request has completed. Under the right conditions,
this leads to stack exhaustion.

A common way for requests to become synchronous is when the remote
client disconnects early, because the homeserver is overloaded and slow
to respond.

Avoid stack exhaustion under these conditions by deferring subsequent
requests until the next reactor tick.

Fixes #14480.

Signed-off-by: Sean Quah <seanq@matrix.org>
Diffstat (limited to 'synapse/server.py')
-rw-r--r--synapse/server.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/synapse/server.py b/synapse/server.py
index f4ab94c4f3..c8752baa5a 100644
--- a/synapse/server.py
+++ b/synapse/server.py
@@ -768,6 +768,7 @@ class HomeServer(metaclass=abc.ABCMeta):
     @cache_in_self
     def get_federation_ratelimiter(self) -> FederationRateLimiter:
         return FederationRateLimiter(
+            self.get_reactor(),
             self.get_clock(),
             config=self.config.ratelimiting.rc_federation,
             metrics_name="federation_servlets",