Skip to content

MVCC

MVCC (Multiversion Concurrency Control, multi-version concurrency control) is applied to MatrixOne to ensure transaction snapshot isolation and achieve transaction isolation.

Create a Latch Free linked list based on the pointer field of the data tuple (Tuple, that is, every row in the table), called the version link. This version chain allows the database to locate the required version of a Tuple. Therefore, the storage mechanism of these versions of data is an important consideration in the design of database storage engine.

One solution is to use the Append Only mechanism, where all Tuple versions of a table are stored in the same storage space. This method is used in Postgre SQL. In order to update an existing Tuple, the database first gets an empty slot (slot) from the table for the new version, and then it copies the contents of the current version to the new version. Finally, it applies modifications to Tuple in the newly allocated Slot. The key to the Append Only mechanism is to decide how to sort the version chain of Tuple. Since it is impossible to maintain a two-way linked list with lock-free, the version chain only points in one direction, either from Old to New (O2N), or from New to Old (N2O).

Another similar solution is called Time Travel, which stores the information in the version chain separately, and the main table maintains the main version data.

The third solution is to maintain the main version of Tuple in the main table and maintain a series of Delta versions in a separate database comparison tool (Delta) storage. This storage is called a rollback segment in MySQL and Oracle. To update an existing Tuple, the database acquires a continuous space from the Delta storage to create a new Delta version. This Delta version contains the original value of the modified attribute, not the entire Tuple. The database then directly updates the main version in the main table (In Place Update).

image-20221026152318567