-
Notifications
You must be signed in to change notification settings - Fork 26
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
Standalone transactions #369
Comments
Hey, there are other issues with the current closure approach, or maybe misunderstandings on my part.
BTW, the "standalone" transaction is the model implemented by sqlx allowing users to explicitly commit and rollback , so it will probably be familiar to users coming from it. |
For 1., I've outlined the workaround in this comment: #329 (comment). Basically, make the return type of the closure For 2., there is no way of doing that, apart from returning an EdgeDB error. Which adds a point for standalone transactions. And yes, sqlx and postgres, both do it this way. @tiberiusferreira, would you be interested in up-streaming your fork via a PR to this repo? I haven't looked much at the code, but if it implements this API, it would benefit edgedb-rust. |
Oh yeah, for sure. I'll clean it up and make a PR. |
After discussion with the team, we concluded that:
@tiberiusferreira I've taken your PR, taken parts of it and refactored the rest. The final version is in #373. Thank you for your help with the initial draft here. |
Awesome! Thank you for all the work here! Excited about going back to using the official crate! |
On second thought, I might not merge this features. That's because we have a hypotesis that the current API (with the closure) lacks only a way to abort the transaction and the new API is much easier to write subtle bugs with (since it lacks retries). If this is the case, we should rather add a way to abort the transaction to the current API. @tiberiusferreira Can I see snippets of your code to see if my theory holds? You might be able to use the current API (if we add a way to abort the transaction). If you don't want to share it publicly, you can message me on Discord (username aljazerzen). |
Current transaction API allows little control over how the transaction is retried and requires all work to happen within the transaction's closure.
This means that there are use-cases where more granular access to the transaction would be needed.
In #329 (comment) I've proposed the following API:
Apparently, @tiberiusferreira has already implemented this in their fork: tiberiusferreira@0cc5f57#diff-608add6cc9859de62fac8b605b75549b985354b28530c7c1b07180ccd86fd729R416
Internally, it has been pointed out that this API should be similar across all language bindings, so that we don't have to rediscover the wheel for each language.
The text was updated successfully, but these errors were encountered: