summary refs log tree commit diff
path: root/synapse/federation/federation_server.py
diff options
context:
space:
mode:
authorreivilibre <oliverw@matrix.org>2022-08-04 15:27:04 +0000
committerGitHub <noreply@github.com>2022-08-04 16:27:04 +0100
commite9e6aacfbe016922ed6a25071c0e9ce77334b4e8 (patch)
tree8c78022941d7e7c910917b0fde86b32382446846 /synapse/federation/federation_server.py
parentOptimise async get event lookups (#13435) (diff)
downloadsynapse-e9e6aacfbe016922ed6a25071c0e9ce77334b4e8.tar.xz
Faster Room Joins: prevent Synapse from answering federated join requests for a room which it has not fully joined yet. (#13416)
Diffstat (limited to 'synapse/federation/federation_server.py')
-rw-r--r--synapse/federation/federation_server.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py
index 1d60137411..db4b83a505 100644
--- a/synapse/federation/federation_server.py
+++ b/synapse/federation/federation_server.py
@@ -843,8 +843,25 @@ class FederationServer(FederationBase):
                 Codes.BAD_JSON,
             )
 
+        # Note that get_room_version throws if the room does not exist here.
         room_version = await self.store.get_room_version(room_id)
 
+        if await self.store.is_partial_state_room(room_id):
+            # If our server is still only partially joined, we can't give a complete
+            # response to /send_join, /send_knock or /send_leave.
+            # This is because we will not be able to provide the server list (for partial
+            # joins) or the full state (for full joins).
+            # Return a 404 as we would if we weren't in the room at all.
+            logger.info(
+                f"Rejecting /send_{membership_type} to %s because it's a partial state room",
+                room_id,
+            )
+            raise SynapseError(
+                404,
+                f"Unable to handle /send_{membership_type} right now; this server is not fully joined.",
+                errcode=Codes.NOT_FOUND,
+            )
+
         if membership_type == Membership.KNOCK and not room_version.msc2403_knocking:
             raise SynapseError(
                 403,