-
Notifications
You must be signed in to change notification settings - Fork 44
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
What are the exact semantics of asynchronous transactions? #242
Comments
The latter. An asynchronous function in a transaction will block the next enqueued async transaction callback (until it is resolved). However, while the asynchronous callback is waiting to resolve, any calls to |
Yep, that makes sense, thanks!
Is this only the case for transactions that do writes, or for all asynchronous transactions? Are you expected to do read-only operations outside of transactions entirely?
One approach I could think of would be to work with a "transaction object", like so: foo.transaction((tx) => {
tx.put("bar", "baz");
}) ... however, the tradeoff of that would be needing to pass a transaction object through nested function calls that make use of it. This is already commonplace in other database libraries that do transactions (eg. Knex), but I don't know whether it'd be an acceptable tradeoff here. |
This is the case for any use
This would always print a,b,c,d in that order, but it would be unknown if the store.put() might be executed during one of the awaits and thus included in one of the transactions.
I probably could add some option for a store.put() call to have an option to explicitly opt-out of participation in any current transaction ( |
The documentation states the following:
However, I'm having difficulty figuring out exactly what the semantics of this are. "other [...] operations that would end up in the current transaction" - does this mean that two simultaneous asynchronous (long-running) transactions might 'contaminate' each other, breaking the isolation property? Or does it just mean that operations outside of a transaction might erroneously end up inside of a transaction? Or something else entirely?
The text was updated successfully, but these errors were encountered: