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
Provide programmatic transaction for MongoDB reactive with Panache #32794
Conversation
@FroMage this is a PoC for MongoDB with Panache reactive transaction based on what you did for HIbernate with Panache. Before I implement the transaction support for all operations can you check the way I handle transactions is the new Panache class ? |
ed3e3a3
to
50e9a75
Compare
50e9a75
to
86ac859
Compare
This comment has been minimized.
This comment has been minimized.
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.
The changes look fine. The failing tests are odd, though.
@evanchooly thanks, I'll have a look at the failing test soon. |
86ac859
to
18319eb
Compare
This comment has been minimized.
This comment has been minimized.
18319eb
to
c08f715
Compare
@evanchooly I fixed the tests, this was due to the fact that a Vert.x context was required for reactive transactions but it should not be required out of the context of a transaction so I updated the code accordingly (a Vert.x context is only required to in a transaction). I also added a small section on the documentation, can you have a look please? |
This comment has been minimized.
This comment has been minimized.
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.
This looks alright to me, minus the context removal question.
What's the point about transactions in mongo again? IIRC they require replicas, right?
Do you think you should test transactions to run multiple things in isolation? I don't think the tests do that.
Also, do you intend to also provide the equivalent of @WithTransaction
?
...panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/Panache.java
Outdated
Show resolved
Hide resolved
They are lightweight transactions and require a replica set, but you can configure a replicaset of one node (our devservices is configured this way). Basically, you open a session and pass it to all calls to the MongoDB driver, and at the end you commit or rollback. So the only trick is to store the session somewhere, in the Vert.x context here.
I agree test can be improved, but the transaction for the sync client has the same test. I don't remember in details the isolation model of MongoDB transactions, I can open a followup issue to improve our test coverage for it.
Maybe someday depending on my todo list ;) I need to check how it was done on HIbernate reactive and take inspiration. |
the docs changes look fine to me as well. |
OK thanks.
Well, at least you're testing that we can roll stuff back :) But yeah, isolation is probably worth testing.
You'd better check that this isn't what the original user wanted in #32156, because otherwise you're both going to be disappointed ;) |
c08f715
to
1d7e7df
Compare
@FroMage if it's OK with the context local removal I want to proceed with the PR as is, I'll create followup issue for more test on MongoDB transaction support (both sync and reactive) and a followup to support annotation based transactions. |
This comment has been minimized.
This comment has been minimized.
1d7e7df
to
4ede3df
Compare
🙈 The PR is closed and the preview is expired. |
✔️ The latest workflow run for the pull request has completed successfully. It should be safe to merge provided you have a look at the other checks in the summary. |
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.
Yup, all good, thanks!
Fixes #32156