-
Notifications
You must be signed in to change notification settings - Fork 248
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
Conversation
b14d93b
to
cd9f855
Compare
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.
cd9f855
to
c030532
Compare
There was a problem hiding this 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?
synapse/handlers/e2e_keys.py
Outdated
""" | ||
user = task.result.get("from_user", "") if task.result else "" | ||
while True: | ||
user, rowcount = await self.store.delete_old_otks_for_one_user(user) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea. Done.
68f3e91
to
a45bc22
Compare
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
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.