element-hq / element-hq/synapse

`state_groups` (& `state_groups_state` & `state_group_edges`) are not fully purged alongside the rooms

Open
#12,821 2 comments 6 reactions 0 assignees View on GitHub
A-Database A-purge-room O-Occasional roadmap S-Minor T-Defect
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#12821](https://github.com/matrix-org/synapse/issues/12821).

---

While investigating my database size, I found that `state_groups_state` and `state_groups` hold many stale entries that reference old rooms that have long since been removed from `rooms` and all related events tables.

It appears these are not purged alongside other tables, particularly via the `DELETE _synapse/admin/v1/rooms/{room_id}` API (with `purge: true`)

### Version information

- **Version**: Synapse 1.57.1

- **Install method**: Docker image

- **Platform**: Linux (Debian)

Contributor guide

Open the contributing guide

Research direction

Start by tracing the DELETE /_synapse/admin/v1/rooms/{room_id} API with purge: true and inspect how it removes data from rooms and related event tables. Compare that cleanup with state_groups, state_groups_state, and state_group_edges; done means stale rows for a purged room are removed without affecting retained rooms.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.