MariaDB Xpand Multi-Version Concurrency Control (MVCC)

Overview

MariaDB Xpand implements a distributed Multi-Version Concurrency Control (MVCC) scheme.

This documentation applies to both Xpand topologies.

MariaDB Xpand's Multi-Version Concurrency Control (MVCC) provides many benefits:

Transaction, Invocation, and Commit IDs

MariaDB Xpand generates several identifiers associated with each transaction, invocation, and commit:

Identifier

Description

xid

Transaction start identifier. Marks the logical beginning of the transaction.

iid

Invocation identifier. Marks the beginning of each statement within the transaction.

cid

Commit identifier. Marks the id at which transaction changes are visible to other transactions.

The following diagram shows several IDs generated throughout a transaction:

Xpand Visibility Rules

These identifiers affect row visibility. The visibility rules depend on the isolation level. See Using Transaction Isolation Levels with MariaDB Xpand for the specific details.

ID Generators

MariaDB Xpand generates the xid and iid identifiers using a combination of system wide clock and a unique instance id to create a globally unique ordered identifier.

Version History in the Undo Log

MariaDB Xpand maintains row version history:

  • When a row changes, the old version of the row is added to the version history.

  • Row version history is stored in the undo log.

  • Each row contains a Log Sequence Number (LSN), which points at the previous version of the row.

  • If the pointer refers to the trim LSN, then that is the end of the history chain.

  • The row versions are used to access previous row versions to build a transaction's snapshot.

  • The row versions are also used to rollback transactions.

The following diagram shows how the system keeps multiple versions of the row in the undo log:

Xpand Version History

Garbage Collection

MariaDB Xpand automatically performs garbage collection:

  • It deletes old row versions from the undo log when they are no longer needed by old transactions.

  • A row version is no longer needed when its cid value is lower than the lowest xid value of any currently running transactions.

  • Xpand also performs checkpoints.