Faster joins: use initial list of servers if we don't have the full state yet (#14408)

Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
This commit is contained in:
Mathieu Velten 2022-11-24 18:09:47 +01:00 committed by GitHub
parent c2e06c36d4
commit 39cde585bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

1
changelog.d/14408.misc Normal file
View File

@ -0,0 +1 @@
Faster joins: send events to initial list of servers if we don't have the full state yet.

View File

@ -434,7 +434,23 @@ class FederationSender(AbstractFederationSender):
# If there are no prev event IDs then the state is empty # If there are no prev event IDs then the state is empty
# and so no remote servers in the room # and so no remote servers in the room
destinations = set() destinations = set()
else:
if destinations is None:
# During partial join we use the set of servers that we got
# when beginning the join. It's still possible that we send
# events to servers that left the room in the meantime, but
# we consider that an acceptable risk since it is only our own
# events that we leak and not other server's ones.
partial_state_destinations = (
await self.store.get_partial_state_servers_at_join(
event.room_id
)
)
if len(partial_state_destinations) > 0:
destinations = partial_state_destinations
if destinations is None:
# We check the external cache for the destinations, which is # We check the external cache for the destinations, which is
# stored per state group. # stored per state group.