{
  "slug": "leveldb",
  "term": "LevelDB",
  "aliases": [],
  "definition": "LevelDB is an embedded key-value storage library that maintains an ordered mapping between arbitrary byte-array keys and values.",
  "note": "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. [leveldb-readme]\n\nA log and memtable hold recent updates before sorted tables organized into levels. MANIFEST tracks table metadata; CURRENT identifies the active manifest. [leveldb-layout]\n\nWriteBatch 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. [leveldb-batch] [leveldb-db]\n\nWith 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. [leveldb-options] [leveldb-db] [leveldb-guide]\n\nThe 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. [leveldb-write] [leveldb-options] Durability depends on the Env and storage: the in-memory helper returns success from Sync without persisting its heap-backed files. [leveldb-memenv]\n\nA 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. [native-sync-ack]\n\nThe 1.23 guide separates metadata keys from content keys so a metadata scan need not fetch and cache file contents. [leveldb-guide]",
  "related": [
    "lsm-tree",
    "sstable",
    "write-ahead-log",
    "tablefs"
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [
    {
      "text": "A custom comparator must retain the same name and key ordering across database reopenings; the default uses lexicographic byte-wise comparison.",
      "citationIds": [
        "leveldb-options"
      ]
    },
    {
      "text": "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.",
      "citationIds": [
        "leveldb-write"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-12-01",
  "citations": [
    {
      "id": "leveldb-readme",
      "title": "LevelDB 1.23 README: ordered key-value library, features and limitations",
      "url": "https://github.com/google/leveldb/blob/99b3c03b3284f5886f9ef9a4ef703d57373e61be/README.md",
      "accessed": "2026-11-30"
    },
    {
      "id": "leveldb-guide",
      "title": "LevelDB 1.23 user guide: atomic batches, synchronization, concurrency and snapshots",
      "url": "https://github.com/google/leveldb/blob/99b3c03b3284f5886f9ef9a4ef703d57373e61be/doc/index.md",
      "accessed": "2026-11-30"
    },
    {
      "id": "leveldb-options",
      "title": "LevelDB 1.23 options: key ordering, per-read snapshot and write synchronization",
      "url": "https://github.com/google/leveldb/blob/99b3c03b3284f5886f9ef9a4ef703d57373e61be/include/leveldb/options.h",
      "accessed": "2026-11-30"
    },
    {
      "id": "leveldb-batch",
      "title": "LevelDB 1.23 WriteBatch: ordered atomic mutations and synchronization requirements",
      "url": "https://github.com/google/leveldb/blob/99b3c03b3284f5886f9ef9a4ef703d57373e61be/include/leveldb/write_batch.h",
      "accessed": "2026-11-30"
    },
    {
      "id": "leveldb-db",
      "title": "LevelDB 1.23 DB API: reads, writes and transient snapshot lifetime",
      "url": "https://github.com/google/leveldb/blob/99b3c03b3284f5886f9ef9a4ef703d57373e61be/include/leveldb/db.h",
      "accessed": "2026-11-30"
    },
    {
      "id": "leveldb-write",
      "title": "LevelDB 1.23 DBImpl::Write: log, requested sync and memtable insertion",
      "url": "https://github.com/google/leveldb/blob/99b3c03b3284f5886f9ef9a4ef703d57373e61be/db/db_impl.cc",
      "accessed": "2026-11-30"
    },
    {
      "id": "leveldb-memenv",
      "title": "LevelDB 1.23 in-memory Env: heap-backed files and no-op synchronization",
      "url": "https://github.com/google/leveldb/blob/99b3c03b3284f5886f9ef9a4ef703d57373e61be/helpers/memenv/memenv.cc",
      "accessed": "2026-11-30"
    },
    {
      "id": "leveldb-layout",
      "title": "LevelDB 1.23 implementation overview: logs, memtables, sorted tables and MANIFEST",
      "url": "https://github.com/google/leveldb/blob/99b3c03b3284f5886f9ef9a4ef703d57373e61be/doc/impl.md",
      "accessed": "2026-11-30"
    },
    {
      "id": "hesela-analysis",
      "title": "Hesela: LevelDB batches, snapshots and acknowledgement boundaries",
      "url": "https://hesela.com/analyses/rocksdb-wal-flush-manifest-boundaries/#leveldb-contracts",
      "accessed": "2026-11-30"
    },
    {
      "id": "native-sync-ack",
      "title": "Hesela: LevelDB Sync acknowledgement fixture, source, controls and limitations",
      "url": "https://hesela.dev/research/leveldb-native/README.md",
      "accessed": "2026-11-30"
    }
  ],
  "provenance": [
    "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."
  ]
}
