mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-26 19:47:05 +03:00
Fix deleting state groups during room purge.
And fix the tests to actually test that things got deleted.
This commit is contained in:
parent
71f3bd734f
commit
5c3363233c
2 changed files with 17 additions and 14 deletions
|
@ -1633,7 +1633,20 @@ class EventsStore(
|
|||
return self.runInteraction("purge_room", self._purge_room_txn, room_id)
|
||||
|
||||
def _purge_room_txn(self, txn, room_id):
|
||||
# First delete tables which lack an index on room_id but have one on event_id
|
||||
# First we fetch all the state groups that should be deleted, before
|
||||
# we delete that information.
|
||||
txn.execute(
|
||||
"""
|
||||
SELECT DISTINCT state_group FROM events
|
||||
INNER JOIN event_to_state_groups USING(event_id)
|
||||
WHERE events.room_id = ?
|
||||
""",
|
||||
(room_id,),
|
||||
)
|
||||
|
||||
state_groups = [row[0] for row in txn]
|
||||
|
||||
# Now we delete tables which lack an index on room_id but have one on event_id
|
||||
for table in (
|
||||
"event_auth",
|
||||
"event_edges",
|
||||
|
@ -1717,18 +1730,6 @@ class EventsStore(
|
|||
# index on them. In any case we should be clearing out 'stream' tables
|
||||
# periodically anyway (#5888)
|
||||
|
||||
# Now we fetch all the state groups that should be deleted.
|
||||
txn.execute(
|
||||
"""
|
||||
SELECT DISTINCT state_group FROM events
|
||||
INNER JOIN event_to_state_groups USING(event_id)
|
||||
WHERE events.room_id = ?
|
||||
""",
|
||||
(room_id,),
|
||||
)
|
||||
|
||||
state_groups = [row[0] for row in txn]
|
||||
|
||||
# TODO: we could probably usefully do a bunch of cache invalidation here
|
||||
|
||||
logger.info("[purge] done")
|
||||
|
|
|
@ -628,10 +628,12 @@ class PurgeRoomTestCase(unittest.HomeserverTestCase):
|
|||
"local_invites",
|
||||
"room_account_data",
|
||||
"room_tags",
|
||||
"state_groups",
|
||||
"state_groups_state",
|
||||
):
|
||||
count = self.get_success(
|
||||
self.store._simple_select_one_onecol(
|
||||
table="events",
|
||||
table=table,
|
||||
keyvalues={"room_id": room_id},
|
||||
retcol="COUNT(*)",
|
||||
desc="test_purge_room",
|
||||
|
|
Loading…
Reference in a new issue