Skip to main content

Crate rushdb_storage

Crate rushdb_storage 

Source
Expand description

Ordered KV substrate shared by every node: buffered transactions over a committed B-tree view, atomic redb publication of expanded op sets, a serialized command log, multi-version snapshot reads, and serializable-optimistic dependency validation.

Re-exports§

pub use planner_stats::PlannerStats;

Modules§

backend
Narrow storage-substrate seam (research D6, plan W3).
cache
Byte-accounted logical caches.
history_v2
Bounded, append-friendly MVCC history blocks.
log_store
Segmented, append-only write-ahead log (log-first).
owner_sets
Owner sets of declared-index leaves, cached per snapshot (READ-2).
planner_stats
Evictable planner-statistics cache (DC1 “on demand, evict when idle”).
read_accounting
Opt-in read accounting for profiling: counts the backend’s point reads, range opens and seeks per key family (keys::family_label). Off by default; when off, a read costs one relaxed atomic load. take returns every thread’s reads (profile one workload at a time); take_local returns only the calling thread’s, which stays exact while other work runs concurrently (tests).
resources
Shared managed-byte accounting. Reservations are ownership tokens, not allocations, an RSS limit, or a substitute for charging each consumer.
tenant_dir
Tenant directory: scope digest ↔ 4-byte tenant ordinal.
wal
Record framing for the log-first storage substrate. This is the write-ahead log: crate::log_store appends these framed records to segment files, and that durable append is the commit’s ack boundary (not the buffered redb materialization). See the manual’s docs/manual/architecture/storage-engine.md.

Structs§

BackendLockTimes
Cumulative backend database-lock timings, summed over every shard.
DependencySet
Serializable-mode read dependencies recorded against a transaction. Zero-width entries are point reads; otherwise half-open [start,end).
OverlayView
A pinned base snapshot plus an uncommitted key overlay.
PreparedCommand
Prepared metadata for one admitted command. The publisher keeps this alongside expanded operations so an admission overlay can validate read/write conflicts without re-expanding the command.
ReadCancellation
Shared cancellation flag for one or more protected read views.
ReadLimits
Per-read byte ceilings enforced when copying values out of the store.
ReadPin
One commit index’s retained read lease.
ReadView
Owns all resources needed to read; it can outlive the Store and be shared with asynchronous providers without self-referential borrowed lifetimes.
ScanBatch
One batch of scan rows together with its byte accounting and done flag.
ScanBounds
Byte-ordered scan bounds as an inclusive/exclusive pair.
ScanCursor
Forward cursor tied to one protected view. No full candidate collection. v2 (B7 follow-up): when the view’s current-value fast path is valid (see ReadView::native_range), one real backend cursor serves the whole scan — built lazily on the first Self::next_batch call and held across calls (native/native_checked). Otherwise falls back to v1’s ordered seek-per-row (next_key + read_value_with_limits). Each batch plus at most one bounded lookahead row is allocated. Callers must release consumed batches; shared outstanding-byte admission is P01.
ScanRow
One materialized scan row.
StorageStatistics
Durable byte accounting by key family, for growth diagnosis and operator metrics. All values are exact sums of stored key+value lengths for the family, taken from one read view; they exclude redb’s copy-on-write slack (compare against Store::storage_file_bytes).
Store
Ordered key/value store shared by every node: admission, deterministic expansion, group-commit publication, multi-version reads, and retention.
TempPath
A temporary store file or directory; see the module docs.
TxAccumulator
Accumulated state of one in-flight cross-service transaction. The buffer is the transaction’s uncommitted write overlay (read-buffer-first like Txn); deps records the public reads performed inside the transaction; mutations/preconditions replay the writes atomically at commit.
Txn
Buffered view handed to admission/apply: reads see committed data merged with staged writes; writes stay buffered until the closure succeeds.
VersionEntry
One superseded value of a key, covering the half-open range [from,to).
WriterHolds
One holder’s writer holds since the store opened.

Enums§

CommitOutcome
Result of a commit attempt: either the durable commit index plus the caller payload, or a conflict reason.
CommitPhase
One timed step of the commit pipeline. Committer-side phases are observed once per commit; publisher-side phases once per publish group.
CompactOutcome
What Store::compact_if_needed did, so a deferral is never silent.
CopyOnWrite
Copy-on-write state of a store’s data files, reported at boot.
Op
Operation emitted into the atomic publish set.
OutcomeKind
Terminal status of a commit key, as stored durably.
ScanProjection
Which columns a scan should materialize for each row.
StorageError
Errors returned by the storage layer: failed preconditions, corrupt or unsupported durable state, resource exhaustion, and invalid read requests.
WriterHolder
What holds a backend’s single writer: one redb write transaction, from begin_write to its commit. Every other writer waits meanwhile, so the longest holds are what stall other tenants’ commits.

Constants§

SERIALIZABLE_CONFLICT
Reason prefix of a CommitOutcome::Conflicted caused by a read dependency that a later commit wrote (first-committer-wins).
WRITER_HOLD_BOUNDS
Upper bounds, in seconds, of the writer-hold histogram buckets.

Traits§

DeriveRead
Read access to the state before a commit, for a Deriver.
Deriver
Deterministic derivation of derived rows from a commit’s base ops.
Replicator
Replication seam: when installed on a Store, local commits build the canonical CommitBatch and route it through the leader. The leader replicates to the quorum and every node (leader included) applies it through Store::apply_replicated_batch, which returns after the batch is durably applied locally. Serialized payload is stored with the outcome so idempotent retries can reproduce the caller’s response.

Functions§

is_usage_bytes_key
Whether key is a tenant’s usage-bytes row.
prefix_range
Inclusive start / exclusive end range covering all keys under a prefix. An empty end bound means unbounded above.
remove_store
Remove the materialization file at path. The WAL directory and layout manifest are left alone.

Type Aliases§

CommitObserver
Callback receiving each timed commit phase, in seconds.
ExpandFn
Deterministic state-machine expansion callback: derives every canonical and derived key implied by one committed batch (document 07).