Expand description
Immutable block storage.
A block is a directory holding one Arrow IPC file per table:
<root>/logs/p=<epoch_hour>/<min_ts:020>-<max_ts:020>-<node:08x>-<seq:012>-<wal_hi:020>/
logs.arrow log_attrs.arrow resources.arrow resource_attrs.arrow scope_attrs.arrowThe filesystem is the manifest. Every reason a LSM engine needs a MANIFEST
file is absent here: Mira publishes exactly one immutable object per commit
via one directory rename, never mutates a published block, and never needs a
multi-file atomic operation. The directory name carries the full pruning key,
so booting is one readdir per partition with zero file opens, and there is
no metadata state that can disagree with the data. That is what makes the
process stateless in the sense that matters: kill it, restart it, point a
second one at the same directory read-only β nothing to reconcile.
Publish is write-tmp / fsync-files / fsync-tmpdir / rename-dir / fsync-parent
/ fsync-grandparent β the last because the partition directory itself is a
new entry in <root>/<signal> on the first block of every hour.
Directory rename is atomic on POSIX, so a block is either wholly visible or
wholly absent; there is no torn state for recovery to clean up, and therefore
no write-ahead log.
Retention is remove_dir_all on the block directory. POSIX guarantees this is
safe against in-flight readers: a mapping holds a reference to the inode that
close() does not drop, so a query holding an Arc<Mmap> keeps reading
correct data from an unlinked file until it drops the mapping. The Arc is
the refcount; no lease protocol is needed.
StructsΒ§
- Block
Ref - A published block, discovered by reading directory names.
- CrcWriter π
- A
Writethat hashes everything passing through it. - Framed π
- One encapsulated IPC message, described entirely by the checksummed bytes it starts at.
- Mapped
Table - A table read straight out of its mapping.
- Src π
- One candidate the read path may have to open: a published block directory, or the snapshot of a block that is still open (section 4).
ConstantsΒ§
- ALIGNMENT π
- Buffer alignment for published blocks.
- COLD_
AFTER_ NS - A block goes cold once it has aged out of the hour it was partitioned into.
- COLD_
MARKER π - The cold-tier marker. Its presence means every table in the block is already ZSTD-encoded, so a sweep can skip the directory without opening a file.
- CONTINUATION π
- The prefix of every encapsulated IPC message since the legacy format was
retired. We write V5 with
write_legacy_ipc_formatoff, so a message that does not start with it is not a message this wrote. - CRC_KEY π
- CRC32 of the record-batch body, stored in the footerβs custom metadata along with the exact byte length it covers. arrow-ipc has no checksum of its own: a valid footer over a corrupt body decodes silently into wrong answers.
- CRC_
LEN_ πKEY - FORMAT_
KEY π - On-disk format version, stamped into every tableβs footer metadata beside the CRC β a place that already exists, so no second file and no second fsync. Read before the reader trusts anything else in the file.
- FORMAT_
VERSION - The format this binary writes, and the highest it will read.
- HEADER_
LEN π - Where the schema message starts:
ARROW1padded up toALIGNMENT, which is exactly howFileWriterplaces it (pad_to_alignmentover the same constant we hand it inwrite_table_with). - LEGACY_
VERSION π - The version blocks written before
FORMAT_KEYexisted are treated as. - MAGIC π
- Leading bytes of every Arrow IPC file. arrow-rsβs own reader seeks straight to the trailer and never checks this, so a truncated-from-the-front file would decode as garbage; we check it ourselves.
- MAX_
COMPACT_ πPER_ SWEEP - ponytail: a flat cap per sweep, so the first pass over an existing volume drains at a few hundred MB a minute instead of saturating the disk for an hour. Make it adaptive when a real deployment says the backlog matters.
- NANOS_
PER_ πHOUR - ZSTD_
LEVEL π - The ZSTD level every compressed table is written at.
FunctionsΒ§
- check_
filesystem - Refuse to start on a filesystem the read path cannot survive.
- check_
format π - Decide whether this binary is allowed to read a block declaring
declaredas itsFORMAT_KEY. - check_
fs_ πtype - The decision
check_filesystemmakes, split from the mount it makes it about for the same reasoncheck_formattakes a string rather than a file: the rule is the part that can be wrong, and a test cannot conjure an NFS mount to state it over. - check_
writable - Refuse to start on a data directory that cannot be written to.
- compact
- Rewrite aged blocks ZSTD-compressed, in place.
- compact_
block π - corrupt π
- A block file whose own metadata does not describe it.
- dir_
name π {min_ts}-{max_ts}-{node}-{seq}-{wal_hi}.- expire
- Drop every block whose newest row is older than
cutoff_ns. - free_
fraction - How much of the filesystem holding
pathis still free, as a fraction of its total size. - fs_type π
- The mountβs filesystem type, if it is one of the ones that matter.
Nonemeans βnothing to say about itβ, which is every local filesystem. - fsync_
dir π - message_
at π - Frame the message at
offset, bounds-checking every number it declares against the region the CRC covers. - node_id
- A replicaβs writer identity, derived from its name with no coordination.
- open_
table - Open one table of a block with no buffer copies.
- open_
table_ opt open_table, but a missing file means an empty table rather than an error.- parse_
dir_ πname - Parses both the five-field name above and the four-field name that predates the write-ahead log.
- publish
- Atomically publish a set of tables as one block under
<root>/<signal>/. - scan
- Rebuild the catalog from the filesystem. This is the entire boot sequence for the read path: no manifest to replay, and the write-ahead logβs recovery point rides in the block names rather than in a file of its own.
- sources π
- The published blocks under
root/signal, plus any open-block snapshots that have not yet been published under the same(node, seq). - stage π
- Write one sealed blockβs files into an already-created staging directory.
- statfs π
- One filled
statfs, shared by the two things that ask the mount a question. - sweep_
staging - Remove staging directories this node left behind for this signal.
- unwind_
staging π - Unwind the staging directory of a publish that did not complete.
- wal_
watermarks - How far the write-ahead log has been absorbed into published blocks, per
signal, in the order
crate::wal::Signal::indexuses. - write_
table - Write one table as a self-contained, checksummed, 64-byte-aligned IPC file and fsync it. Uncompressed on purpose: IPC body compression forces the reader to decompress into fresh allocations, which is mutually exclusive with the zero-copy mmap read path.
- write_
table_ lz4 - The same again as LZ4_FRAME, so the
tierexample can price the pure-Rust alternative against the C one on real blocks. Nothing in the engine writes LZ4; see the decisions table indocs/architecture.md. - write_
table_ πwith - write_
table_ zstd - The same file, ZSTD-compressed per buffer.