多版本并发控制

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

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

算法 编辑

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

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

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

MVCC可以无锁英语Non-lock concurrency control实现。

历史 编辑

MVCC在1981年的一篇论文"Concurrency Control in Distributed Database Systems"[3]被充分论述,并成为经典描述。一般认为原创工作始于1978年David P. Reed英语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 (PDF). [2018-11-12]. (原始内容存档 (PDF)于2017-08-08). 
  4. ^ Reed, David P. Naming and Synchronization in a Decentralized Computer System (PDF). MIT dissertation. September 21, 1978 [2018-11-12]. (原始内容存档 (PDF)于2022-01-21). 
  5. ^ ArangoDB Manual Pages: AppendOnly/MVCC. [2018-11-12]. (原始内容存档于2013-02-23). 
  6. ^ Berkeley DB Reference Guide: Degrees of Isolation. [2018-11-12]. (原始内容存档于2011-03-19). 
  7. ^ A new approach: Clustrix Sierra database engine (PDF). [2018-11-12]. (原始内容存档 (PDF)于2012-04-12). 
  8. ^ Database Transaction — CUBRID 10.0.0 documentation. cubrid-manual.readthedocs.io. [2018-11-12]. (原始内容存档于2017-09-07). 
  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. [2018-11-12]. (原始内容存档于2019-01-13). 
  12. ^ Graves, Steve. Multi-Core Software: To Gain Speed, Eliminate Resource Contention. RTC Magazine. May 1, 2010 [2018-11-12]. (原始内容存档于2010-06-01). 
  13. ^ White paper by Roman Rokytsky Firebird and Multi Version Concurrency Control页面存档备份,存于互联网档案馆
  14. ^ Multi-Version Concurrency Control in the H2 Database Engine. [2018-11-12]. (原始内容存档于2006-07-09). 
  15. ^ MVCC - Ingres Community Wiki页面存档备份,存于互联网档案馆). Community.ingres.com. Retrieved on 2013-09-18.
  16. ^ Todd, Bill. InterBase: What Sets It Apart. 2000 [4 May 2006]. (原始内容存档于2006-02-26). 
  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. [2018-11-12]. (原始内容存档于2017-04-04). 
  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) Portuguese Web Archive的存檔,存档日期2014-10-04
  26. ^ Oracle Database Concepts: Chapter 13 Data Concurrency and Consistency Multiversion Concurency Control页面存档备份,存于互联网档案馆
  27. ^ Oracle 4. Oracle FAQ. [21 March 2013]. (原始内容存档于2021-01-12). 
  28. ^ Oracle Timeline. [21 March 2013]. (原始内容存档于2021-01-31). 
  29. ^ OrientDb Documentation. [2018-11-12]. (原始内容存档于2015-12-27). 
  30. ^ PostgreSQL Current Documentation, Chapter 13: Concurrency Control页面存档备份,存于互联网档案馆
  31. ^ How does MVCC (Multi-Version Concurrency Control) work. [2018-11-12]. (原始内容存档于2021-02-09). 
  32. ^ VAX Rdb/ELN, Version 2.3 (Relational Database Management System) (PDF). [2018-11-12]. (原始内容 (PDF)存档于2016-03-03). 
  33. ^ RDM Embedded 10.1 Reference Manual, d_trrobegin页面存档备份,存于互联网档案馆
  34. ^ RethinkDB advanced FAQ. [2018-11-12]. (原始内容存档于2016-03-28). 
  35. ^ Running Transactions - Splice Machine Documentation. doc.splicemachine.com. [2018-11-12]. (原始内容存档于2018-05-14). 
  36. ^ Archived copy. [2015-11-06]. (原始内容存档于2014-08-11). 
  37. ^ Proposal for MVCC in ZODB. [2018-11-12]. (原始内容存档于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