element-hq / element-hq/synapse

Consider only inserting events we actually want to purge into `events_to_purge`

Open
#13,419 0 comments 0 reactions 0 assignees View on GitHub
A-Database A-Message-Retention-Policies T-Enhancement Z-Cleanup
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

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

---

In [`purge_history`](https://github.com/matrix-org/synapse/blob/2ee0b6ef4b78bada535beb30301cf0e01cbb7d81/synapse/storage/databases/main/purge_events.py#L30) we create a temporary table (`events_to_purge`, which we drop at the end of the purge) to store events we want to purge, alongside with whether or not we should delete them. It feels like there's room for improvement there, as in theory we should be able to only insert events we want to purge. I'm not sure how complicated this would be in practice, though. According to the code, we seem to use all the events in `events_to_purge`, even those not slated for deletion, to figure out state groups to remove. However according to comments it also seems to think that all events in that table _are_ slated for deletion.

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.