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

Delete stale non-e2e devices for users, take 2 #14595

Merged
merged 5 commits into from
Dec 9, 2022

Conversation

erikjohnston
Copy link
Member

This reintroduced #14038 and #14580, that were reverted in #14582.

The fix to the issue is to limit the number of devices we try and delete at once, and punt deleting the majority of devices to a background job.

erikjohnston and others added 5 commits December 5, 2022 10:09
This should help reduce the number of devices e.g. simple bots the repeatedly login rack up.

We only delete non-e2e devices as they should be safe to delete, whereas if we delete e2e devices for a user we may accidentally break their ability to receive e2e keys for a message.

Co-authored-by: Patrick Cloke <[email protected]>
Co-authored-by: Sean Quah <[email protected]>
…andling users with more than 50 non-E2E devices (#14580)
@erikjohnston erikjohnston marked this pull request as ready for review December 5, 2022 10:38
@erikjohnston erikjohnston requested a review from a team as a code owner December 5, 2022 10:38
Comment on lines +465 to +468
# We don't want to block and try and delete tonnes of devices at once,
# so we cap the number of devices we delete synchronously.
first_batch, remaining_device_ids = device_ids[:10], device_ids[10:]
await self.delete_devices(user_id, first_batch)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not delete them all in the background?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mainly thinking that it's nice to delete some devices before we let someone create a new one, so that we know every log in we delete at least some of the stale devices.

I don't really think it matters much in hindsight though.

@clokep clokep requested a review from a team December 7, 2022 11:59
Copy link
Contributor

@squahtx squahtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

The cache to deduplicate the deletions is an interesting trick.

@erikjohnston erikjohnston merged commit c2de2ca into develop Dec 9, 2022
@erikjohnston erikjohnston deleted the erikj/delete_devices branch December 9, 2022 09:37
anoadragon453 added a commit that referenced this pull request Dec 9, 2022
erikjohnston added a commit that referenced this pull request Dec 9, 2022
reivilibre added a commit that referenced this pull request Dec 12, 2022
erikjohnston added a commit that referenced this pull request Mar 2, 2023
This should help reduce the number of devices e.g. simple bots the repeatedly login rack up.

We only delete non-e2e devices as they should be safe to delete, whereas if we delete e2e devices for a user we may accidentally break their ability to receive e2e keys for a message.
erikjohnston added a commit that referenced this pull request Mar 2, 2023
This should help reduce the number of devices e.g. simple bots the repeatedly login rack up.

We only delete non-e2e devices as they should be safe to delete, whereas if we delete e2e devices for a user we may accidentally break their ability to receive e2e keys for a message.
erikjohnston added a commit that referenced this pull request Mar 2, 2023
This should help reduce the number of devices e.g. simple bots the repeatedly login rack up.

We only delete non-e2e devices as they should be safe to delete, whereas if we delete e2e devices for a user we may accidentally break their ability to receive e2e keys for a message.
erikjohnston added a commit that referenced this pull request Mar 2, 2023
This should help reduce the number of devices e.g. simple bots the repeatedly login rack up.

We only delete non-e2e devices as they should be safe to delete, whereas if we delete e2e devices for a user we may accidentally break their ability to receive e2e keys for a message.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants