In ACID relational databases, a System Change Number (SCN) or transaction ID is used to keep data consistent within and without transactions.
When a transaction commences this SCN number is incremented.
Typically a query cannot see a change in the database if the change’s SCN is higher than the SCN that existed when the query commenced.
MongoDB implements a mechanism similar to the SCN using timestamps.
That is, if a transaction alters data after the query starts, but before the query finishes, this data will not be returned by the query.
The MongoDB WiredTiger storage engine caches previous versions of any document that might be required by an open transaction.
consistency is implemented only for declared transactions
transactions can only persist for one minute
Implementing an optimistic model is a little complicated because MongoDB does not currently implement an “intent” lock that can be used to prevent data being modified by another transaction after you have read it.
This transparently implements the familiar pessimistic locking model