mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-13 10:22:10 -04:00
Faster joins: persist to database (#12012)
When we get a partial_state response from send_join, store information in the database about it: * store a record about the room as a whole having partial state, and stash the list of member servers too. * flag the join event itself as having partial state * also, for any new events whose prev-events are partial-stated, note that they will *also* be partial-stated. We don't yet make any attempt to interpret this data, so API calls (and a bunch of other things) are just going to get incorrect data.
This commit is contained in:
parent
4ccc2d09aa
commit
e2e1d90a5e
12 changed files with 297 additions and 32 deletions
|
@ -20,6 +20,7 @@ from typing import (
|
|||
TYPE_CHECKING,
|
||||
Any,
|
||||
Awaitable,
|
||||
Collection,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
|
@ -1543,6 +1544,42 @@ class RoomStore(RoomBackgroundUpdateStore, RoomWorkerStore):
|
|||
lock=False,
|
||||
)
|
||||
|
||||
async def store_partial_state_room(
|
||||
self,
|
||||
room_id: str,
|
||||
servers: Collection[str],
|
||||
) -> None:
|
||||
"""Mark the given room as containing events with partial state
|
||||
|
||||
Args:
|
||||
room_id: the ID of the room
|
||||
servers: other servers known to be in the room
|
||||
"""
|
||||
await self.db_pool.runInteraction(
|
||||
"store_partial_state_room",
|
||||
self._store_partial_state_room_txn,
|
||||
room_id,
|
||||
servers,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _store_partial_state_room_txn(
|
||||
txn: LoggingTransaction, room_id: str, servers: Collection[str]
|
||||
) -> None:
|
||||
DatabasePool.simple_insert_txn(
|
||||
txn,
|
||||
table="partial_state_rooms",
|
||||
values={
|
||||
"room_id": room_id,
|
||||
},
|
||||
)
|
||||
DatabasePool.simple_insert_many_txn(
|
||||
txn,
|
||||
table="partial_state_rooms_servers",
|
||||
keys=("room_id", "server_name"),
|
||||
values=((room_id, s) for s in servers),
|
||||
)
|
||||
|
||||
async def maybe_store_room_on_outlier_membership(
|
||||
self, room_id: str, room_version: RoomVersion
|
||||
) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue