rustdb
A key-value store built on a B-tree, with a write-ahead log and crash recovery tests.
- Open sourceFeatured in a systems programming newsletterrustdb write-up on crash recovery · Mar 2026
- Commits
- 214
- Stars
- 112
- Last commit
- 3 days ago
The problem
CS3223 (Database Systems Implementation) explained B-trees and logging on slides, but never showed what actually breaks when a database loses power mid-write.
Who it's for
Mostly me, and coursemates who want a small, readable storage engine to learn from. Two students taking CS3223 this semester now use it as a reference for their project.
Why I built it
I want to work on infrastructure, and I didn't trust that I understood durability until I'd lost data myself.
What I built
An embedded key-value store: put, get, delete and range scans, with crash recovery.
How it works
A page cache, a B-tree index and a write-ahead log. A test harness kills the process at random points thousands of times and checks that nothing acknowledged is lost.
Hard parts and decisions
Torn page writes. A page half-written at the moment of a crash looked valid but wasn't. I added checksums to every page and replay the log from the last clean checkpoint.
What happened
Passes 10,000 randomised crash tests with no acknowledged writes lost. 112 stars, mostly from a write-up I shared in a systems programming forum.
What I'd do next
Concurrency is single-writer only. Next is MVCC so readers never block the writer.