-
Notifications
You must be signed in to change notification settings - Fork 88
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
Support for Transactions #143
Comments
I'm working with Mongo 4.4 and attempting to write unit tests for some code which uses transactions - any chance this issue can be bumped up in priority? I'm getting: |
I’m tempted to say that supporting transactions in mongo-java-server is something I consider out-of-scope. After all I’m wondering if in over 99.9% of use cases the combination of MongoDB with transactions isn’t a bad decision anyway and using a good relational database such as PostgreSQL wouldn’t be the much better choice? Please note that I would be very curious to learn about your use cases that justify the use of MongoDB with transactions! It might convince me that my old-school conservative view on NoSQL/relational databases is outdated ;) |
I'm using multi document transactions where we persist data into the main collection and an audit collection to record changes. This audit log is then used (with change streams) as an event log to facilitate downstream processing. Transactions are useful here as in the event either the main collection or the audit collection fails to be updated, we can rollback the entire transaction and try again therefore preserving the event stream (audit log) Hope this helps with the usecase. I have implemented tests using the a real mongo instance using https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo for now, but I think for unit tests, it would be nice to still be able to use the in memory provider and then use a real mongo instance for integration tests. Let me know what you think. |
@shahr: Thanks for the explanation of your use case. It’s a good example for why one would want to use transactions. However, what I should have stressed a bit more: I’m not questioning transactions but rather the combination of MongoDB and transactions. In other words: Is there a good reason to use MongoDB instead of a relational database with very good support for transactions? If the collection is sharded, MongoDB will need to run a distributed transaction with at least "poor" performance. The use of such transactions is even questioned in the MongoDB transaction manual. |
@bwaldvogel yep, in general I do completely agree with you. The decision, however, to use MongoDB with transactions was due to the following:
Hope that helps with the context. |
@bwaldvogel In our case we have an application that needs to make changes to multiple collections in an atomic way, hence transactions. |
Mongdb recently introduced transactions which would be a great addition to the library.
https://docs.mongodb.com/manual/core/transactions/
Transactions are only available on replica sets and need v6 or higher of the Wire Protocol as it relies on the OP_MSG.
#38 and #71 are preconditions for this issue.
The text was updated successfully, but these errors were encountered: