Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Create one-off scheduled task to delete old OTKs #17934

Merged
merged 6 commits into from
Nov 19, 2024

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Nov 14, 2024

To work around the fact that, pre-#17903, our database may have old one-time-keys that the clients have long thrown away the private keys for, we want to delete OTKs that look like they came from libolm.

To spread the load a bit, without holding up other background database updates, we use a scheduled task to do the work.

To work around the fact that,
pre-#17903, our database may have old
one-time-keys that the clients have long thrown away the private keys for, we
want to delete OTKs that look like they came from libolm.

To spread the load a bit, without holding up other background database updates,
we use a scheduled task to do the work.
Copy link
Member

@erikjohnston erikjohnston left a comment

Choose a reason for hiding this comment

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

Seems sane. Any chance you could quickly write a unit test?

"""
user = task.result.get("from_user", "") if task.result else ""
while True:
user, rowcount = await self.store.delete_old_otks_for_one_user(user)
Copy link
Member

Choose a reason for hiding this comment

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

Any chance we could do a number of users in a batch? Rather than trying to do ~25 transactions a second?

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea. Done.

@richvdh richvdh requested a review from erikjohnston November 19, 2024 10:44
@erikjohnston erikjohnston merged commit c5e89f5 into develop Nov 19, 2024
39 checks passed
@erikjohnston erikjohnston deleted the rav/drop_old_otks branch November 19, 2024 11:20
sandhose pushed a commit that referenced this pull request Nov 26, 2024
In a worker-mode deployment, the `E2eKeysHandler` is not necessarily
loaded, which means the handler for the `delete_old_otks` task will not
be registered. Make sure we load the handler.

Introduced in #17934
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants