mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-07 02:44:57 -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
|
@ -1953,3 +1953,31 @@ class EventsWorkerStore(SQLBaseStore):
|
|||
"get_event_id_for_timestamp_txn",
|
||||
get_event_id_for_timestamp_txn,
|
||||
)
|
||||
|
||||
@cachedList("is_partial_state_event", list_name="event_ids")
|
||||
async def get_partial_state_events(
|
||||
self, event_ids: Collection[str]
|
||||
) -> Dict[str, bool]:
|
||||
"""Checks which of the given events have partial state"""
|
||||
result = await self.db_pool.simple_select_many_batch(
|
||||
table="partial_state_events",
|
||||
column="event_id",
|
||||
iterable=event_ids,
|
||||
retcols=["event_id"],
|
||||
desc="get_partial_state_events",
|
||||
)
|
||||
# convert the result to a dict, to make @cachedList work
|
||||
partial = {r["event_id"] for r in result}
|
||||
return {e_id: e_id in partial for e_id in event_ids}
|
||||
|
||||
@cached()
|
||||
async def is_partial_state_event(self, event_id: str) -> bool:
|
||||
"""Checks if the given event has partial state"""
|
||||
result = await self.db_pool.simple_select_one_onecol(
|
||||
table="partial_state_events",
|
||||
keyvalues={"event_id": event_id},
|
||||
retcol="1",
|
||||
allow_none=True,
|
||||
desc="is_partial_state_event",
|
||||
)
|
||||
return result is not None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue