Database currently features
This is a research/descovery project based on the key-value store implementation described in the book "Designing Data-Intensive Applications" by Martin Kleppmann and Michael Greim.
The goal is to implement a very basic key-value store with the following features:
- Segmentation and Compaction
- Crash Recovery
- Startup recovery and index rebuilding
- Checksummed, versioned records
- WAL-like durable group commits
- Concurrency Control
Crash recovery detects incomplete or corrupted records after an unexpected shutdown. Valid records remain available, while a damaged final record is discarded or truncated.
On startup, the active file and binary segment hints are scanned to rebuild the in-memory key indexes. This restores lookup state without requiring a separate persisted index.
Each record stores a format version and CRC32 checksum alongside its key and value. The version identifies the frame layout, while the checksum detects partial or corrupted writes.
Writes first enter an in-memory queue and are grouped for up to 5 ms. The batch is written to the append-only active file and synced before acknowledgements are returned. This limits the number of expensive fsync calls.
Compaction writes segment data and hints to temporary files, syncs them, and then publishes their names through a manifest. On startup, the manifest identifies the complete segment set to use.
View Benchmark Data here
To run the program, simply:
- Clone the repo
- Build the program using
go build - Run the program using
./lsm-tree - Use the
helpcommand to see the available commands