Should Mongo be considered if ACID/transaction is required ?
110 views
Skip to first unread message
emilly
unread,
May 29, 2016, 8:05:27 AM5/29/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
I am beginner in MongoDB but read a lot of stuff on net in last week. What I get is MongoDB does not follow the ACID/transaction principles across documents/collections (like relational datatbase) which is need of most of web application if not all (For example scenarios like transfer amount from one account to another). Here is my take on each principle
Atomicity :- In most of the enterprise/web application we need scenarios like where a transaction contains multiple DML statements. As MongoDB does not support it. One way is either i go for manually two phase commit or some other approach. But i believe its better to consider relational DB when traction is required instead of MongoDB as relational DB are designed for the same
Consitency :- I don't care much as i can achieve it at app layer also without much effort
Isolation :- As Mongo odel is similar to auto commits transaction for relational databases. It means each upadte is visible to another transaction as soon as it is fired instead of doing at commit time
Durable:- In Mongo DB, if commit is fired and unfortunately system crash, Mongo by default can not recover the last transaction. If i need to recover it for some reason,should i consider Mongo or i should stick to relational DB?
As per mine understanding Mongo DB makes sense where we don't have transaction requirement and we need to do data analysis on humongous data?
Rhys Campbell
unread,
May 30, 2016, 2:32:26 AM5/30/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
Does MongoDB support ACID transactions?
"Yes, but in a limited sense. MongoDB supports ACID transactions at the document level; today MongoDB does not support multi-document transactions. For many but not all applications, this is sufficient because data for a record tends to be managed as a single document. Like most databases, MongoDB uses write-ahead logging to an on-disk journal to guarantee write operation durability and to provide crash resiliency."
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
Just want to point out a possible misconception in your question:
You imply that transaction is necessary in "scenarios like transfer
amount from one account to another" but that's not how banks work, or
worked for the last many decades.
If you want to transfer $200 from your checking account to my savings
account, do you think that a two phase commit transaction in the DB
can be used to implement this? It cannot - for one thing, we bank at
two different banks. The "transfer $" is probably the most commonly
used example as why transactions are necessary and it's probably the
least applicable one as that's not at all how the banks achieve
consistency in their financial transactions. [1]
Asya
[1] if it was, then how would they have gotten it done before RDBMS
existed and supported two phase commit transactions?
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
@Asya
Consider the simple scenario where i need to transfer the amount from one account to another account with in same bank.
This is just one example. Another example can be where employee entity can not be created with out address. Now if there is some error while inserting/updating the address record i need to rollback complete transaction instead of stale data under employee collection or i need to store complete document in one collection
@Rhys Campbell You said "For many but not all applications, this is sufficient because data for a record tends to be managed as a single document..." I come from RDBMS background. In last 10 years of experience i see in almost every enterprise application we need atomicity across documents/table or either collection should be very generic to contain all related data in itself instead of segregating it across the collection
Asya Kamsky
unread,
May 31, 2016, 2:49:18 AM5/31/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
I've spent more years working with RDMBS before I came to MongoDB than 10. :)
Let's just say there are many more ways to skin a cat, so to speak.