多版本并发控制

多版本并发控制(Multiversion concurrency control, MCCMVCC),是数据库管理系统常用的一种并发控制,也用于程序设计语言实现事务内存[1]

MVCC意图解决读写锁造成的多个、长时间的读操作饿死写操作问题。每个事务读到的数据项都是一个历史快照(snapshot)并依赖于实现的隔离级别。写操作不覆盖已有数据项,而是创建一个新的版本,直至所在操作提交时才变为可见。快照隔离使得事物看到它启动时的数据状态。

算法

MVCC使用时间戳 (TS), 或“自动增量的事务ID”实现“事务一致性”。MVCC可以确保每个事务(T)通常不必“读等待”数据库对象(P)。这通过对象有多个版本,每个版本有创建时间戳废止时间戳 (WTS)做到的。

事务Ti读取对象(P)时,只有比事务Ti的时间戳早,但是时间上最接近事务Ti的对象版本可见,且该版本应该没有被废止。

事务Ti写入对象P时,如果还有事务Tk要写入同一对象,则(Ti)必须早于(Tk),即 (Ti) < (Tk),才能成功。[2]

MVCC可以无锁实现。

历史

MVCC在1981年的一篇论文"Concurrency Control in Distributed Database Systems"[3]被充分论述,并成为经典描述。一般认为原创工作始于1978年David P. Reed的博士学位论文[4]

数据库实现

现在,多数数据库系统已经使用MVCC。

参考文献

  1. refs 页面存档备份,存于. Clojure. Retrieved on 2013-09-18.
  2. Ramakrishnan, R., & Gehrke, J. (2000). Database management systems. Osborne/McGraw-Hill.
  3. Philp A. Bernstein and Nathan Goodman: 《Multiversion Concurrency Control--Theory and Algorithms》,《ACM Transactions on Database Systems》Vol.8, No.4, December 1983, pages 465-483
  4. Reed, David P. (PDF). MIT dissertation. September 21, 1978.
  5. . [2018-11-12]. (原始内容存档于2013-02-23).
  6. Berkeley DB Reference Guide: Degrees of Isolation
  7. A new approach: Clustrix Sierra database engine 存檔,存档日期2012-04-12.
  8. . cubrid-manual.readthedocs.io.
  9. DB2 Version 9.7 LUW Information Center, Currently committed semantics improve concurrency
  10. TM1 9.5.2 Information Center, Parallel Interaction
  11. etcd3 Documentation | etcd3 API | CoreOS
  12. Graves, Steve. . RTC Magazine. May 1, 2010. (原始内容存档于June 1, 2010).
  13. White paper by Roman Rokytsky Firebird and Multi Version Concurrency Control
  14. Multi-Version Concurrency Control in the H2 Database Engine
  15. MVCC - Ingres Community Wiki 存檔,存档日期2011-07-21.. Community.ingres.com. Retrieved on 2013-09-18.
  16. Todd, Bill. . 2000 [4 May 2006]. (原始内容存档于26 February 2006).
  17. About XtraDB, About XtraDB 页面存档备份,存于
  18. MariaDB/Storage Engines, PBXT
  19. About PBXT, About PBXT 页面存档备份,存于
  20. Inside MarkLogic Server
  21. Snapshot Isolation in SQL Server
  22. Multiversion concurrency control in MongoDB, MongoDB CTO: How our new WiredTiger storage engine will earn its stripes
  23. MySQL 5.1 Reference Manual, Section 14.2.12: Implementation of Multi-Versioning
  24. MySQL 5.1 Reference Manual, Table 14.1. Storage Engine Features
  25. or Maria MySQL 5.1 Reference Manual, Section 14.6.1: Falcon Features (Archive) 存檔,存档日期2014-10-04.
  26. Oracle Database Concepts: Chapter 13 Data Concurrency and Consistency Multiversion Concurency Control
  27. . Oracle FAQ. [21 March 2013].
  28. . [21 March 2013].
  29. . [2018-11-12]. (原始内容存档于2015-12-27).
  30. PostgreSQL Current Documentation, Chapter 13: Concurrency Control
  31. How does MVCC (Multi-Version Concurrency Control) work
  32. (PDF). (原始内容 (PDF)存档于2016-03-03).
  33. RDM Embedded 10.1 Reference Manual, d_trrobegin 页面存档备份,存于
  34. RethinkDB advanced FAQ
  35. . doc.splicemachine.com.
  36. . [2015-11-06]. (原始内容存档于2014-08-11).
  37. Proposal for MVCC in ZODB 存檔,存档日期2012-02-06.

延伸阅读

  • Gerhard Weikum, Gottfried Vossen, Transactional information systems: theory, algorithms, and the practice of concurrency control and recovery, Morgan Kaufmann, 2002, ISBN 1-55860-508-8
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.