Aditya Arya
All projects

StrataKV

Shipped

An embedded key-value store in Go, published on pkg.go.dev. Checksummed write-ahead log, atomic batches and Bloom filters, with three crash-safety bugs found and fixed.

Recorded demo · open on YouTube

What survives an interrupted write?

StrataKV is an embedded, LSM-style key-value store written in Go with no external module dependencies. It runs inside the program that uses it; there is no server. The current release is v2.0.0 (github.com/Adityarya11/StrataKV/v2). v2 is about making partial writes and corruption visible, instead of treating every failed read as a missing key.

Make the recovery boundary explicit

Writes go to a write-ahead log before they change the memtable. Each record has a CRC-32C checksum. An atomic write batch is written as one group, with every record except the last marked pending, so recovery applies the whole batch or none of it. On reopen, replay keeps the valid prefix of the log and cuts off an unreadable tail. It does not pretend to recover corrupted data.

An integration test cuts the last record of a batch, reopens the database, and checks both sides: the write before the batch survives, and none of the 50 batched writes come back. Read the interrupted-batch test.

Three bugs v2 fixed

Trade read work for simpler storage

Flushed data goes into immutable segment files. Segments are not sorted and have no index, so a lookup that reaches a segment scans it. Bloom filters skip segments that cannot contain the key. Compaction merges segments, stops if it cannot read a source, and verifies the new segment before deleting the old ones.

Compaction only runs when the caller invokes it, and it holds an exclusive lock while it runs. Stats() exposes segment and memtable state so the application can decide when to compact.

What the benchmarks measured

Run on 2026-10-06 on my laptop (Ryzen 5 6600H, NVMe SSD, Windows 11) against real files with real fsync. Keys and values are synthetic.

Two results went the other way:

Integration and current limits

Blan uses StrataKV to cache interpreter output. Its backend still pins a pre-v2 revision and never calls compaction, so it does not use the v2 API described here.

Not built yet: automatic compaction, an index inside segments, range scans, TTL or eviction, MVCC, replication, and general transactions. Atomic write batches are a narrower guarantee than transactions. It is a single-node library.

Next projectBlan: Language, Runtime & Playground