LevelDB
LevelDB is an embedded key-value storage library that maintains an ordered mapping between arbitrary byte-array keys and values.
The library has no built-in SQL engine or client-server service. One process at a time can open a database; multiple threads can share its DB object. [1]
A log and memtable hold recent updates before sorted tables organized into levels. MANIFEST tracks table metadata; CURRENT identifies the active manifest. [8]
WriteBatch applies ordered mutations atomically, without including an earlier Get or validating its read condition. Atomic batches alone therefore do not isolate application read-modify-write operations. [4] [5]
With null ReadOptions::snapshot, each read selects its own implicit snapshot. Separate reads can straddle an atomic batch. One explicit snapshot gives a consistent read view, but does not validate a later write. Snapshot handles are transient read state, not independent backup copies. [3] [5] [2]
The 1.23 write path appends the log, requests WritableFile::Sync when sync=true, then inserts into the memtable; synchronization does not require an SSTable flush. Default sync=false can acknowledge before persistent storage. [6] [3] Durability depends on the Env and storage: the in-memory helper returns success from Sync without persisting its heap-backed files. [7]
A native 1.23 fixture reported an injected IOError after the backend log Sync succeeded: live reads retained the old value and subsequent writes failed, but ordinary close/reopen recovered the new value. This tests an acknowledgement boundary, not a power-loss failure or its frequency. [10]
The 1.23 guide separates metadata keys from content keys so a metadata scan need not fetch and cache file contents. [2]
Relations
Limitations
- A custom comparator must retain the same name and key ordering across database reopenings; the default uses lexicographic byte-wise comparison. [3]
- After a log Sync error in LevelDB 1.23, the appended record may or may not be recovered on reopen; failure is not proof that the update was rolled back. [6]
Citations
- LevelDB 1.23 README: ordered key-value library, features and limitations
- LevelDB 1.23 user guide: atomic batches, synchronization, concurrency and snapshots
- LevelDB 1.23 options: key ordering, per-read snapshot and write synchronization
- LevelDB 1.23 WriteBatch: ordered atomic mutations and synchronization requirements
- LevelDB 1.23 DB API: reads, writes and transient snapshot lifetime
- LevelDB 1.23 DBImpl::Write: log, requested sync and memtable insertion
- LevelDB 1.23 in-memory Env: heap-backed files and no-op synchronization
- LevelDB 1.23 implementation overview: logs, memtables, sorted tables and MANIFEST
- Hesela: LevelDB Sync acknowledgement fixture, source, controls and limitations
Further reading
Sources & caveats
- Source review of LevelDB 1.23 at commit 99b3c03b3284f5886f9ef9a4ef703d57373e61be; this is an inspection target, not a latest-version claim.
- A bounded native Sync-acknowledgement fixture ran with three cases in each of two probe builds; no process crash, power cut, performance measurement or failing physical device was tested.
- The read-modify-write limitation is an inference from the API, not an executed concurrency experiment.