Introducing a new way to review your PRs.

Read the announcement

helixdb / helix-db

HelixDB is an OLTP graph database with native vector and full-text search built in Rust on Object Storage.

View on GitHub

27 documents · Updated Nov 23, 2026

docs / database-engine

Database engine

The database engine is the embedded runtime for Helix graph data. It opens a read-only or read/write handle over a local or remote object store, turns graph queries into stable reads or atomic writes, and keeps graph data, indexes, storage upgrades, and runtime caches consistent across restarts.

Runtime boundary

The HelixDB handle is the main boundary between an embedded application or server transport and the database runtime. It owns storage access, the planner-visible index catalog, cache services, and workers that advance durable maintenance work. Public services cover opening and closing a database, query execution, scoped access, sequence and flush checks, index-operation status, and cache state. References: crates/…/lib.rs• L757-805, crates/…/lib.rs• L968-1083, crates/…/lib.rs• L2424-2429

Storage modes

The engine supports process-local memory, local disk, and S3-compatible object storage. A writer handle can commit graph changes and start maintenance work. A reader handle serves stable reads but cannot perform write-only operations. Each handle also has a DataScope, which selects the physical namespace for tenant-isolated data. References: crates/…/lib.rs• L108-115, crates/…/lib.rs• L328-361, crates/…/lib.rs• L1378-1388, crates/…/scope.rs• L67-120

Query service

The query service is the request boundary for SDKs and server transports. It validates the request, checks whether its mode permits the request, prepares one scoped catalog view, plans the query, executes it, and converts the result to the public response shape. Warm mode uses the same read path to fill caches and does not accept writes. Row returns always use arrays for both non-empty and empty results. Scalar results such as counts keep their scalar shape. References: crates/…/query_service.rs• L29-40, crates/…/query_service.rs• L115-200, crates/…/query_service.rs• L242-279, crates/…/query_service.rs• L388-488, crates/…/query_service.rs• L508-609

The request path is summarized below.

flowchart LR
    A[Query request] --> B[Validate request and mode]
    B --> C[Refresh scoped catalog]
    C --> D[Plan executable operations]
    D --> E{Request kind}
    E -->|Read| F[Stable read view]
    E -->|Graph write| G[Serializable write scope]
    E -->|Index DDL| H[Durable index operation]
    F --> I[Interpret plan]
    G --> I
    H --> I
    I --> J[Public response]

Runtime coordination

The runtime keeps the catalog observation used for planning coupled to the request that executes the plan. Scope gates coordinate catalog refreshes, graph mutations, and index lifecycle work so a request does not use stale catalog state or cross a tenant boundary. The handle also exposes monotonic storage progress and writer flush controls for callers that need to track committed data or publish it to readers. References: crates/…/lib.rs• L855-909, crates/…/lib.rs• L2240-2286, crates/…/lib.rs• L2328-2347

Cache services

Cache services reduce read cost without changing durable graph meaning. Runtime policy selects vector memory, SlateDB memory or hybrid tiers, object-store cache warming, and optional text-search cache tiers; these settings are runtime state and are not part of the stored index or row format. The process reads its memory ceiling from the tightest available container or host limit so memory-proportional defaults fit the process that owns them. References: crates/…/cache.rs• L1-4, crates/…/cache.rs• L965-1055, crates/…/host_memory.rs• L1-36

Hybrid SlateDB caching is shared by handles that use the same canonical disk root. The shared device remains available across handle close and process-local role changes, while a handle close flushes its resident tier for later opens. References: crates/…/slate_cache.rs• L1-22, crates/…/slate_cache.rs• L37-82, crates/…/slate_cache.rs• L120-176

Storage model

The engine stores graph records and service metadata in a typed key/value layout above SlateDB. The V2 encoding is the canonical storage boundary for graph keys, property values, index records, operation records, and scoped data. The catalog loader reads canonical index records and checks that each key and value describe the same logical index before the runtime exposes it to the planner. References: crates/…/mod.rs• L1-10, crates/…/mod.rs• L1-5, crates/…/mod.rs• L1-50, crates/…/repository.rs• L208-236

Graph and metadata records

Graph nodes, edges, properties, topology, allocation watermarks, index definitions, and lifecycle operation state share one durable store. Typed keys separate these roles and include the request scope where the data is tenant-isolated. The runtime keeps logical index definitions in a catalog rather than treating user configuration as the persisted index record. References: crates/…/mod.rs• L27-49, crates/…/mod.rs• L1-5, crates/…/db.rs• L171-215

Storage compatibility

Storage compatibility is a startup concern. Writer startup bootstraps the canonical markers and runs required blocking work before it returns a usable writer. Reader startup accepts only a complete current store or a pristine legacy store; it refuses storage that needs a writer migration. Migration state is durable, so work can resume after a restart. See Storage encoding and migrations for the compatibility contract and migration stages. References: crates/…/repository.rs• L50-139, crates/…/mod.rs• L3-8, crates/…/pipeline.rs• L10-29, crates/…/lib.rs• L1247-1303

Graph mutations

Graph writes use one request-owned serializable snapshot. The write scope includes the catalog view, mutation authority, graph rows, and deferred index changes. Graph rows are staged in the transaction, while topology and secondary index maintenance may use family-local mutation state until an operation needs to see it. On success the engine commits the durable transaction and its deferred cache effects. On an error or deadline, it drops the active scope so the write does not commit. References: crates/…/mod.rs• L127-180, crates/…/tx.rs• L29-119, crates/…/mod.rs• L52-127

The write path keeps authoritative graph state and derived index state aligned.

sequenceDiagram
    participant Q as Query service
    participant E as Interpreter
    participant T as Write scope
    participant G as Graph rows
    participant X as Index mutation state
    participant S as Durable store

    Q->>E: Execute graph write plan
    E->>T: Open scoped serializable snapshot
    T->>G: Stage node, edge, property, and topology changes
    T->>X: Record affected derived index changes
    E->>T: Make required derived state visible
    T->>S: Commit graph and index-visible state
    S-->>Q: Return committed result

Mutation visibility

The interpreter makes deferred state visible only when the next operation needs it. Topology reads flush topology state, secondary lookups flush secondary state, and reads that use both families flush both. Vector and text searches overlay the transaction's queued state directly, so they do not need a physical flush. See Graph mutations and transactions for write semantics and transaction scope. References: crates/…/visibility.rs• L1-8, crates/…/visibility.rs• L57-127, crates/…/visibility.rs• L209-260

Relationship scans

A relationship scan is the source used when a pattern starts with an unbound typed relationship. It reads the type membership sets, confirms each edge's stored endpoints, and binds the relationship and endpoint nodes to each parent row. Missing endpoint records are skipped, while malformed records fail the query instead of producing partial graph results. References: crates/…/relationship_scan.rs• L11-42, crates/…/relationship_scan.rs• L43-161, crates/…/relationship_scan.rs• L29-66, crates/…/relationship_scan.rs• L96-147

Row pipelines

The row interpreter supports both materialized and demand-driven execution while keeping their graph and mutation semantics equal. Independent patterns can stream candidates through scans, indexed probes, expansions, joins, and relationship scans. The pipeline grows work from the consumer's demand and stops when the consumer has enough complete rows. References: crates/…/matches.rs• L411-547, crates/…/expansion_stack.rs• L156-206, crates/…/pipeline.rs• L33-80

Query memory limits

Every row program has a request memory budget that covers retained rows, source state, continuation state, and the encoded result. The interpreter admits owned data before it grows a collection and releases the full reservation when a query ends or fails. This turns memory pressure into a clean query failure rather than a partial result. References: crates/…/mod.rs• L52-127, crates/…/mod.rs• L554-612, crates/…/admission_points.rs• L1-56

Index services

The engine treats secondary, vector, and text indexes as derived services over authoritative graph records. A validated logical definition identifies the element kind, label, property, and family. A lifecycle operation then builds a physical generation, validates it, publishes it as active, or removes it through a durable cleanup path. Index DDL returns an accepted, existing, or already-active receipt instead of making a long build part of the request latency. References: crates/…/model.rs• L90-118, crates/…/public.rs• L32-96, crates/…/lifecycle.rs• L90-128

Index catalog

The index catalog is the shared view used by planning, DDL, mutation maintenance, and search. On open, the engine loads active canonical records for each scope. During a request, the query service refreshes the scope catalog and keeps that observation linked to execution. This prevents a plan from selecting an index that the runtime has not observed as active. References: crates/…/repository.rs• L208-236, crates/…/lib.rs• L2240-2286, crates/…/lib.rs• L855-909

Lifecycle workers

Writer handles run parent-owned workers that discover durable operations and dispatch family work with bounded resources. A build scans an authoritative source cut, catches up changes, validates the result, and activates a generation. A drop drains the active generation and removes its physical state. Blocked operations expose stable status and can be retried or aborted through the public database API. See Index lifecycle and search for family-specific build, serving, and cleanup behavior. References: crates/…/lib.rs• L808-829, crates/…/worker.rs• L1-15, crates/…/public.rs• L119-249

Planner insights

The query service keeps a bounded, recent view of missing-index and unbounded-scan signals from successful plans. It records query shape rather than values, ranks repeated signals, forgets old signals, and removes a missing-index signal once the active catalog answers it. This gives operators a product-level view of useful index work without making telemetry part of storage selection. References: crates/…/query_service.rs• L29-38, crates/…/query_service.rs• L108-113, crates/…/insight_tally.rs• L1-20, crates/…/insight_tally.rs• L202-319

The relation between graph writes and index lifecycle work is shown here.

flowchart TD
    A[Authoritative graph records] --> B[Validated index definition]
    B --> C[Durable build operation]
    A --> D[Mutation deltas]
    C --> E[Family driver]
    D --> E
    E --> F[Validated physical generation]
    F --> G[Active catalog entry]
    G --> H[Planner and search access]

Migrations

Migrations preserve the meaning of existing durable data while the storage layout and index services evolve. The engine stores migration jobs and readiness markers in the database namespace. Ordered startup work handles changes that must complete before a writer is usable. A background worker handles resumable cleanup in bounded batches and exits when no work remains. References: crates/…/mod.rs• L3-8, crates/…/mod.rs• L56-67, crates/…/pipeline.rs• L10-29, crates/…/worker.rs• L41-115

Migration scheduling

Migration tuning controls whether background work runs automatically and bounds each batch by source rows and source bytes. Manual stepping is available only when automatic scheduling is disabled. Failed batches use capped backoff, while completed batches continue at the active interval. This makes migration progress durable and limits the resource cost of repair work. References: crates/…/migrations.rs• L5-12, crates/…/migrations.rs• L86-104, crates/…/migrations.rs• L175-193, crates/…/lib.rs• L1237-1249, crates/…/lib.rs• L2367-2387

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the reader bootstrap checks aligned with every storage marker and schema-complete condition used by writer startup.
  • Keep the V2 key/value codecs aligned with catalog loading and migration readers. A key and its value must describe the same logical record.
  • Keep query-service scope selection separate from telemetry tenant identity. A telemetry label must not select the storage namespace.
  • Keep query response contracts aligned across transports. Every row return now uses [] when it has no rows; scalar returns such as counts remain scalar.
  • Keep write-scope commit and deferred-family visibility aligned. A new read operation must declare which staged derived state it can observe.
  • Keep relationship-scan type membership and endpoint records aligned. A new relationship source must preserve its missing-record and malformed-record behavior.
  • Keep row admission ownership aligned when a pipeline gains a new retained source or result shape. Rejected queries must release all request reservations.
  • Keep index lifecycle receipts and status projections stable for SDK and transport consumers when durable operation states change.
  • Keep worker ownership and close order intact. Lifecycle, migration, and startup cache workers must stop before their storage dependency closes.
  • Keep shared hybrid-cache roots canonical and capacity-stable within one process. A root must not be opened with a second device shape.

Important failure modes

TriggerConsequenceGuard
A reader opens a store with incomplete V2 bootstrap or migration stateThe handle refuses to open instead of serving an uncertain viewReader bootstrap validation requires the complete current tuple or a pristine legacy store.
A graph write runs on a reader handleThe request fails with a writer-mode errorThe query service and interpreter check writer mode before opening a write scope.
A request uses a stale or wrong-scope catalog observationPlanning or execution can select invalid index stateScoped catalog permits and catalog proofs couple planning to execution.
A row-producing query returns no rowsClients that expect null can misread a valid empty resultThe query response contract serializes every row return as []; scalar returns keep their scalar form.
A derived family is read before its staged mutations are visibleThe query can miss changes made earlier in the same writeOperation visibility selects topology and secondary barriers, while search overlays its queued transaction state.
A relationship type bitmap names an edge with missing or malformed endpoint dataThe missing edge is skipped or the query fails instead of returning a false graph rowRelationship scans confirm endpoint records before binding rows and surface decode errors.
A query exceeds its row or result memory budgetThe request fails without returning a partial resultRow and response builders admit owned memory before allocation and release reservations on failure.
A lifecycle operation finds invalid source data or a uniqueness conflictThe operation becomes blocked instead of publishing a bad generationPublic blocker codes expose the reason and retry or abort controls resolve the operation.
A migration batch fails repeatedlyProgress pauses without losing the durable checkpointThe background worker retries with capped backoff and stores job state in the database.
Two handles open one hybrid-cache root with different capacitiesThe second open fails instead of creating a conflicting cache deviceThe process shares one canonical root and requires matching cache settings.

Key files

FileWhy to read it
crates/…/lib.rsMain database handle, open modes, catalog proofs, query entry points, workers, cache state, and close behavior.
crates/…/query_service.rsTransport-facing request flow, query modes, response conversion, empty row-return contract, and stable failure classes.
crates/…/insight_tally.rsBounded planner insight behavior used to guide index work.
crates/…/mod.rsBoundary between planner executable plans and read, write, and index-DDL execution.
crates/…/mod.rsRow-program lifecycle, read or write scope handling, memory budget, and response admission.
crates/…/tx.rsRequest write ownership and commit or abort behavior.
crates/…/visibility.rsContract for seeing deferred topology and index changes during a write.
crates/…/relationship_scan.rsUnbound relationship source behavior and endpoint confirmation.
crates/…/expansion_stack.rsDemand-driven continuation of graph pattern sources.
crates/…/mod.rsCanonical typed key families and scope boundary.
crates/…/repository.rsDurable catalog loading and reader or writer bootstrap validation.
crates/…/lifecycle.rsAtomic index DDL classification and durable operation creation.
crates/…/worker.rsParent-owned dispatch of durable index work.
crates/…/public.rsStable receipts, operation status, stages, and blocker codes.
crates/…/cache.rsRuntime cache modes, warm policies, and memory budgets.
crates/…/slate_cache.rsProcess-wide sharing and lifetime rules for hybrid SlateDB caches.
crates/…/pipeline.rsOrdered writer startup and runtime-dependent migration stages.
crates/…/worker.rsResumable background migration scheduling and shutdown.