Is it possible to implement Multi-Version Concurrency Control (MVCC) on top of MongoDB?

房东的猫 提交于 2019-12-08 23:32:15

问题


MongoDB is to me a great database. However there are cases where I really need atomic multi-document transactions. For example to transfer things (like money or reputation) between accounts and this needs to either succeed completely or fail completely.

I wonder if it would be possible to interact with MongoDB through a library implementing the MultiVersion Concurrency Control pattern.

How bad would it be concerning performances? Would it be possible and profitable to use a hybrid approach, using the 'mongo-mvcc' library only when necessary and the traditional db connection when working only on a single document or would this break the mvcc stuff ?


回答1:


The simplest way is to use locks (two-phase commit), although this is not very efficient in some cases. For higher concurrency some kind of MVCC can be implemented on the top of Mongo. This article provides a good description:

http://highlyscalable.wordpress.com/2012/01/07/mvcc-transactions-key-value/




回答2:


Money transaction can be implemented via two-phase commit : http://www.mongodb.org/display/DOCS/two-phase+commit




回答3:


There is an implementation of MVCC on MongoDB available now on GitHub:

https://github.com/igd-geo/mongomvcc




回答4:


MongoDB isn't really designed to work with transactions. There is a really good discussion of how you might be able to implement this over at: http://kylebanker.com/blog/2010/04/30/mongodb-and-ecommerce/




回答5:


Well when you need real TRANSACTIONS you use RDBMS which are designed to support them :) NoSQLs are faster and more scalable mainly because they don't support transactions.

If you need both maybe it's a good idea to have transactional layer to support transactions and NoSQL layer for other purposes? In some cases it shouldn't be difficult to create a hybrid system using for example MongoDB and PostgreSQL



来源:https://stackoverflow.com/questions/5984873/is-it-possible-to-implement-multi-version-concurrency-control-mvcc-on-top-of-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!