diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2022-04-12 14:23:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 13:23:43 +0000 |
commit | 320186319ac4f1d16f8f964d92db8921a4b1073e (patch) | |
tree | 965d970fdea98a16bd2c23af3aabb0c9493eceb8 /synapse/storage/databases/main/room.py | |
parent | Remove references to unstable identifiers from MSC3440. (#12382) (diff) | |
download | synapse-320186319ac4f1d16f8f964d92db8921a4b1073e.tar.xz |
Resync state after partial-state join (#12394)
We work through all the events with partial state, updating the state at each of them. Once it's done, we recalculate the state for the whole room, and then mark the room as having complete state.
Diffstat (limited to 'synapse/storage/databases/main/room.py')
-rw-r--r-- | synapse/storage/databases/main/room.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/room.py b/synapse/storage/databases/main/room.py index 18b1acd9e1..87e9482c60 100644 --- a/synapse/storage/databases/main/room.py +++ b/synapse/storage/databases/main/room.py @@ -1077,6 +1077,37 @@ class RoomWorkerStore(CacheInvalidationWorkerStore): get_rooms_for_retention_period_in_range_txn, ) + async def clear_partial_state_room(self, room_id: str) -> bool: + # this can race with incoming events, so we watch out for FK errors. + # TODO(faster_joins): this still doesn't completely fix the race, since the persist process + # is not atomic. I fear we need an application-level lock. + try: + await self.db_pool.runInteraction( + "clear_partial_state_room", self._clear_partial_state_room_txn, room_id + ) + return True + except self.db_pool.engine.module.DatabaseError as e: + # TODO(faster_joins): how do we distinguish between FK errors and other errors? + logger.warning( + "Exception while clearing lazy partial-state-room %s, retrying: %s", + room_id, + e, + ) + return False + + @staticmethod + def _clear_partial_state_room_txn(txn: LoggingTransaction, room_id: str) -> None: + DatabasePool.simple_delete_txn( + txn, + table="partial_state_rooms_servers", + keyvalues={"room_id": room_id}, + ) + DatabasePool.simple_delete_one_txn( + txn, + table="partial_state_rooms", + keyvalues={"room_id": room_id}, + ) + class _BackgroundUpdates: REMOVE_TOMESTONED_ROOMS_BG_UPDATE = "remove_tombstoned_rooms_from_directory" |