From b3ab301fd2669b21bb01263e4ef7ae3111bf6519 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Mon, 22 Aug 2022 18:06:06 +0100 Subject: [PATCH 1/4] Don't block /make_knock if not fully joined to room --- synapse/federation/federation_server.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index 75fbc6073df9..b93e89cb99af 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -763,6 +763,16 @@ async def on_make_knock_request( The partial knock event. """ origin_host, _ = parse_server_name(origin) + + if self.store.is_partial_state_room(room_id): + # Before we do anything: check if the room is partial-stated. + # Note that checking the ACL (below) requires full state, for example. + raise SynapseError( + 404, + "Unable to handle /make_knock right now; this server is not fully joined.", + errcode=Codes.NOT_FOUND, + ) + await self.check_server_matches_acl(origin_host, room_id) room_version = await self.store.get_room_version(room_id) From 2e4fa75215a8a4f177a6d5e19c3254021467c647 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Mon, 22 Aug 2022 18:10:14 +0100 Subject: [PATCH 2/4] Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) --- changelog.d/13583.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/13583.bugfix diff --git a/changelog.d/13583.bugfix b/changelog.d/13583.bugfix new file mode 100644 index 000000000000..1e4ce5904bc1 --- /dev/null +++ b/changelog.d/13583.bugfix @@ -0,0 +1 @@ +Faster Room Joins: fix `/make_knock` blocking indefinitely when the room in question is a partial-stated room. \ No newline at end of file From 406f58d7f3f1c92ddaa6cdfd4090716f5ea21e2c Mon Sep 17 00:00:00 2001 From: reivilibre Date: Tue, 23 Aug 2022 17:32:30 +0100 Subject: [PATCH 3/4] Update synapse/federation/federation_server.py Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> --- synapse/federation/federation_server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index b93e89cb99af..eb58d596d789 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -766,7 +766,8 @@ async def on_make_knock_request( if self.store.is_partial_state_room(room_id): # Before we do anything: check if the room is partial-stated. - # Note that checking the ACL (below) requires full state, for example. + # Note that at the time this check was added, `on_make_knock_request` would + # block due to https://github.com/matrix-org/synapse/issues/12997. raise SynapseError( 404, "Unable to handle /make_knock right now; this server is not fully joined.", From 0eaf9e7a7b8e33dbbc72de791b6fd47bdbb590fd Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 23 Aug 2022 17:54:41 +0100 Subject: [PATCH 4/4] fix: use await --- synapse/federation/federation_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index eb58d596d789..3bf84cf62515 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -764,7 +764,7 @@ async def on_make_knock_request( """ origin_host, _ = parse_server_name(origin) - if self.store.is_partial_state_room(room_id): + if await self.store.is_partial_state_room(room_id): # Before we do anything: check if the room is partial-stated. # Note that at the time this check was added, `on_make_knock_request` would # block due to https://github.com/matrix-org/synapse/issues/12997.