element-hq / element-hq/synapse

Consider adding (more?) foreign key constraints

Open
#12,817 1 comment 1 reaction 0 assignees View on GitHub
A-Corruption A-Database T-Task
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

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

---

**Description:**

Because of an unfortunate event, I ended up on my server with some extra accounts and rooms I wanted to delete. I used the proper (`admin/v1/deactivate`, `admin/v1/rooms` and `admin/v2/rooms`) APIs of Synapse, but it left me with a database that appears inconsistent:

- I had 10 GB of entries in `current_state_delta_stream`, `state_groups_state` and `state_groups`, but the rooms were missing from `room_stats_state`
- half of my rows in `state_group_edges` don't point to `state_groups`

I'd like to clean these up, but it's hard for me because I'm not familiar with the database structure and there are no constraints to help with it.

Adding some constraints would help avoid inconsistent states (cf. #11779) and even work as documentation. If you're worried about the performance impact, they could added in a disabled state.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.