mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-09 22:12:16 -04:00
Faster joins: Refactor handling of servers in room (#14954)
Ensure that the list of servers in a partial state room always contains the server we joined off. Also refactor `get_partial_state_servers_at_join` to return `None` when the given room is no longer partial stated, to explicitly indicate when the room has partial state. Otherwise it's not clear whether an empty list means that the room has full state, or the room is partial stated, but the server we joined off told us that there are no servers in the room. Signed-off-by: Sean Quah <seanq@matrix.org>
This commit is contained in:
parent
8e9fc28c6a
commit
0a686d1d13
9 changed files with 77 additions and 37 deletions
|
@ -20,7 +20,17 @@ import itertools
|
|||
import logging
|
||||
from enum import Enum
|
||||
from http import HTTPStatus
|
||||
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Set, Tuple, Union
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
AbstractSet,
|
||||
Dict,
|
||||
Iterable,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
import attr
|
||||
from prometheus_client import Histogram
|
||||
|
@ -169,7 +179,7 @@ class FederationHandler:
|
|||
# A dictionary mapping room IDs to (initial destination, other destinations)
|
||||
# tuples.
|
||||
self._partial_state_syncs_maybe_needing_restart: Dict[
|
||||
str, Tuple[Optional[str], StrCollection]
|
||||
str, Tuple[Optional[str], AbstractSet[str]]
|
||||
] = {}
|
||||
# A lock guarding the partial state flag for rooms.
|
||||
# When the lock is held for a given room, no other concurrent code may
|
||||
|
@ -1720,7 +1730,7 @@ class FederationHandler:
|
|||
def _start_partial_state_room_sync(
|
||||
self,
|
||||
initial_destination: Optional[str],
|
||||
other_destinations: StrCollection,
|
||||
other_destinations: AbstractSet[str],
|
||||
room_id: str,
|
||||
) -> None:
|
||||
"""Starts the background process to resync the state of a partial state room,
|
||||
|
@ -1802,7 +1812,7 @@ class FederationHandler:
|
|||
async def _sync_partial_state_room(
|
||||
self,
|
||||
initial_destination: Optional[str],
|
||||
other_destinations: StrCollection,
|
||||
other_destinations: AbstractSet[str],
|
||||
room_id: str,
|
||||
) -> None:
|
||||
"""Background process to resync the state of a partial-state room
|
||||
|
@ -1939,7 +1949,7 @@ class FederationHandler:
|
|||
|
||||
def _prioritise_destinations_for_partial_state_resync(
|
||||
initial_destination: Optional[str],
|
||||
other_destinations: StrCollection,
|
||||
other_destinations: AbstractSet[str],
|
||||
room_id: str,
|
||||
) -> StrCollection:
|
||||
"""Work out the order in which we should ask servers to resync events.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue