Format:RocksDB database
| Magic | footer ends with the table magic (block-based 0x88e241b785f4cff7) |
|---|---|
| Extensions | .sst, .log, MANIFEST-*, CURRENT, OPTIONS-* |
| License | Apache-2.0 OR GPL-2.0-only |
| Website | https://github.com/facebook/rocksdb |
| On this wiki | Facts · Code · Notes · Topics |
RocksDB's on-disk files: same 32 KB log framing as LevelDB plus recyclable record types, SST files with a version-dependent footer and distinct magic numbers per table type (block-based 0x88e241b785f4cff7, plain 0x8242229663bf9564, cuckoo 0x926789d0c5f17873).
Overview
RocksDB descends from Format:LevelDB database and keeps its directory idea (CURRENT, MANIFEST, numbered logs and tables), but SST files use their own footer and magic numbers, and the WAL framing gained record types. At the pinned commit, table/format.cc Footer::DecodeFrom recognises the LevelDB table magic 0xdb4775248b80fb57 only to refuse it (NotSupported, the message says to load with RocksDB >= 4.6.0 and < 11.0.0 and compact to upgrade), so current RocksDB does not read LevelDB-style tables; see Fact:RocksDB database/behavior/RocksDB rejects LevelDB table magic.
Table magic numbers
Stored as an 8-byte little-endian value at the very end of an SST file. Declared in table/block_based/block_based_table_builder.cc, table/plain/plain_table_builder.cc and table/cuckoo/cuckoo_table_builder.cc:
- block-based table: 0x88e241b785f4cff7
- plain table: 0x8242229663bf9564 (legacy plain table: 0x4f3418eb7a8f13b8)
- cuckoo table: 0x926789d0c5f17873 The magic also decides the block trailer size (5 for block-based, 0 for plain), per a comment in table/format.h.
Footer version 0 (legacy) is the LevelDB shape: two block handles, padding, magic (48 bytes). Footer versions 1 and higher are fixed-size (table/format.h kNewVersionsEncodedLength = 1 + 2 x kMaxEncodedLength + 4 + 8): a checksum-type byte, the metaindex and index block handles padded to maximum size, a uint32 format version, then the magic. Newer format versions add a context checksum (a per-file base value mixed with the block offset into every block checksum); see ChecksumModifierForContext in table/format.h.
Footer layout by format_version, from table/format.cc at the pinned commit (kLatestBbtFormatVersion = 8; block-based tables below version 2 are no longer read): versions 1-5 store checksum type, metaindex and index handles (padded to 40 bytes), format_version and magic; versions 6 and up replace the handles by an extended magic 3E 00 7A 00, a footer checksum, a base context checksum, the metaindex size (version 8: low 16 bits size, high 16 bits gap) and 24 reserved bytes; the index block is then found through the metaindex. All are 53 bytes. See Fact:RocksDB database/struct/RocksDB SST footer format version 6 and up and the checksum byte values in Fact:RocksDB database/enum/RocksDB checksum types.
Write-ahead log
Same block size (32768) and 7-byte header as LevelDB, with more record types (db/log_format.h): 1 full, 2 first, 3 middle, 4 last, 5-8 recyclable full/first/middle/last, 9 SetCompressionType, 10 and 11 user-defined-timestamp size, 130 and 131 predecessor WAL info. Bit 7 (0x80) of a type marks a record that may be ignored when unknown. Recyclable records (types 5-8, 11, 131) have an 11-byte header: the 7-byte header plus a 4-byte log number (kRecyclableHeaderSize in db/log_format.h), so a reader can tell records of a reused file from stale ones (Fact:RocksDB database/struct/WAL record headers).
Reversing notes
- A recovered SST: read the last 8 bytes, match against the table above, then the footer layout follows.
- The MANIFEST keeps LevelDB's VersionEdit tags 1-7 and 9 and adds RocksDB-only ones (column families, new-file variants, WAL and blob records), see Fact:RocksDB database/enum/RocksDB MANIFEST VersionEdit tags. Unverified: the OPTIONS-NNNNNN file is an INI-style text dump of the options in effect, and compression (Snappy, Zlib, LZ4, Zstd) is recorded per block in the trailer.
Code & repositories
- https://github.com/facebook/rocksdb @
54732b0c8f6f8af34f973d7fae0a234022fcf1fa· license: Apache-2.0 OR GPL-2.0-only (declared by the contributor; GitHub's detector did not recognize COPYING)
RocksDB source; table/format.h and db/log_format.h hold footer and WAL definitions.
Tested on: source read, not run: read selected files · checked 2026-10-18