Concurrency Control in distributed system including pessimistic control (such as read-write lock) and optimistic control. Here we discuss the optimistic approaches:
Basic approach:
- Check for serializability at commit.
- If not, abort, and roll back updates it did.
This approach may causes other transaction to read dirty data, which may be aborted as well.
Multi-version approach
- For each object, we maintain per-transaction version of it, called “tentative version”, and a final version of “committed version”.
- “tentative version” has timestamp, sometimes we have timestamp for both read and write.
- On read and write, find the correct version.
Vector Clock Approach
1. For each object, maintain a vector clock that records the timestamp for which have modified it.
- It detect whether new write is strictly newer than current value. If it is, then do the update, if not, create a **sibling value ** which can be solved by user or pre-defined strategy in application.
- To prevent vector is too long (too many entries),use size-based pruning. To prevent timestamp is too old and unnecessary to maintain, use time-based pruning.
- 本文作者: Yu Wan
- 本文链接: https://cyanh1ll.github.io/2021/01/15/Optimistic/
- 版权声明: CYANH1LL