From 409ef7bf0e0728b62dd239b14a636f4fdc3a5d3b Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Wed, 7 Sep 2022 20:53:21 +0100 Subject: [PATCH] Remove old populate current_state_events membership background job --- synapse/storage/databases/main/roommember.py | 68 -------------------- 1 file changed, 68 deletions(-) diff --git a/synapse/storage/databases/main/roommember.py b/synapse/storage/databases/main/roommember.py index 3c860137d7b6..56271b356542 100644 --- a/synapse/storage/databases/main/roommember.py +++ b/synapse/storage/databases/main/roommember.py @@ -64,7 +64,6 @@ _MEMBERSHIP_PROFILE_UPDATE_NAME = "room_membership_profile_update" -_CURRENT_STATE_MEMBERSHIP_UPDATE_NAME = "current_state_events_membership" @attr.s(frozen=True, slots=True, auto_attribs=True) @@ -1255,10 +1254,6 @@ def __init__( self.db_pool.updates.register_background_update_handler( _MEMBERSHIP_PROFILE_UPDATE_NAME, self._background_add_membership_profile ) - self.db_pool.updates.register_background_update_handler( - _CURRENT_STATE_MEMBERSHIP_UPDATE_NAME, - self._background_current_state_membership, - ) self.db_pool.updates.register_background_index_update( "room_membership_forgotten_idx", index_name="room_memberships_user_room_forgotten", @@ -1341,69 +1336,6 @@ def add_membership_profile_txn(txn: LoggingTransaction) -> int: return result - async def _background_current_state_membership( - self, progress: JsonDict, batch_size: int - ) -> int: - """Update the new membership column on current_state_events. - - This works by iterating over all rooms in alphebetical order. - """ - - def _background_current_state_membership_txn( - txn: LoggingTransaction, last_processed_room: str - ) -> Tuple[int, bool]: - processed = 0 - while processed < batch_size: - txn.execute( - """ - SELECT MIN(room_id) FROM current_state_events WHERE room_id > ? - """, - (last_processed_room,), - ) - row = txn.fetchone() - if not row or not row[0]: - return processed, True - - (next_room,) = row - - sql = """ - UPDATE current_state_events - SET membership = ( - SELECT membership FROM room_memberships - WHERE event_id = current_state_events.event_id - ) - WHERE room_id = ? - """ - txn.execute(sql, (next_room,)) - processed += txn.rowcount - - last_processed_room = next_room - - self.db_pool.updates._background_update_progress_txn( - txn, - _CURRENT_STATE_MEMBERSHIP_UPDATE_NAME, - {"last_processed_room": last_processed_room}, - ) - - return processed, False - - # If we haven't got a last processed room then just use the empty - # string, which will compare before all room IDs correctly. - last_processed_room = progress.get("last_processed_room", "") - - row_count, finished = await self.db_pool.runInteraction( - "_background_current_state_membership_update", - _background_current_state_membership_txn, - last_processed_room, - ) - - if finished: - await self.db_pool.updates._end_background_update( - _CURRENT_STATE_MEMBERSHIP_UPDATE_NAME - ) - - return row_count - class RoomMemberStore( RoomMemberWorkerStore,