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.
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.
Optimistic Concurrency与MVCC原理与应用
本文深入探讨了Optimistic Concurrency机制及其核心实现方式MVCC(Multi-Version Concurrency Control)。该机制利用时间戳或Vector Clocks来确定事务的修改日期,通过在读取操作前记录目标实体的时间戳,进行计算并准备写入操作,在写入前再次检查实体值的时间戳,以避免冲突。Optimistic Concurrency在大型分布式数据库实施中展现出了多个优点,特别是在访问模式下,大量读取操作不受阻塞,同时实现了真正的快照隔离。
1万+

被折叠的 条评论
为什么被折叠?



