NOSQL DB concurrency

Optimistic Concurrency, also known as MVCC (Multi-Version
Concurrency Control).


This mechanism relies on timestamps (presupposing a shared
clock) or Vector Clocks, as described in [Lamport, 1978], to determine the modification
dates of transactions. In a nutshell, when transaction A begins, it reads the timestamps of
the entity or entities it wishes to modify. It then does its computations, and prepares its
write. Just before writing, it checks the timestamp of the values again and looks to see if a
conflicting transaction (transaction B) has updated the values. If so, the write would be in
conflict, and its changes are rolled back and forced to start again from scratch.


Optimistic Concurrency has several properties that make it an ideal choice for
large scale distributed database implementations. In opposition to locking mechanisms,
reads are never blocked, which can be important if the access pattern of the application
calls for large amounts of reads (as many queries in the map/reduce paradigm do).
MVCC is very good at achieving true "snapshot" isolation, because a query can carry
with it a timestamp that is used to filter any entity the query touches; this is true not only
in short terms "near" queries, but also equally effective in reconstructing historical
snapshots.

你可能感兴趣的:(NoSQL,concurrency)