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
| Component | Role |
|---|---|
KahunaManager | Facade that wires the managers and the persistence layer together. |
LockManager | Routes lock operations to lock actors. It also handles lock replication and restore. |
KeyValuesManager | Routes key/value operations to key/value actors, including scripts and transactions. |
TransactionCoordinator | Owns transaction sessions and their working sets. It also handles finalization and cleanup, and the recovery metadata of durable decisions. |
SequencerManager | Implements named sequences on top of key/value operations under a reserved internal keyspace. |
BackupService | Coordinates backups and restores. A backup has a manifest and checkpoints, with incremental WAL segments. |
BackgroundWriterActor | Batches dirty persistent objects and writes materialized state to storage. |
Kommander IRaft | Provides 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.