Features
What the engine does, as it ships.
TessariKV 0.0.2 is an LSM tree with atomic batches, snapshot reads, transactions, keyspaces, three compaction styles and encryption at rest. Each line here is a line of the engine's README.
Writes
Atomic batches, with the durability each one asks for.
A WriteBatch carries puts, deletes and range deletes, possibly across several keyspaces, and lands atomically through a write-ahead log. The batch says how durable it must be before write returns, and sync_wal makes everything written so far durable on demand.
- write batchput · delete · range delete
- logappended with its durability
- skiplistin memory, lock-free
- flushfrozen, written sorted
- L0 tablenamed by a synced manifest
| Durability | Before the write returns | Survives |
|---|---|---|
Sync (default) | the log record is on stable storage | power loss |
Buffered | the log record is handed to the operating system | a process crash |
NoWal | nothing is logged; the write lives in memory | nothing until a flush; for bulk loads that can be redone |
Reads
Point reads, many keys, many ranges, one snapshot.
- point reads, many-key reads and many-range scans at one snapshot
- paged scans and bounded iterators at a consistent snapshot
- snapshots held on demand, the oldest one reported
- approximate range sizes from table indexes
- a whole-key filter lets a read of an absent key skip the in-memory table
- memtablefilter: not here
- immutablefilter: not here
- L0 · 000129bloom: skip file
- L1 · 000118block cache · found
Transactions
Snapshot isolation, or serializable, checked without locks.
A transaction reads every key and range as it was when it began, except the keys it wrote itself, and its writes stay private until commit writes them as one atomic batch. Savepoints mark points it can return to.
Under snapshot isolation the first committer wins: a commit is refused with Conflict when a key it writes was written after it began. Serializable transactions are also refused when a key they read, or a range they scanned, changed. The check runs concurrently with other commits, with no lock and no single committer.
- T1
- begin @40
- put acct:7 = 90
- commit → seq 41
- T2
- begin @40
- put acct:7 = 75
- commit → Conflict
Tables
Sorted blocks, checked on every read of them.
Sorted blocks
Prefix compression, an index, a bloom filter and a checksum on every block.
Per-keyspace codecs
LZ4 by default, Snappy, Zstandard or Deflate, with a separate codec for the bottom level.
verify_checksums
Re-reads every table file from storage and verifies each block.
Lock-free block cache
A CLOCK cache sized by block_cache_bytes; max_open_files bounds the files kept open.
In-memory tables
A lock-free skiplist per keyspace; total_memtable_bytes caps them together. A database can live entirely in memory.
Statistics
Tickers since open and per-interval latency histograms; each count is one wait-free add on a per-thread stripe.
Compaction
Leveled, universal or FIFO, several at once.
Leveled compaction is the default; universal and FIFO are a keyspace option away. Several compactions run at once, each split into parallel parts, with rate-limited output and compact_range on demand. Automatic compactions can be switched off per keyspace for a bulk load.
Writes slow down, then stop, on level-0 size, pending compaction bytes and unflushed tables, and a failed flush, compaction or log write stops writes and is reported by background_error.
Encryption
Every file sealed, under a key of its own.
With DbOptions::encryption and a KeyProvider of yours, every file holding data or metadata (tables, log, manifest, options record) is encrypted and authenticated with AES-256-GCM, or ChaCha20-Poly1305 on machines without AES instructions. A wrong or missing key is refused before any file is read.
To rotate, new files take the current key id; an old key stays needed until compaction has rewritten every file naming it.
- 000131.sstkey = derive(root, file)user:042 → red9f3a c1e0 77b2 04d9
- 000046.logkey = derive(root, file)put order:17 = oke21c 5a90 3bf7 c8a1
- MANIFESTkey = derive(root, file)L0 += 0001314d07 b6e3 19ac f250
- OPTIONSkey = derive(root, file)multiplier = 10a8f1 02cd 6e94 7b3e
Operations
Keyspaces, checkpoints and a clean way out.
Keyspaces
Named at open, created or dropped while running; each with its own options, tables, levels and compactions.
Flush and recovery
Tables named by a synced manifest; recovery replays only the log above them and removes it once flushed.
Checkpoint
A consistent copy of a live database in another directory, holding every batch committed before the call.
Destroy
Removes every file the engine wrote, in an order a crash cannot turn into a partial database.
Options on record
Every open records the options it runs with in OPTIONS-<n>.
Close
close lets a running flush finish, syncs every acknowledged write and releases the lock.