Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

765,846 Writes/Second Was a Lie: Building a Crash-Safe Key-Value Store With Only Rust's Standard Library

说明与用途

StoneKV 是一个仅使用 Rust 标准库的键值存储,保证在返回 Ok(()) 后写入已同步。文章阐述了如何修复长度检查不对称以及记录已知格式限制。

问题

Ensuring a key‑value store survives mid‑write crashes while keeping the implementation dependency‑free.

结果

StoneKV now guarantees that any acknowledged write is durable, with symmetric size checks preventing silent corruption. Known format limits are documented, and the crash‑safety contract is explicit.

工作流

  • 1. Append record to WAL and sync with File::sync_all().
  • 2. Update memtable after sync succeeds.
  • 3. Flush memtable to disk when threshold reached.
  • 4. On restart, detect incomplete WAL record, replay valid prefix, truncate invalid tail.
  • 5. Enforce MAX_FIELD_LEN in both encode() and decode() to prevent asymmetric corruption.
  • 6. Add tests for boundary conditions and document unresolved limitations.

证据

After Store::set() or Store::delete() returns Ok(()), the write has been appended to the WAL and File::sync_all() has completed.

来源

Boundary tests now assert both directions: exactly MAX_FIELD_LEN succeeds, one byte over fails at encode().

来源

  • 记录日期: 2026-09-08T08:45:14.703Z