Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Do not hold write transaction in prune() loop #72

Closed
link2xt opened this issue Dec 30, 2022 · 1 comment · Fixed by #75
Closed

Do not hold write transaction in prune() loop #72

link2xt opened this issue Dec 30, 2022 · 1 comment · Fixed by #75
Labels
bug Something isn't working

Comments

@link2xt
Copy link
Contributor

link2xt commented Dec 30, 2022

Here write connection is created and transaction is started immediately:

with db.write_transaction() as conn:

This command is called by prune loop every second.

Opening a transaction locks the database in such a way that new_email will not be able to get a transaction here and timeout:

with db.write_transaction() as conn:

Transaction should be short-lived. At the very least begin immediate should be replaced with begin here:

sqlconn.execute("begin immediate")

This will postpone locking the database until the first write statement: https://www.sqlite.org/lang_transaction.html

But I don't see the reason to explicitly open transactions in the prune loop at all, it's enough to open a write connection without a transaction.

@link2xt link2xt added the bug Something isn't working label Dec 30, 2022
@link2xt
Copy link
Contributor Author

link2xt commented Dec 30, 2022

Note that #71 does not help at all, because both the prune loop and new_email request handler are writers, and WAL only helps to avoid readers locking writers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant