Version 12.0.0
Disaggregated Storage Roles and Role Changes
Data StructuresSource Location
src/conn/conn_layered.c

Caution: the Architecture Guide is not updated in lockstep with the code base and is not necessarily correct or complete for any specific release.

Disaggregated storage allows multiple WiredTiger nodes to read shared data while a single node persists it to shared storage. A connection's role determines its access to shared storage, the view it reads, and the work it performs on behalf of the cluster. Changing that role affects the whole storage engine, not only individual tables or cursors.

This page describes how WiredTiger implements roles and role changes. For the application contract, including configuration, call sequences, and restrictions, see Managing disaggregated storage roles.

Leader and follower

The leader is the only node that writes to shared storage: it writes the stable shared tables, publishes schema changes to shared metadata, and produces the checkpoints that other nodes read. A follower reads a checkpointed view of those tables and applies recent changes locally, without writing them back to shared storage. A follower can create and drop tables locally, but only a leader publishes those changes to other nodes.

For application data, a layered table combines a shared stable table with a node-local, in-memory ingest table. On a leader, the stable table is a live writable btree and the ingest table is empty. On a follower, the stable table is a read-only checkpoint view, with ingest table changes layered over it. The two constituents allow checkpoint adoption without writing follower changes into the shared btree.

Followers eventually adopt new checkpoints produced by the leader. Adopting a checkpoint makes covered ingest table content eligible for removal once it is safe for readers. See Layered Cursor for the merged view.

A follower never takes a checkpoint of its own: a checkpoint call on a follower returns success without doing any work, so the only checkpoints it can adopt are the ones the leader produced. See Checkpoint.

Role changes

The application changes a connection's role through WT_CONNECTION::reconfigure. Step-up changes a follower into a leader, and step-down changes a leader into a follower. The two transitions are asymmetric: step-up incorporates the follower's local changes into the shared tables it starts writing, while step-down switches to a read-only view of a checkpoint and retains any later changes in the ingest tables. The diagram summarizes both roles and the transitions between them.

Effects across WiredTiger

Because the role applies to all shared state on the connection, each role change updates the following responsibilities together:

Area Effect of the role
Shared checkpoints The leader writes the shared checkpoint; followers adopt it as a new base for reads.
Shared metadata The leader publishes schema changes to shared metadata during checkpointing; followers adopt the published schema with the checkpoint.
Shared history store The leader writes historical versions to shared storage. Followers read the history associated with their checkpoint.
Encryption key-provider metadata The leader persists encryption key-provider metadata with shared checkpoints; followers read the published metadata.
Shared table views Step-up switches from checkpoint views to live writable tables; step-down switches to read-only checkpoint views.
Eviction A leader can reconcile shared pages. A follower reclaims covered ingest table content without writing it back to shared storage.
Shared disk cache A follower caches shared page images locally. Step-up makes the cache read-only until it is retired; step-down re-enables it.
Background work Checkpoint cleanup is leader-only work; the deferred checkpoint pickup server runs on followers. Step-up and step-down stop or restart these services.

See Layered Tables for layered tables, History Store for historical versions, Key Provider for encryption key metadata, and Eviction for page reclamation.

Step-up

Before step-up, a follower already has a shared checkpoint view and recent changes in its ingest tables. Step-up first adopts any checkpoint whose pickup was deferred, so the new leader continues the shared checkpoint lineage from the newest base rather than forking it from an older one. It then switches the role, restarts any in-progress checkpoint, creates the stable tables missing for tables created on the follower, and drains the remaining ingest table changes into the stable tables. After successful reconfiguration, the connection can perform normal leader writes and produce shared checkpoints from that base.

Step-up does more than allow writes to the follower's existing view: it combines checkpointed data and local changes into a consistent live shared tree. Draining moves ingest content from under positioned cursors, and a snapshot taken on the follower cannot be consistent with the drained and adopted stable tables, so transactions and positioned cursors must not span step-up. See Step-up for the application requirements.

Step-down

Step-down transfers shared-write responsibility without restarting the old leader and changes it to a follower. After the transition, the node reads its stable tables through read-only views of the concluding checkpoint, so every change it must still serve has to be either in that checkpoint or in its ingest tables. The application therefore needs a clear boundary between writes that belong in the concluding checkpoint handed to the next leader and later writes that must be stored locally for follower operations. There are two ways to establish it.

Blocking step-down

The simplest boundary is to stop writing. In blocking step-down, writes stop while the concluding checkpoint is taken and remain stopped through the reconfiguration. Until reconfiguration, the node still operates as a leader and writes to its live stable tables. Reconfiguration switches those tables to read-only checkpoint views, so updates newer than the checkpoint would no longer be available through the follower's stable tables. The concluding checkpoint's latency therefore becomes part of the period in which the application cannot write.

Asynchronous step-down

Asynchronous step-down defines the boundary in advance so writes can continue while the concluding checkpoint is taken. The application sets a step-down timestamp N, and transactions that begin after it is set keep a copy of their writes in the ingest tables. The concluding checkpoint is taken at N, so the node can switch to checkpointed stable table views without losing newer writes. Writes must still stop for the step-down reconfiguration itself, so asynchronous step-down shortens the period of write unavailability but does not eliminate it.

The rest of this section describes how writes are routed while N is set, why some transactions are rolled back, how reads and schema operations behave, and what the reconfiguration does.

Write routing

WiredTiger chooses the destination of a transaction's writes using the step-down state recorded at transaction begin. A transaction that began before N was set writes to the stable tables only. A transaction that began after N was set writes to the ingest tables, and in the default mode to the stable tables as well.

Writes above N must be retained in the ingest tables because they are not included in the concluding checkpoint. After the step-down reconfiguration, stable-table reads use the read-only checkpoint view, so those newer writes must remain available in the ingest tables.

The disaggregated=(stepdown_write_mirroring) setting of wiredtiger_open selects between the two modes for transactions that begin after N. For applications, the modes differ mainly in the write-conflict detection they guarantee: mirrored writes detect every conflict at the conflicting write, as outside a step-down, while ingest-only writes can miss a conflict with a straddling writer until that writer is rolled back.

  • Mirrored writes (default): each write to an existing layered table goes to the stable table first and then to the ingest table, within the same transaction. Because every writer, including those that began before N was set, writes to the stable table, WiredTiger's normal single-btree conflict detection handles conflicts between them. The stable table versions above N are excluded from the concluding checkpoint by its timestamp.
  • Ingest-only writes (legacy): writes go to the ingest tables only. Writers on the two sides of the boundary no longer share an update chain, so each ingest-only write performs an explicit check against the stable table for conflicting updates. This check does not always detect conflicts immediately with writers that began before N was set and straddle setting the step-down timestamp. Those writers are rolled back rather than committed, so the missed conflicts cannot persist.

In both modes, the ingest table holds the copy that survives the step-down reconfiguration. Mirroring trades additional stable table writes and reconciliation for immediate conflict detection through a single btree; ingest-only writes avoid the extra copy but rely on the cross-table check.

Why straddling writers are rolled back

WiredTiger chooses the destination of transaction writes using the step-down state recorded at transaction begin for two reasons:

  1. A transaction can set its commit timestamp after it has already written, and the write cannot be moved to the alternative table afterwards. A write with a commit timestamp at or below N belongs in the stable table, so the destination needs to be chosen before the relevant commit timestamp exists.
  2. Straddler rollback keeps each transaction's write destinations consistent with its begin-time state, so the state recorded at begin provides the correct destination for every write of that transaction.

A layered-table write checks whether the transaction began before N was set and returns WT_ROLLBACK when it observes the change, failing the transaction early. The commit path also checks for straddling writers and is synchronized with setting the step-down timestamp. Under the application contract, this ensures such writers cannot commit above N. A retried transaction begins with N set and writes to the ingest tables.

Reads during step-down

Reads follow the same decision made at transaction begin. This is possible because layered-table operations always run in explicit snapshot-isolation transactions, and WT_SESSION::reset_snapshot is not allowed while the step-down timestamp is set. A transaction that began after N was set reads the ingest table layered over the still-live stable table. One that began earlier reads the stable table alone, which already holds everything its snapshot can see. The decision stays correct only while the transaction keeps reading the state it saw at begin.

The step-down reconfiguration replaces each live stable table with a view of the concluding checkpoint. The checkpoint keeps older versions in the shared history store, which supports reads at a timestamp, so a transaction with a read timestamp selects the same versions from the checkpoint view. A transaction without a read timestamp that straddles reconfiguration may be rolled back because its snapshot cannot be assumed to select consistent content from the replacement.

Schema changes during step-down

A layered table created after N is set has the follower table shape: only its local ingest table is created. Writes to such a table always go to the ingest table and are never mirrored, so a stable table would stay empty, and the concluding checkpoint must not include the table.

Without schema epochs, the concluding checkpoint applies every other schema operation queued when it starts, including drops issued after N was set. With schema epochs, the step-down epoch divides schema operations the same way N divides data. See Schema operations during step-down for the schema-epoch contract.