Skip to content

Operations

The oliviadb command (crate open/crates/oliviadb-ops, AGPL-3.0-only or commercial) holds the utilities a DBA needs on the first day: an online integrity check, online backup and restore, a text extract and load, and the DL/I server with its statistics and write-freeze commands. The engine parts (table scrub, write freeze) are in the open oliviadb-core.

oliviadb check   --store DIR [--map DBD=DIR]... --lib DIR... [--at VERSION] [--online] [--json] [--ascii]
oliviadb backup  --store DIR [--map DBD=DIR]... --out DIR [--json]
oliviadb restore --backup DIR --store DIR [--map DBD=DIR]... [--at VERSION] [--lib DIR... [--ascii]]
oliviadb extract --store DIR [--map DBD=DIR]... --lib DIR... --dbd NAME [--at VERSION] [--online] [--out FILE]
oliviadb load    --store DIR [--map DBD=DIR]... --lib DIR... [--in FILE] [--ascii]
            [--format text|F --dbd NAME [--lrecl N] [--overflow FILE --overflow-lrecl N]]
oliviadb serve   --store DIR [--map DBD=DIR]... --lib DIR... [--listen ADDR] [--local SOCKET] [--ascii] [--lock-wait MS]
            [--schema FILE [--environment production|staging] [--audit FILE]]
oliviadb stats   --server ADDR [--json] [--reset]
oliviadb status  --server ADDR
oliviadb unfreeze --server ADDR
oliviadb schema  check FILE... | fmt FILE [--write] | json FILE
oliviadb schema  export --lib DIR... [--name NAME] [--json]
oliviadb schema  plan FILE --against STORE|FILE [--lib DIR...] [--json]
oliviadb schema  apply FILE --store DIR [--lib DIR...]
oliviadb profile check FILE [--profile NAME]

--store is a DL/I system's directory, --map a database kept in a store of its own (as System::map_database), --lib a directory of DBDGEN and PSBGEN sources (*.dbd, *.psb; DBDs are not kept in the store). --ascii selects ASCII data (NULLVAL characters, the server's call encoding); EBCDIC is the default.

One opener per store. A store has one opener at a time, across processes (the store lock, spec/storage-format.md, "Store lock": an advisory lock on the store's LOCK file, which holds the opener's process id). A command, a DL/I program, oliviadb serve or oliviadb-server (its dli section) that finds a store held fails at once with store DIR is open in process PID; it does not wait. The lock goes with its process, a killed one too, so a crash leaves no lock to clear. check, extract and backup with --online read a copy and run beside the store's opener; without --online they need the store free.

Exit codes: 0 done (check: clean, or information only), 1 the check found warnings (status: the node is frozen), 2 the check found errors, 3 the command failed (usage, I/O, a refused request).

Integrity check: oliviadb check

Read-only, at one version (an MVCC snapshot). --online first takes a snapshot of the live stores (the backup's copy, below, into a temporary directory) and checks it, so it runs beside a server or on a standby without touching their files; without it the stores are opened directly and must not be in use. --at checks the databases as of an older version (above the GC watermark). The report is text, or one JSON object with --json: version, result, exit_code, per store its tables, blocks, entries and last version, per database its segments, index entries and logical-link entries, and findings, each with severity, code, store, database, key (the stored key, hexadecimal) and message. At most 100 findings per code and database are listed, the rest counted (suppressed).

code severity what
storage error a table's block, index partition or filter partition fails its checksum, entries out of order, a block's last entry differs from its index, entry count, key range or newest version differs from the manifest, tables of a level overlap, a table newer than the tree's last version (Db::check, Table::scrub: every block read from the file, around the cache)
frozen warning the node's writes are frozen (below)
unknown-namespace error data under a namespace the store's catalog does not name
dbd-changed warning the DBD source differs from the one the database's namespace was assigned for
database-unusable error the database cannot be opened by its DBD
bad-path-key error a path key does not parse by the DBD (a component that is not a child of the one before, a type the DBD lacks)
orphan error a segment whose parent (any ancestor) is not stored; every segment under a missing ancestor is reported
key-mismatch error the sequence field in the data differs from the key in the path key
bad-length error a fixed-length segment not of its DBD length; a variable-length one shorter than its size field or longer than its maximum
unknown-layout error a version names a layout number the registry does not hold
index-missing, index-extra, index-wrong-target error secondary indexes both ways: the entries every source segment needs (by the index's search and subsequence fields, NULLVAL suppression) against the stored ones
link-missing, link-extra error logical children's entries under their logical parents both ways (a child kept for its logical path after a physical delete, and a child logically deleted, count as needing theirs)
logical-parent-missing error a logical child whose logical parent's key does not resolve or whose parent is not stored
pair-missing error physical pairing: a logical child A under X pointing to P without the paired B under P pointing to X
pair-one-sided info the same where the paired type's delete rule is L (one side is deleted alone)

Evidence: faults injected into checked databases are reported with their code and key: an index entry removed, an extra one, one pointing elsewhere, a root deleted under its dependents (one orphan per dependent), a changed sequence field, an unknown layout number, an unknown namespace, a removed logical-link entry, a deleted logical parent. The table scrub and checksum detection: oliviadb-core/tests/freeze.rs (a flipped bit in a data block, a damaged index).

Not checked yet: HSAM, SHSAM, GSAM and MSDB data sets, DEDB subset pointers and sequential dependents, HALDB partition boundaries against the partition definitions, version headers' variant numbers against the layout's variants, the write-ahead log's records beyond what opening the store replays.

Backup and restore: oliviadb backup, oliviadb restore

oliviadb backup copies each store while its owner keeps writing, without asking it: tables never change once written and are hard-linked (copied where links are impossible), the manifest and logs only grow and their bytes are copied (a record cut by the copy is a torn tail, dropped when the copy is opened). When the owner replaces what is being copied (a compaction removes a table the copied manifest names, a flush retires the log the copy needs, the manifest is rotated), the copy is redone, keeping the tables already linked (at most 100 attempts). The copy is then opened, recovered like a store after a crash, and checked (Db::check); BACKUP.json records the backup's version, each store's last version and GC watermark, and the problems the check found (a backup with problems is refused by restore).

Consistency is at a version: a store's copy holds every commit up to its last version and none after it. Every commit acknowledged before the backup started is in it; a commit in flight may be (as after a crash). With several stores (mapped databases) the copies are taken one after the other, so the backup's version is the time the backup started (the hybrid logical clock's milliseconds) and restore cuts every store there; units of work across stores are made whole by the stores' recovery of interrupted multi-store commits.

oliviadb restore puts the copies in new directories (tables hard-linked, logs and manifest copied) at the backup's version or, with --at, at an older one: a store with versions above the cut is rebuilt from its versions up to it (every key's history as far as the store kept it, so --at must not be below a copy's GC watermark). With --lib the restored databases are verified: oliviadb check, then each database's JSON export equal to the backup's at the restored version.

Evidence (oliviadb-ops/tests/backup.rs): five backups taken under a writer that commits, flushes and compacts continuously hold exactly the commits a model of the acknowledged commits has at the backup's version; restores at the backup's version and 50 commits earlier give the model's state at those versions; two stores restored at the backup's start hold each store's model state there; a flipped bit in a source table is found by the backup's check and the restore refuses it.

Not built: an archive of the write-ahead log (point-in-time recovery beyond the versions a store keeps), incremental backups, a cut that streams (the rebuild holds the store's versions in memory).

Text extract and load: oliviadb extract, oliviadb load

The extract is the JSON export (spec/schema.md 4.6) as lines: a header {"dbd":..,"oliviadb_extract":1,"version":".."}, each layout's definition on a line of its own ({"layout":"sha256:..","definition":{..}}) before the first record that uses it, then one line per database record, its segments nested, each decoded by the layout its writer recorded (else the segment type's default at that version). It is lossless: a segment whose fields do not give back its bytes exactly (bytes outside every field, a sign or zone the encoder writes differently) also carries data (x: and hexadecimal), and one whose length differs from its DBD's carries length; a segment without a layout carries only data. Decimal values are written as JSON numbers with their scale.

oliviadb load registers the layouts the extract defines (one already held keeps its number), builds each segment's data from its fields by its layout (character fields padded with blanks, packed and zoned decimal and binary from the numbers; bytes outside every field filled with the layout's blank) or takes data, and loads the database like an unload: keys rebuilt from the data, secondary indexes and logical-relationship entries rebuilt, every segment recording its layout and variant.

Limits: the load holds the database in memory (as the unload's reload does); field values must fit their fields (an error names the field).

IMS unloads and data sets: oliviadb-migrate load --format

oliviadb load reads OliviaDB's own text format (--format text, the default) in every build; other formats are read by the build's readers (oliviadb_dli::ingest), which the open oliviadb command does not have (it refuses them). The enterprise command oliviadb-migrate (crate oliviadb-dli-migrate) is oliviadb with the IMS readers: oliviadb-migrate load --format FORMAT --dbd NAME --in FILE (FORMAT hd, hisam, shisam or dedb) replaces database NAME with the contents of an IMS file (library: oliviadb_dli_migrate, trait Migrate on System). Keys, secondary indexes and logical-relationship entries are rebuilt as by the unload reload; versions get the default layout (spec/schema.md 4.6). The command prints the segments and roots loaded, the segments dropped as deleted and the control records skipped.

format input from
hd an HD Reorganization Unload data set with its RDWs the HD Reorganization Unload record layout (status.md, "Replica")
hisam --in: the primary data set's logical records, --lrecl bytes each; --overflow: the overflow data set, the logical record at RBA r being bytes r to r + --overflow-lrecl IMS 13 Database Administration (SC19-3652-04), "How a HISAM record is stored", Figure 25, "Deleting segments", "Bits in the delete byte"
shisam the KSDS's records, --lrecl bytes each the same manual, "SHISAM databases"
dedb the unloaded segment records (DBT format) with their RDWs IMS High Performance Fast Path Utilities User's Guide (SC27-9536-28), "Unloaded segment records layout", Tables 207-213

A HISAM data set is read logical record by logical record: the 4-byte pointer to the next logical record of the database record (an RBA in the overflow data set, zeros in the last), the segments (segment code, delete byte, data; a variable-length segment's length from its size field), segment code 0. A segment marked deleted (delete byte X'80') is dropped with its dependents, a database record marked deleted (X'40') whole; the root with a key of all X'FF' that ends the database is skipped. A DEDB unload is sorted by its records' sort key part (area, RAP, root key, segment code and sequence number per level), as the reload's sort step does, so the file may come in any order; sequential dependents keep their entry sequence, and the subset pointers each segment's USRPFLG2 marks are set.

Refused, each with an error naming it: the HISAM Reorganization Unload utility's output (the manuals do not lay out its header and statistics records), HISAM segments in logical relationships, a HISAM delete byte with bits other than 0 to 2, DEDB records in the TFMT format, with SDEP=PHYSICAL, compressed, or with insert limit counts, and any record whose fields contradict the DBD (segment code, level, parent, length, root key).

Evidence: hand-built HISAM chains, deleted segments and DEDB unloads with their DL/I results derived by hand, and every refusal (in OliviaDB Enterprise, which holds the readers).

Write freeze

After an I/O error on a log, table or manifest (append or sync), or a block read back that fails its checksum, the node stops writing: every tree of the node (every store of a DL/I system, all trees of an HA node) refuses writes with Error::Poisoned, which is retryable; reads go on. A failed sync is not retried: after a failed fsync a later successful one does not prove the data reached the disk, so the files are not written again until someone has looked at them. The first cause is kept (Freeze: kind write, sync or checksum, the file and error, the time, the number of errors since).

  • The DL/I server prints one loud line on standard error when it freezes and answers every sync point with a refusal marked retryable and frozen (the unit of work is backed out); oliviadb status shows the freeze (and exits 1); oliviadb check reports it.
  • Agent memory refuses writes with Unavailable (the network API: 503, retryable: not done); recall goes on, without keeping the record of the pack it returns (feedback on such a pack finds nothing).
  • Clearing: after checking the storage (oliviadb check --online), oliviadb unfreeze reopens every store whose own write failed (its log's tail is recovered like a crash's: the commit whose sync failed may or may not be there; agent memory told its caller the outcome is unknown: Unconfirmed, 504 on the network API) and lifts the freeze. If a store cannot be reopened the freeze stays. Db::reopen, Node::clear_freeze and System::clear_freeze are the API.

Evidence: oliviadb-core/tests/freeze.rs (a failed log sync, a failed table write freezing a second tree of the node, a checksum failure, each with the simulator's fault injection; clearing and reopening), oliviadb-ops/tests/server.rs (writes failing under the server: retryable refusals, status, reads, unfreeze, the failed units of work absent), oliviadb-memory/tests/freeze.rs. The deterministic simulators run with read corruption and write and sync errors and now freeze on each.

On an HA pair a frozen primary gives up its role: it stops renewing its lease and heartbeating, the standby takes over within about the lease, and the frozen node stops once it has lost the role (docs/ha.md, "A primary whose storage freezes").

Open: the freeze is not persisted (a restart starts unfrozen, after recovery).

Statistics: oliviadb stats

Every DL/I call is counted per program (PSB), PCB (IO, or its number and database) and function: the number of calls, the status codes they ended with (WAIT for a call that had to wait for a lock and was repeated), and the latency (a histogram with four buckets per power of two: percentiles are the upper bound of their bucket, at most 25 % above the true value; the maximum and mean are exact). Programs scheduled are counted per PSB. oliviadb stats --server ADDR prints a table, --json the server's answer (programs with rows: pcb, func, calls, status, latency_us with p50, p95, p99, max, mean; also block_cache hits and misses and frozen); --reset starts afresh. In a process that embeds OliviaDB the counters are System::stats.

Evidence: oliviadb-dli unit tests (every value in exactly one bucket; percentiles of a known distribution within their bound), oliviadb-ops/tests/server.rs (the counts and statuses of the calls a test made, over the network and in the CLI's table).

Open: time spent waiting for locks, block reads per call (cache or disk), OpenTelemetry export, the counters in the C ABI and the Java binding (the Spring starter's oliviadb.dli.calls counts calls on the Java side).

The DL/I server: oliviadb serve

One DL/I system per process; clients connect over TCP and each connection schedules one program. The protocol is one JSON object per line each way (I/O areas, SSAs and PCB masks in hexadecimal): hello (the client's session id; the answer names the server's run), schedule, call (function, PCB number, 0 for the I/O PCB, I/O area, SSAs; the answer carries the status code, the I/O area and the PCB mask), sync and term (with the client's sequence number of the unit of work), rollback, outcome, status, stats, unfreeze. A call that has to wait for a lock waits up to --lock-wait (30 s by default), then is refused retryably. The Rust client is oliviadb_ops::client::Client.

The installation's randomizing routines

HDAM, PHDAM and DEDB root order is the installation's randomizing routine's (docs/integration.md, "HDAM and PHDAM root order"). --randomizer NAME=LIB (repeatable) loads one from a shared library that exports

int oliviadb_randomizer(void *ctx, const char *module, const unsigned char *key, size_t len,
                        const oliviadb_rmname *rm, uint32_t *block, uint32_t *anchor);

(ctx is NULL; rm holds the RMNAME= anchor points per block, blocks and bytes; return 0 with the relative block number and the anchor point, both from 1, or non-zero for a failure, which gives the call AO). NAME is the module name DBDs give in RMNAME=, or * for every module not named. The server does not start when a library cannot be loaded or does not export the function. Evidence: oliviadb-ops/tests/randomizer_lib.rs (the order of an unqualified GN follows the routine: block, anchor point, then key).

The local call path

Programs on the server's node can skip TCP: oliviadb serve --local SOCKET also listens on a Unix socket, and a program that attaches there makes its calls through a shared-memory call slot (oliviadb-shm), as the design's process model has it: the program never maps the server's data, only its own slot, so a bad pointer in the program cannot touch the buffer pool, and the PSB is checked in the server.

  • Attach: the program sends {"op":"attach","session":...,"mode":"poll"|"wake"} on the socket (the first line; it also does what hello does); the answer names the slot file (in SOCKET.slots/), which the program maps. Every request then goes through the slot: DL/I calls in a binary form (function, PCB number, I/O area, SSAs; the answer: status, I/O area, PCB mask, frozen, error, observe finding), everything else as the JSON object of the line protocol. The Rust client is Client::connect_local(path, mode), the C ABI's oliviadb_local_connect (docs/integration.md, "C ABI version 10"); the schedule answer carries the PCB masks as the program starts (masks) and the attach answer the character set of program storage (charset).
  • A slot has room for one request and one answer (256 KiB each): a DL/I program has one call in flight, so the design's ring has depth one. The server copies a request out of the slot (the length read once and checked against the area) before it decodes it, so a program that rewrites the slot meanwhile changes nothing the server checked; a request whose lengths do not add up is refused and the server goes on.
  • wake: the program writes a byte on the socket after each request and sleeps until the server writes one back. poll: no bytes; one polling thread of the server serves every polling slot in turn, and the program spins on the slot. The poller spins while calls come; after 2 ms without one it sleeps 50 µs between passes, after 100 ms 1 ms, so the first call after a pause waits up to that long. A call that waits for a lock stays in its slot and is tried again every millisecond (up to --lock-wait), without holding up the other programs. Choose per program: poll for batch, wake for occasional calls.
  • The socket is the guard: a program whose socket ends is backed out and its locks released (its slot file is removed); a program sees the server's death as the socket's end at once (in poll mode it looks every 256 spins) and gets the errors of the table below, as over TCP.

Measured (cargo bench -p oliviadb-ops --bench call_paths: GU of a root by key, random keys over 20 000 cached roots, 100 000 calls per path, each timed; Apple M3 Max, macOS 27.2, release build, 2026-12-02; the machine was not otherwise idle, so the tails are indicative):

path p50 p99 p99.9
in process (no hop) 1.50 µs 2.33 µs 6.54 µs
local, poll 1.96 µs 5.21 µs 7.96 µs
local, wake 7.25 µs 19.8 µs 51.3 µs
TCP, loopback (JSON lines) 30.8 µs 54.4 µs 77.5 µs

The poll path costs about 0.5 µs per call over the in-process call (the design's target is about 1 µs); the wake path is in the design's 5 to 10 µs.

Evidence: oliviadb-shm/tests/slot.rs (two mappings exchanging calls, lengths beyond the area refused before decoding, malformed messages), oliviadb-ops/tests/local.rs (calls and their statuses in both modes, a lock wait in the poller's queue while another program is served, a program that dies backed out, kill -9 of the server seen at once with the unit of work reported lost, a corrupted slot refused).

Programs under access profiles

With --schema FILE (.olv or JSON) each program whose PSB has a profile in the schema (profile NAME for program "PSB", as oliviadb schema export writes an imported PSB) runs under it (spec/schema.md 6, oliviadb_dli::enforce). An imported PSB's profile reproduces the PSB; a profile may keep fewer of its grants, never more. What it takes away narrows the PSB the program is scheduled with, so a call the profile does not grant gets the status a PSB without it gives: a segment the profile grants nothing of is not sensitive (an SSA naming it gets AC, an unqualified GN passes over it), an option it takes from every segment of a PCB leaves the PCB's PROCOPT (G for get and list, I insert, R update, D delete; a call it no longer allows gets AM), and I, R or D taken from some segments only leaves those segments' SENSEG PROCOPT (an ISRT, REPL or DLET of one of them gets AM). The schedule answer names the profile and its mode.

The profiles are checked when the server starts, and it does not start when one asks what a PSB cannot express: get and list taken from some segments of a PCB and not the others (a PCB whose segments do not agree on G is not scheduled, see docs/limits.md), update or delete without get, get without list or the reverse, a segment granted under one that is not, every segment of a PCB taken, fields(...) other than the segment's SENFLDs, a PROCSEQ PCB's lookup taken, rows, masks, pii masked, quotas, as_of, limits, except, by, scan, propose, verbs DL/I has no call for, or a grant the PSB does not give.

--environment production (the default) refuses to start with a profile in observe mode and schedules no program without a profile. --environment staging schedules a program in observe mode under its whole PSB and, for each call the profile would have refused, writes a record to the audit log (--audit FILE, JSON lines; standard error without it): observe, profile, purpose, principal (the PSB), path (the DBD and the segments the SSAs name) and reason; the call's answer carries the reason as observed. A program without a profile is scheduled and recorded ("profile": null).

Evidence: oliviadb-ops/tests/profiles_dli.rs (a narrowing profile against the narrowed PSB written out by hand; the statuses and the GN sequence derived by hand from it; observe records; what is refused at start).

When the server process dies

The design's answer to "what happens if the server process dies", built for the DL/I server:

what was going on what the client gets what happens to the data
a database call, or a rollback, in flight; or the next request after the death ServerLost with UnitOfWork { updates } (retryable) the unit of work since the last sync point is rolled back (its changes were only in the server's memory); positions and locks are gone. The program reconnects (reconnect: waits for the server, schedules again) and restarts from its last checkpoint
a sync point (or the program's end) without its answer the client reconnects, asks outcome for its session, and reports SyncCommitted or UnitOfWork each sync point that commits writes the session's sequence number in the same atomic commit, so the restarted server knows whether it committed
a program (client) dies nothing (other programs go on) the server sees the connection close, backs the unit of work out and releases its locks

Nothing acknowledged is lost: a sync point is answered after its commit is synced. No call is repeated by the client on its own (the positions are gone). Calls never wait for ever on a dead server: the connection's end is seen at once. The exact abnormal-end code a COBOL program should get for a unit of work lost this way is to be taken from the IMS manuals and is open; the Rust client reports the error kind.

Restart time, measured (oliviadb-ops/tests/server.rs, this machine, release build): a store of 63 MiB of tables and a 7.3 MiB log tail (just under the default memtable, replayed whole): the system opens in 4 ms and the server listens 6 ms after it is started; a supervisor that restarts it at once makes it available again in milliseconds. A database of the design's size (thousands of trees per node) opens in about 0.2 to 0.4 ms per tree (docs/memory-model.md), so seconds per node.

Evidence (oliviadb-ops/tests/server.rs, three processes of oliviadb serve killed with SIGKILL): an idle program with an open unit of work and four programs inserting and syncing every five inserts; after kill -9 and a restart every acknowledged insert is there, every insert of an unacknowledged unit of work is not, each program's error is retryable and names what was lost, and the store checks clean online beside the restarted server. Deaths placed right before and right after a sync point's commit (OLIVIADB_SERVE_ABORT) give UnitOfWork and SyncCommitted, with the insert absent and present. A client dropped with an uncommitted insert leaves neither the insert nor its lock behind.

Open: the Java binding still runs DL/I in the calling process (the C ABI reaches the server through the local call path, docs/integration.md, "C ABI version 10"); the outcome record is one per session and is not removed (a few dozen bytes per session ever seen).

Schemas and profiles: oliviadb schema, oliviadb profile

The schema language (aggregate, the analogue of a DBD; profile, the analogue of a PSB) and its JSON form are described in spec/schema.md. oliviadb database and oliviadb psb are synonyms.

  • oliviadb schema check reads .olv or JSON files and prints file:line:col: message per error (exit 2); fmt prints (or with --write rewrites) the file in the formatter's layout; json prints the canonical JSON.
  • oliviadb schema export --lib DIR... prints the schema of DBDGEN and PSBGEN libraries: a migrated IMS database in the new form (every attribute the IR has no field for is kept in ims members, so nothing is lost).
  • oliviadb schema plan NEW --against STORE|FILE lists what the new version changes against the schema deployed in the store (or, before the first deployment, the store's DBD and PSB libraries given with --lib; or a schema file) and refuses breaking changes (exit 2): a key part's type, order, direction or collation, a field number reused with another type, a field a profile names removed, a fixed segment length shortened, a discriminator changed or a value moved to another variant, a node type removed or moved to another parent, an aggregate removed, placement or partitioning changed, an index made unique. Allowed: new fields, new node types (they take a free code between their siblings' codes), new or redefined indexes (listed to build online), profiles, enum widening. The new version must be numbered above the deployed one.
  • oliviadb schema apply NEW --store DIR plans and, when nothing breaks, records the schema (with every node type's code) as deployed, kept with the store's layout registry (so it is backed up and replicated like the layouts).
  • oliviadb profile check gives every granted path its plan (key, key prefix, index, text index, change stream) and fails (exit 2) on a path that would scan an aggregate without saying scan.