Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Delete rows from device_inbox in the background when deleting a device #16098

Closed
erikjohnston opened this issue Aug 10, 2023 · 1 comment · Fixed by #16240
Closed

Delete rows from device_inbox in the background when deleting a device #16098

erikjohnston opened this issue Aug 10, 2023 · 1 comment · Fixed by #16240
Assignees
Labels
S-Minor Blocks non-critical functionality, workarounds exist. T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Comments

@erikjohnston
Copy link
Member

device_inbox can have a huge number of rows when deleting a user, which makes user deletion slow and costly. Instead, we should do the deletion of rows in device_inbox as a background task (potentially using #15891).

@erikjohnston erikjohnston added S-Minor Blocks non-critical functionality, workarounds exist. T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. labels Aug 10, 2023
@erikjohnston
Copy link
Member Author

I think we can use the new TaskScheduler class to add a task in the background to delete all to-device messages for the device after deletion. The best way of doing that would likely be to just repeatedly do DELETE FROM device_inbox WHERE user_id = ? AND device_id = ? AND stream_ordering < ? LIMIT 100. Care should be taken to only delete to-device messages from before the deletion, to handle the case where the device logs back in again with the same device ID.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-Minor Blocks non-critical functionality, workarounds exist. T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants