Skip to main content

Internals

This section describes how Kahuna works in a running node. It is for contributors and for operators who debug behavior. It also helps users who want to understand the trade-offs behind durability and performance.

Kahuna is built around a few core ideas.

  • Raft-backed partition ownership decides which node can commit changes to the data in a partition.
  • Actors serialize access to in-memory state and isolate concurrency-sensitive code.
  • Write-ahead logs make committed Raft operations recoverable.
  • Materialized persistence stores locks and key/value entries. This means that a node doesn't need to replay all logs from the start.
  • Transaction machinery provides isolation for key/value scripts and interactive transactions.
    • MVCC: several versions for each key.
    • Write intents: staged, uncommitted changes.
    • Operation registration: deduplicated retries.
    • Priority admission.
    • Durable decisions and deferred settlement.

Main Components​

ComponentRole
KahunaManagerFacade that wires the managers and the persistence layer together.
LockManagerRoutes lock operations to lock actors. It also handles lock replication and restore.
KeyValuesManagerRoutes key/value operations to key/value actors, including scripts and transactions.
TransactionCoordinatorOwns transaction sessions and their working sets. It also handles finalization and cleanup, and the recovery metadata of durable decisions.
SequencerManagerImplements named sequences on top of key/value operations under a reserved internal keyspace.
BackupServiceCoordinates backups and restores. A backup has a manifest and checkpoints, with incremental WAL segments.
BackgroundWriterActorBatches dirty persistent objects and writes materialized state to storage.
Kommander IRaftProvides partition leadership and replication. It also has hooks for log restore and checkpoints.

Request Flow​

A persistent write is routed to its partition leader and committed through Raft. It is then applied to actor memory, and the background writer later flushes it to storage. Request Flow follows that path step by step. Transaction Lifecycle covers transactions, from reads and scripts to durable two-phase commit and deferred settlement.

Pages in This Section​