-
Notifications
You must be signed in to change notification settings - Fork 55
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
Make transaction opening more safe #20
Comments
How would this work with |
Related to #148. |
Hey @ShadowJonathan,
Sorry for the delay. This is indeed something that I keep in mind. However, write transactions are non- I also have some tricky questions for @hyc (👋) about that:
|
A thread is a single unit of execution. So is a transaction. It is nonsensical to associate them other than 1:1. |
FWIW that association can easily be broken when async comes in the mix, Send or not, because then a thread can consequently open multiple transactions on the same thread, and work with them on their own dime. |
Indeed, this is why I would like to add a runtime check to only allow one transaction on a thread, write transactions are neither |
It's not required for a |
Heed could ensure that only one write transaction is ever opened on the same thread.
It can create a
thread_local
atomic counter for write transactions and raise an error (panic or not) when the user try to open a write transaction and another one is already open.According to the LMDB documentation, there must never be more than one transaction on the same thread at any time. We could ensure that when we call the
read/write_txn
function and write into a global variable to check that no other transaction is already opened.The text was updated successfully, but these errors were encountered: