Properly purge state groups tables when purging a room (#18024)

Currently purging a complex room can lead to a lot of orphaned rows left
behind in the state groups tables.
It seems it is because we are loosing track of state groups sometimes.

This change uses the `room_id` indexed column of `state_groups` table to
decide what to delete instead of doing an indirection through
`event_to_state_groups`.

Related to https://github.com/element-hq/synapse/issues/3364.

### Pull Request Checklist

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct
(run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: Erik Johnston <erikj@jki.re>
This commit is contained in:
Mathieu Velten
2025-01-06 16:32:18 +01:00
committed by GitHub
parent 6306de8e16
commit b3ba501c52
5 changed files with 35 additions and 70 deletions

View File

@@ -3050,7 +3050,7 @@ PURGE_TABLES = [
"pusher_throttle",
"room_account_data",
"room_tags",
# "state_groups", # Current impl leaves orphaned state groups around.
"state_groups",
"state_groups_state",
"federation_inbound_events_staging",
]