From 8e37ece015c8afd97572bdc742981792b02c6700 Mon Sep 17 00:00:00 2001
From: David Robertson <davidr@element.io>
Date: Wed, 25 Jan 2023 16:11:06 +0000
Subject: [PATCH] Bump the client-side timeout for /state (#14912)

* Bump the client-side timeout for /state

to allow faster joins resyncs the chance to complete for large rooms.
We have seen this fair poorly (~90s for Matrix HQ's /state) in testing,
causing the resync to advance to another HS who hasn't seen our join yet.

* Changelog

* Milliseconds!!!!
---
 changelog.d/14912.misc                 | 1 +
 synapse/federation/transport/client.py | 4 ++++
 2 files changed, 5 insertions(+)
 create mode 100644 changelog.d/14912.misc

diff --git a/changelog.d/14912.misc b/changelog.d/14912.misc
new file mode 100644
index 0000000000..9dbc6b3424
--- /dev/null
+++ b/changelog.d/14912.misc
@@ -0,0 +1 @@
+Faster joins: allow the resync process more time to fetch `/state` ids.
diff --git a/synapse/federation/transport/client.py b/synapse/federation/transport/client.py
index 556883f079..682666ab36 100644
--- a/synapse/federation/transport/client.py
+++ b/synapse/federation/transport/client.py
@@ -102,6 +102,10 @@ class TransportLayerClient:
             destination,
             path=path,
             args={"event_id": event_id},
+            # This can take a looooooong time for large rooms. Give this a generous
+            # timeout of 10 minutes to avoid the partial state resync timing out early
+            # and trying a bunch of servers who haven't seen our join yet.
+            timeout=600_000,
             parser=_StateParser(room_version),
         )
 
-- 
GitLab