# Install Source: https://docs.luradb.org/getting-started/install/ Install LuraDB from the Debian package, with Docker or from source, on Windows in WSL or Docker Desktop. LuraDB installs as one Debian package. `apt` resolves the runtime dependencies, creates the `luradb` system user, generates an admin API key and enables the systemd service without starting it, so you can review the configuration before LuraDB runs for the first time. LuraDB needs Linux on amd64 with kernel 6.1 or newer, and systemd if you install the package. On a Windows machine it runs in WSL or in Docker Desktop, see [Windows](#windows-wsl-or-docker-desktop). ## What the host needs | Requirement | Why | |---|---| | Linux on amd64 | The server is built on `io_uring` and ships for this platform only. | | Kernel 6.1 or newer | LuraDB's `io_uring` rings use `DEFER_TASKRUN`. On an older kernel the service does not start and logs `LuraDB requires Linux kernel 6.1 or newer (io_uring DEFER_TASKRUN)`. | | systemd | The package installs and enables a systemd service. Docker and a source build do not need it. | | `libc6` 2.34 or newer and `adduser` | The package depends on both; `apt` installs them. | Check the kernel first: ```sh uname -r ``` ## Install the Debian package Download `luradb_-1_amd64.deb` from the [GitHub releases](https://github.com/hwein/luradb/releases) and install it with `apt`, which resolves the dependencies: ```sh sudo apt install ./luradb_0.7.1-1_amd64.deb ``` On the first install the package: - creates the system user `luradb` (no login, no home directory); - writes `/etc/luradb/luradb.toml`, owned by `root:luradb` with mode `640`, because it contains the admin key; - generates a random admin API key and puts it into that file; - creates `/etc/luradb/tls`, where you put a certificate if you [turn on HTTPS](https://docs.luradb.org/operating/security/); - enables the service for the next boot, but does not start it. A notice at the end of the install says where the configuration lives and how to start: ```text LuraDB is installed but not started. Config: /etc/luradb/luradb.toml Data: /var/lib/luradb Start: sudo systemctl start luradb Review the config before the first start (bind address, data paths, admin API key). The service is enabled and starts automatically on the next boot. ``` The service does not start by itself so that you can look at the configuration first. The first start creates the data files under `/var/lib/luradb`; where exactly is set by `storage.wal_path`, `storage.sstable_dir` and the other keys of `[storage]` in the [configuration reference](https://docs.luradb.org/operating/configuration/). ## Start the service and read the admin key ```sh sudo systemctl start luradb systemctl status luradb journalctl -u luradb -f ``` The log shows how the cores were split and on which address the server listens. The admin key stays in the configuration file; read it with: ```sh sudo grep api_key /etc/luradb/luradb.toml ``` ```text api_key = "lura_…" ``` A key starts with `lura_` and is followed by 32 hexadecimal digits. The package generates it once; it stays the same across updates and reinstalls. Every request except `/health` sends it as a Bearer token. The examples in this handbook read it from a shell variable: ```sh KEY=lura_… # your admin key from /etc/luradb/luradb.toml ``` ## Check that it answers `/health` needs no key. A second request with the key shows who you are: ```sh curl -s http://127.0.0.1:3000/health curl -s http://127.0.0.1:3000/store-api/auth/whoami -H "Authorization: Bearer $KEY" ``` ```json { "domain_count": 1, "estimated_memtable_keys": 1, "l0_sstable_count": 0, "resources": { "disk_state": "ok", "memory_state": "ok", "state": "ok" }, "shards": [{ "id": 0, "status": "ok" }], "status": "ok", "uptime_secs": 1, "version": "0.7.1", "vlog_size_bytes": 0 } ``` ```json { "name": "admin", "role": "Admin" } ``` The `shards` list has one entry per data shard; the example host has four cores and therefore one shard, see [Multicore](https://docs.luradb.org/how-it-works/multicore/). Without the key, any other request answers `401 Unauthorized`. By default the server listens on `127.0.0.1:3000`, see `server.bind_address` and `server.port`. Turning authentication off with `auth.enabled` is only accepted on a loopback address: with another bind address the start is refused with `auth.enabled = false and server.bind_address = '0.0.0.0' is not loopback — enable auth (auth.enabled = true) or bind to loopback (127.0.0.1 / ::1)`. ## Change the configuration ```sh sudoedit /etc/luradb/luradb.toml sudo systemctl restart luradb ``` The server reads the file once at start; a change takes effect with a restart. `luradb.toml` is a dpkg conffile: your changes survive updates, and dpkg asks what to do when your file and the new package version both changed. Every key is explained in the [configuration reference](https://docs.luradb.org/operating/configuration/). ## Run it in Docker The Docker setup is a way to try LuraDB on any machine; it is not a distribution image. It builds an image from a `.deb` you provide, so nothing is compiled and the host needs no package install. 1. Clone the repository and put a `luradb_*.deb` from the releases into `target/debian/`: ```sh git clone https://github.com/hwein/luradb.git mkdir -p luradb/target/debian ``` 2. Build the image and start the container: ```sh cd luradb/packaging/docker docker compose up -d ``` 3. When the container is `healthy`, check it: ```sh curl http://localhost:3000/health ``` A container shares the kernel of its host (with Docker Desktop, the kernel of its virtual machine), so that kernel must be 6.1 or newer as well; `docker run --rm ubuntu:24.04 uname -r` shows it. Docker's default seccomp profile blocks the `io_uring` calls LuraDB needs; `compose.yaml` therefore sets `seccomp=unconfined`, which is why a plain `docker run` fails at start. The container generates the admin key on its first start and prints it once: ```sh docker compose logs luradb | grep "admin api key" ``` Later starts reuse the key from the `etc` volume; read it back with `docker compose exec luradb grep api_key /etc/luradb/luradb.toml`. To use a key of your own, set `LURADB_ADMIN_KEY` in the container's environment before the first start. The Swagger UI is on in this setup, and the port is published on `127.0.0.1` only. The service and the container in operation are described in [systemd and Docker](https://docs.luradb.org/operating/systemd-and-docker/). ## Windows: WSL or Docker Desktop LuraDB does not run on Windows itself. Two ways put a Linux kernel on a Windows machine, and both meet the kernel requirement: **WSL 2** runs a Linux distribution on a kernel that Microsoft ships with WSL; `wsl --version` in PowerShell shows its version, and current WSL releases ship 6.6 or newer. Install Ubuntu, open it, and follow [Install the Debian package](#install-the-debian-package) inside it: ```powershell wsl --install -d Ubuntu-24.04 ``` Ubuntu's WSL images start systemd by default; `systemctl is-system-running` answers `running`. If it does not, put `systemd=true` under `[boot]` in `/etc/wsl.conf`, then `wsl --shutdown` in PowerShell and open the distribution again. WSL forwards the port to Windows, so `http://localhost:3000/health` also answers in a browser or in PowerShell. The distribution, and the service with it, stops a short while after its last terminal closes; opening a terminal starts both again. **Docker Desktop** uses WSL 2 as well, so its containers share that kernel; `docker info --format '{{.KernelVersion}}'` shows it. Follow [Run it in Docker](#run-it-in-docker) in PowerShell or in a WSL terminal, `docker compose` behaves the same in both. ## Build from source The toolchain is pinned in `rust-toolchain.toml`; `rustup` picks it up. ```sh git clone https://github.com/hwein/luradb.git cd luradb git checkout v0.7.1 cargo build --release ``` The binary is `target/release/luradb`. To build the package, install `cargo-deb` and `dpkg-dev` and run `cargo deb`; the package lands in `target/debian/`. Started without `--config`, the binary reads `./luradb.toml` if it exists, otherwise `/etc/luradb/luradb.toml`, otherwise it runs with built-in defaults. With the defaults, authentication is off, the server listens on `127.0.0.1:3000` and the data files go to the current directory; the log says so: ```text INFO luradb: No config file found at luradb.toml, using defaults WARN luradb: auth.enabled is false — the server is unauthenticated. Allowed only because server.bind_address (127.0.0.1) is loopback-only. ``` ## Command line | Option | Effect | |---|---| | `--config ` | Reads the configuration from this file. | | `--migrate-shards ` | Changes the number of data shards of the data directory to `N` while the server is stopped, see [Upgrading](https://docs.luradb.org/getting-started/upgrading/#change-the-shard-count). | | `--dump-openapi` | Prints the OpenAPI contract as JSON and exits. | Related settings: `server.bind_address`, `server.port`, `server.unix_socket_path`, `auth.enabled`, `auth.admins.name`, `auth.admins.api_key`, `storage.wal_path`, `storage.sstable_dir` # First five minutes Source: https://docs.luradb.org/getting-started/first-five-minutes/ Store a key, a JSON document and a relational table with curl. This walk-through stores a key, a JSON document and a relational table in a fresh installation, using only `curl`. It assumes the service from [Install](https://docs.luradb.org/getting-started/install/) is running and that `KEY` holds the admin key: ```sh KEY=lura_… # your admin key from /etc/luradb/luradb.toml ``` Response headers are shortened to the ones that matter; timestamps and generated keys differ on your machine. ## A key with an expiry takes two requests Data lives in domains, and a fresh installation has one called `default`. Create a domain of your own for sessions and store a key in it that expires after an hour: ```sh curl -s -X POST http://127.0.0.1:3000/store-api/domains \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"name": "sessions"}' ``` ```json { "name": "sessions", "created_at": 1794251285, "state": "active", "require_conditional_writes": { "kv": false, "json": false } } ``` ```sh curl -s -X PUT "http://127.0.0.1:3000/store-api/kv/sessions/keys/s-4f2a?ttl=3600" \ -H "Authorization: Bearer $KEY" -d '{"user": "jane"}' ``` The write answers `200` with an empty body. Read the key back with `-i` to see the headers: ```sh curl -si http://127.0.0.1:3000/store-api/kv/sessions/keys/s-4f2a \ -H "Authorization: Bearer $KEY" ``` ```text HTTP/1.1 200 OK content-type: application/octet-stream x-expires-at: 1794254886 etag: "1a1c1b5e25e0000" content-length: 16 {"user": "jane"} ``` A value is plain bytes; LuraDB does not interpret it. `X-Expires-At` is the absolute expiry in Unix seconds and the `ETag` names this version of the key, which [conditional writes](https://docs.luradb.org/how-it-works/consistency/) use. Once the hour is over, the key answers `404`. ## A document is found by an indexed field A domain holds documents and tables as well as keys. Create the domain `orders`, index the field `status` and store two documents: ```sh curl -s -X POST http://127.0.0.1:3000/store-api/domains \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"name": "orders"}' curl -s -X POST http://127.0.0.1:3000/store-api/json/orders/indexes \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"field": "status", "type": "string"}' curl -s -X POST http://127.0.0.1:3000/store-api/json/orders/documents \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"customer": "Jane Doe", "status": "open", "total": 42.5}' curl -s -X POST http://127.0.0.1:3000/store-api/json/orders/documents \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"customer": "Omar Haddad", "status": "shipped", "total": 19}' ``` Each document comes back with the key LuraDB generated and its version: ```json { "_key": "f125018a-f727-4105-8652-53209249213b", "_version": 1, "customer": "Jane Doe", "status": "open", "total": 42.5 } ``` Search accepts filters on indexed fields only; a filter on a field without an index answers `400`. Create the index before you store documents, or [reindex](https://docs.luradb.org/using/json-documents/) afterwards. ```sh curl -s -X POST http://127.0.0.1:3000/store-api/json/orders/search \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"filter": {"status": "open"}}' ``` ```json { "documents": [ { "_key": "f125018a-f727-4105-8652-53209249213b", "_version": 1, "customer": "Jane Doe", "status": "open", "total": 42.5 } ], "total": 1, "offset": 0, "limit": 50 } ``` ## A table is queried with SQL Relational tables are created and queried through one endpoint that takes one LuraSQL statement per request. The table goes into the same domain `orders`, next to the documents. Values go in as parameters: ```sh curl -s -X POST http://127.0.0.1:3000/store-api/rel/orders/sql \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"sql": "CREATE TABLE customers (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, city TEXT)"}' curl -s -X POST http://127.0.0.1:3000/store-api/rel/orders/sql \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"sql": "INSERT INTO customers (name, city) VALUES (?, ?)", "params": ["Jane Doe", "Lisbon"]}' curl -s -X POST http://127.0.0.1:3000/store-api/rel/orders/sql \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"sql": "INSERT INTO customers (name, city) VALUES (?, ?)", "params": ["Omar Haddad", "Tunis"]}' ``` The statements answer `{"ok":true}` and `{"affected":1,"last_pk":1}`. A `SELECT` returns typed columns and rows: ```sh curl -s -X POST http://127.0.0.1:3000/store-api/rel/orders/sql \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"sql": "SELECT id, name, city FROM customers WHERE city = ?", "params": ["Lisbon"]}' ``` ```json { "columns": [ { "name": "id", "type": "INTEGER" }, { "name": "name", "type": "TEXT" }, { "name": "city", "type": "TEXT" } ], "limit_applied": false, "row_count": 1, "rows": [[1, "Jane Doe", "Lisbon"]] } ``` ## The API describes itself in Swagger UI Turn the Swagger UI on in `/etc/luradb/luradb.toml` and restart the service: ```toml [server] swagger_enabled = true ``` Open `http://127.0.0.1:3000/test-ui/` in a browser; the path is `server.swagger_url`. The page and the OpenAPI contract at `/api-docs/openapi.json` load without a key, also while authentication is on: ```sh curl -s http://127.0.0.1:3000/api-docs/openapi.json ``` The calls you make from the page need a key like any other request: paste it under "Authorize". Every endpoint, with its status codes and conditions, is also in the generated pages under [REST API](https://docs.luradb.org/using/rest-api/). ## Where to go next - [Domains and engines](https://docs.luradb.org/how-it-works/domains-and-engines/) explains the three engines and how rows link to keys and documents. - [Key-value](https://docs.luradb.org/using/key-value/), [JSON documents](https://docs.luradb.org/using/json-documents/) and [LuraSQL](https://docs.luradb.org/using/lurasql/) cover each engine in detail. - [Security](https://docs.luradb.org/operating/security/) creates users whose keys reach only some domains, so that your application does not run with the admin key. Related settings: `server.swagger_enabled`, `server.swagger_url`, `auth.enabled`, `domains.default_domain` # Upgrading Source: https://docs.luradb.org/getting-started/upgrading/ Update LuraDB and know what a new release changes for you. Updating LuraDB means installing the newer `.deb` package over the old one. LuraDB is `0.x` software: on-disk formats and the REST API can change between minor releases, so read the [changelog](https://docs.luradb.org/reference/changelog/) before you update. Entries that touch the REST API are marked `API:`, breaking changes are marked **BREAKING**. ## An update installs the new package over the old one ```sh sudo apt install ./luradb_-1_amd64.deb ``` `apt` replaces the binary and the systemd unit. For the same package version, which `apt install` treats as nothing to do, use `sudo apt reinstall ./luradb_*.deb`. - `/etc/luradb/luradb.toml` is a dpkg conffile and stays as you left it. When you changed the file and the new package carries a different one, dpkg asks which to keep. - The admin key stays. The package writes a key only while the file still holds `@GENERATED_ON_INSTALL@`, which is the case on the first install only. - The package leaves `/var/lib/luradb` and the `luradb` user alone. Changes to the data format happen at the first start of the new binary. ## An update restarts the service only if it is running After unpacking, the package reloads systemd and runs `try-restart` on `luradb.service`: a running service restarts on the new binary, a stopped service stays stopped. The restart ends open connections, watch streams included; clients have to reconnect. The server shuts down gracefully on `SIGTERM`, and every confirmed write is in the write-ahead log, which the new process replays as far as it is not yet in the data files. A change you made to `luradb.toml` before the update takes effect with this restart. ## Back up before an update that changes the format A release may change what is on disk. Version 0.7.0 merges the domains of the three engines into one domain per name at its first start, see [Compatibility](https://docs.luradb.org/reference/compatibility/#what-an-update-does-to-the-data). Version 0.5.1 changes more: - The write-ahead log path becomes a directory of 64 MiB segment files. A log file written by an earlier version at that path becomes such a directory on the first start. - The engine files move into a `shard_0/` directory beside the configured paths, see [Multicore](https://docs.luradb.org/how-it-works/multicore/). - Users, API key hashes and permissions move into a separate system store, at `storage.system_dir`. - The write-ahead log header records the starting sequence number. These changes happen automatically on the first start and are one-way. Once 0.5.1 or later has started on a data directory, a version before 0.5.1 refuses to start on it, with an error that the write-ahead log is a directory, and changes no data. To go back, restore a backup taken before the update into the older version. [Backup and restore](https://docs.luradb.org/operating/backup-and-restore/) describes how to take and restore one. ## Read the changelog markers before you update Every release in the [changelog](https://docs.luradb.org/reference/changelog/) lists what changed, sorted into Added, Changed, Removed, Fixed and Security. Four markers tell you where to look first: | Marker | Example | What to check | |---|---|---| | `API:` | `API: read-only log access — GET /store-api/logs …` (0.3.0) | The REST API gained or changed an endpoint. Existing clients keep working unless the entry also says BREAKING. | | `**BREAKING** API:` | `GET /health reports per-shard status and answers 503 with status degraded when a shard does not respond.` (0.5.1) | A client that calls the endpoint can see a different response. | | `**BREAKING**` | `Requires Linux kernel 6.1 or newer; the server refuses to start on older kernels.` (0.5.1) | Something outside the REST API stops working until you act. | | `**BREAKING** Format:` | `the write-ahead log path is now a directory of segments; earlier versions cannot open a data directory written by this version.` (0.5.1) | The data format changes; going back needs a backup. | Between two releases that are far apart, read every release in between. ## The shard count stays as the data was written The number of data shards belongs to the data directory. With `multicore.shards` at `0`, its default, the server keeps the count the directory was written with, also after an update and on a host with more or fewer cores. If this host would pick a different count, the start log warns and prints the command that changes it: ```text WARN luradb::server::layout: Data shards: 1, as the data directory was written; this host would use 2. Writes stay on 1 core(s) until you stop the server and run: luradb --migrate-shards 2 ``` When the count is the one stored, the log says `Data shards: 2, as the data directory was written.` A count that you set to another number than the stored one refuses the start: ```text Error: shard count changed (stored 2, configured 3) — run `luradb --migrate-shards 3` ``` ## Change the shard count `--migrate-shards` rewrites the data directory for another number of data shards, more or fewer, down to 1. It works offline, moves key-value, JSON and relational data alike, and prints the result. With the packaged service: ```sh sudo systemctl stop luradb sudo -u luradb sh -c 'cd /var/lib/luradb && exec /usr/bin/luradb --config /etc/luradb/luradb.toml --migrate-shards 4' sudo systemctl start luradb ``` ```text INFO luradb::server::migrate: Changing the data shards from 1 to 2. INFO luradb::server::migrate: Data shards: 2. The data directory has 2 data shards. ``` - **Run it from the directory the service runs in.** Relative paths in the configuration count from the current directory, and the packaged service runs in `/var/lib/luradb`. From another directory the tool does not find the JSON and relational data and stops without changing anything. - **Stop the server first.** The server holds a lock on `/lock` for as long as it runs. Started against a running server, the tool stops with `stop the server before changing the shard count`. - **Shut the server down cleanly.** The tool refuses to run when a write-ahead log still holds writes that are not in the data files: start the server once, stop it again and rerun the tool. - **Leave room for a second copy of the data.** The new layout is built in a `migrate_/` directory inside each data directory and only then moved into place. The old layout is removed once the move has finished. - **Set `multicore.shards` to `0` or to the new count** in `luradb.toml`; any other explicit value refuses the start. - **An interrupted run can be repeated.** If the tool stops while it moves the new layout into place, the server refuses to start with `shard migration incomplete — rerun the migration tool`, and the same command finishes the change. A run stopped earlier leaves the old layout untouched. - **Backups are not affected.** An archive restores into any shard count. ## A removed configuration key is warned about and ignored A release can drop configuration keys. Version 0.5.1 removed many tuning keys, version 0.7.0 three more. A `luradb.toml` that still sets such a key starts normally and the value has no effect; the server logs one warning per key. The packaged file of 0.5.1, kept by dpkg, gives on the first start of 0.7.1: ```text WARN luradb: unknown config key 'buffer_pool.pool_size' is ignored WARN luradb: unknown config key 'rate_limit.default_max_storage_bytes' is ignored WARN luradb: unknown config key 'storage.db_path' is ignored ``` The server makes no difference between a removed key and one that never existed, so the same warning also catches a typo. Look the key up in the [removed keys](https://docs.luradb.org/operating/configuration/#removed-keys) of the configuration reference: each entry says in which release the key was removed and what replaced it or why it went, for example `io_engine.sqpoll_enabled` (removed) or `lsm.use_mmap` (removed). After the update, read the start log once with `journalctl -u luradb -b` and remove or replace every key it warns about. ## A kept luradb.toml keeps its old values A file that dpkg keeps also keeps the values the old package wrote into it, where the new package ships a different default. From 0.5.1 to 0.7.x this matters for `lsm.max_key_length`: the old file sets `256`, the new package `512`. With `256`, the start caps the key-value keys at 237 bytes, once per data shard: ```text WARN luradb::server::control: domains.max_user_key_length (256) is capped to 237 by lsm.max_key_length (256) minus the 19-byte internal domain prefix; raise lsm.max_key_length to use the full length ``` Set `max_key_length = 512` in `[lsm]` and restart to allow keys of 256 bytes again. When dpkg kept your file, the package version lies beside it as `/etc/luradb/luradb.toml.dpkg-dist`; `diff` shows every other default that changed. ## After the update ```sh curl -s http://127.0.0.1:3000/version -H "Authorization: Bearer $KEY" ``` ```json { "server_version": "0.7.1", "api_version": "0.17.0" } ``` `server_version` is the release; `api_version` is the version of the REST contract, which changes independently of it. `GET /health` should answer `"status": "ok"`; see [Resource guard](https://docs.luradb.org/how-it-works/resource-guard/) for what `degraded` means. Related settings: `multicore.shards`, `storage.wal_path`, `storage.system_dir`, `backup.enabled`, `backup.dir` # Domains and engines Source: https://docs.luradb.org/how-it-works/domains-and-engines/ What a domain is and how the key-value, JSON and relational engines share it. A domain is the unit you create, protect and back up. It holds keys, documents and tables alike, and each engine keeps the shape of data it is good at: key-value, JSON documents and slim relational tables (LuraSQL). A relational row can point at a key or a document in the same domain. ## A domain holds keys, documents and tables One request creates a domain, and from then on all three engines store data under its name. Each engine has its own endpoints below the domain: | Engine | Keeps | Endpoints | Typical use | |---|---|---|---| | Key-value | Bytes under a key, with TTL, null state and a change stream | `/store-api/kv/{domain}/…` | Sessions, tokens, flags, counters | | JSON | Documents with a version, secondary indexes and search | `/store-api/json/{domain}/…` | Payloads, catalogs, anything with loose ends | | LuraSQL | Tables with typed columns, indexes, views and joins | `/store-api/rel/{domain}/…` | Fixed fields, relations, reports | ```sh curl -s -X POST http://127.0.0.1:3000/store-api/domains \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"name": "orders"}' ``` ```json { "name": "orders", "created_at": 1794251251, "state": "active", "require_conditional_writes": { "kv": false, "json": false } } ``` `GET /store-api/domains` lists the active domains and `GET /store-api/domains/orders` returns one. `require_conditional_writes` is set when the domain is created and makes single-key and single-document writes conditional, see [Consistency](https://docs.luradb.org/how-it-works/consistency/#a-domain-can-require-conditional-writes). Every start creates a domain called `default` if it is missing; `domains.default_domain` sets the name. A name uses letters, digits, `_` and `-`, up to `domains.max_name_length` characters, 50 by default. A name that breaks the rule answers `400`, a name that exists `409`. `DELETE /store-api/domains/orders` answers `202 Accepted` and deletes the domain with its keys, documents, tables and views. The domain is gone for clients at once: the list no longer shows it, and its endpoints answer `410 Gone` while the data is purged in the background. Until the purge is done, the name stays taken and creating it again answers `409`. The permissions on the domain are deleted with it. The JSON and the relational engine can be switched off, see `json.enabled` and `rel.enabled`. Their endpoints then answer `503`, and the domains stay; the next start with the engine on catches up on the domains created or deleted meanwhile. The key-value engine always runs. A domain lives on one data shard, with its keys, documents and tables. That is what allows rows to link to keys and documents, and it is why one busy domain gives one core the writes, see [Multicore](https://docs.luradb.org/how-it-works/multicore/). ## Key-value keeps bytes under a key In the key-value engine, a domain maps a key to a value. The key is valid UTF-8 of at most 256 bytes (`domains.max_user_key_length`); the value is any bytes, and LuraDB does not interpret them. A key can carry a TTL, after which it disappears, and it can be set to an explicit null state that keeps it listed but empty. Keys are listed and counted by prefix, deleted by prefix in one atomic step, and watched over a server-sent-events stream that delivers each change. Every version of a key has an `ETag` for [conditional writes](https://docs.luradb.org/how-it-works/consistency/). The page [Key-value](https://docs.luradb.org/using/key-value/) goes through each call. ## JSON keeps documents with a version In the JSON engine, a domain stores documents. A document has a key, either one you choose or a generated UUID, and a version that counts its writes; both come back in the reserved fields `_key` and `_version` next to the fields of the document. Search filters on fields that have an index, with equality or ranges, and pages through the result. Documents are loaded in bulk from NDJSON and exported as NDJSON. See [JSON documents](https://docs.luradb.org/using/json-documents/). ## LuraSQL keeps rows in tables In the relational engine, a domain holds tables with typed columns (`INTEGER`, `REAL`, `TEXT`, `BOOLEAN`, `TIMESTAMP`), primary keys, `AUTOINCREMENT`, indexes, views and left joins. One request carries one statement, with `?` placeholders bound from a `params` array. Besides `/sql`, tables have row endpoints and a CSV/TSV import. LuraSQL is deliberately small: see [LuraSQL](https://docs.luradb.org/using/lurasql/) for what it supports and where it stops. ## A row can point at a key or a document A column of type `KVREF` holds the key of a key-value entry, a column of type `JSONREF` the key of a JSON document. The target is always in the **same domain** as the table. A table in the domain `orders` can point at keys and documents of `orders`, and at nothing else. ```sh curl -s -X PUT http://127.0.0.1:3000/store-api/kv/orders/keys/label-1001 \ -H "Authorization: Bearer $KEY" -d 'LISBON-0042' curl -s -X PUT http://127.0.0.1:3000/store-api/json/orders/documents/o-1001 \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"customer": "Jane Doe", "status": "open", "total": 42.5}' curl -s -X POST http://127.0.0.1:3000/store-api/rel/orders/sql \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"sql": "CREATE TABLE shipments (id INTEGER PRIMARY KEY AUTOINCREMENT, order_doc JSONREF, label KVREF, carrier TEXT)"}' curl -s -X POST http://127.0.0.1:3000/store-api/rel/orders/sql \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"sql": "INSERT INTO shipments (order_doc, label, carrier) VALUES (?, ?, ?)", "params": ["o-1001", "label-1001", "DHL"]}' ``` A plain `SELECT` returns the keys. With `expand`, the server looks the targets up and returns them next to the rows: ```sh curl -s -X POST http://127.0.0.1:3000/store-api/rel/orders/sql \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"sql": "SELECT id, order_doc, label, carrier FROM shipments", "expand": ["*"]}' ``` ```json { "columns": [ { "name": "id", "type": "INTEGER" }, { "name": "order_doc", "type": "JSONREF" }, { "name": "label", "type": "KVREF" }, { "name": "carrier", "type": "TEXT" } ], "expanded": { "label": [{ "encoding": "utf8", "exists": true, "value": "LISBON-0042" }], "order_doc": [{ "document": { "customer": "Jane Doe", "status": "open", "total": 42.5 }, "exists": true }] }, "limit_applied": false, "row_count": 1, "rows": [[1, "o-1001", "label-1001", "DHL"]] } ``` A key whose value is not valid UTF-8 comes back base64-encoded, with `"encoding": "base64"`. A key in the null state resolves to `exists: true` with `value: null`. The rules for a link: - **A link is checked when it is written.** Inserting or updating a row with a target that does not exist is refused with `409 Conflict`: `cross-engine link target 'o-9999' of column 'order_doc' is missing in json`. The check reads the target at that moment; keys and documents can be deleted later, and the link then dangles. - **A dangling link resolves to a missing target, not to an error.** An `expand` of a target that is gone returns `"exists": false`. - **While an engine is switched off, its links read `NULL`.** The stored cells stay and come back with the engine. - **A link needs read access to its target.** Reading a link cell, and writing one, requires read permission on the keys or documents it points to. Without it, the cell reads `NULL`, and a write that sets the link is refused with `403`. - **Backups carry the links.** After a restore they resolve when the keys and documents they point to are restored too or already exist; otherwise they read as missing. [Backup and restore](https://docs.luradb.org/operating/backup-and-restore/) has the details. ## Rights are granted per domain or per engine A user is a name with an API key and a set of permissions. A permission names a domain and a level, and optionally an engine (`kv`, `json` or `rel`). Without an engine it covers the whole domain: keys, documents and tables. The levels build on each other: `read` allows reading, `write` also writing, `ddl` also the DDL statements of LuraSQL: creating, changing and dropping tables, views and indexes. The key of the admin account passes every check. ```sh curl -s -X POST http://127.0.0.1:3000/store-api/auth/users/reporter/permissions \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"domain": "sessions", "access": "read"}' curl -s -X POST http://127.0.0.1:3000/store-api/auth/users/reporter/permissions \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"domain": "orders", "access": "write", "engine": "json"}' ``` With the key of `reporter`, the domain `sessions` is readable in every engine, and of `orders` only the documents are reachable: | Request | Answer | |---|---| | `GET /store-api/kv/sessions/keys/s-4f2a` | `200` | | `PUT /store-api/kv/sessions/keys/s-4f2a` | `403 Forbidden` | | `GET /store-api/kv/default/keys/hello` | `403 Forbidden` | | `POST /store-api/json/orders/documents` | `201 Created` | | `POST /store-api/rel/orders/sql` with a `SELECT` | `403 Forbidden`: the permission on `orders` covers the JSON engine only | | `GET /store-api/domains` | `200`, listing `orders` and `sessions` | In `/sql`, the statement decides the level it needs: a `SELECT` needs `read`, an `INSERT`, `UPDATE` or `DELETE` needs `write`, and `CREATE`, `ALTER` or `DROP` needs `ddl`. Creating and deleting domains, managing users and the global metrics and configuration endpoints are for the admin account only. [Security](https://docs.luradb.org/operating/security/) describes users, key rotation and the other ways to authenticate. Related settings: `domains.default_domain`, `domains.max_name_length`, `domains.max_user_key_length`, `rate_limit.default_read_iops`, `rate_limit.default_write_iops`, `json.enabled`, `rel.enabled` # Write path Source: https://docs.luradb.org/how-it-works/write-path/ How a write travels from the write-ahead log to the data files. A write is confirmed only once it is in the write-ahead log. From there the data moves into the MemTable and, once the MemTable is full, into SSTables on disk; the log is what recovery replays after a crash. ## From request to disk ### A write is confirmed once it is in the write-ahead log Drawing: A client sends a put request. The storage thread appends it to the write-ahead log and syncs it, and the client gets the answer. The MemTable takes the write next and readers see it. A value of 1 KiB or more is appended to the value log first. When the MemTable is full it is written as a level-0 SSTable, and compaction merges SSTables into lower levels. The three engines store their data the same way, in LSM trees. What follows describes one write of a key; JSON documents and relational rows take the same road, each engine with a log, SSTables and a value log of its own. 1. **The shard admits the write.** The request has been routed to the shard that owns the domain, see [Multicore](https://docs.luradb.org/how-it-works/multicore/). While disk space or memory is short, the write is refused here with `507`, see [Resource guard](https://docs.luradb.org/how-it-works/resource-guard/). 2. **The write waits for the storage thread.** One dedicated thread writes the logs of all engines through `io_uring`. Writes wait for it in a queue of `storage.wal_queue_capacity` places; when the queue is full, further writes are held back until there is room. 3. **The storage thread appends the record to the log of the engine and syncs it with `fdatasync`.** It batches concurrent writes into one sync per log (group commit), so a busy server does not pay a sync for every write. Only after the sync does the write count as confirmed. 4. **A large value goes to the value log.** A value of at least `lsm.vlog_inline_threshold` bytes (1024 by default) is appended to the value log of the engine; the MemTable keeps a pointer to it. Smaller values stay inline. 5. **The MemTable takes the write.** From this moment readers see it, and the client gets its answer. If a sync fails, the service stops with exit code 3 instead of carrying on with data it may not have on disk, and the next start recovers from the log; see [Resource guard](https://docs.luradb.org/how-it-works/resource-guard/#when-the-disk-fails). ## A full MemTable becomes an SSTable The MemTable is a sorted structure in memory that holds the newest writes. When its size, keys plus stored values, reaches `lsm.memtable_size_threshold` (4 MiB by default), it is frozen and a fresh MemTable takes over. The flush loop looks every `lsm.flush_check_interval_ms` (100 ms) for a frozen MemTable and writes the oldest one to disk as a level-0 SSTable, an immutable sorted file, and then saves the manifest, the list of files that make up the tree. You can watch this happen. Writing 6000 values of 900 bytes into a fresh server crosses the threshold once, and `/health` counts the file: ```json { "estimated_memtable_keys": 1523, "l0_sstable_count": 1, "vlog_size_bytes": 0 } ``` `l0_sstable_count` is the number of level-0 files, summed over the shards; `estimated_memtable_keys` is what the MemTables still hold. The JSON and relational engines flush at the same size with the same loop; only the key-value engine reads the `[lsm]` settings, the other two use these values built in. ## Compaction merges SSTables into levels Level-0 files overlap each other, so every read has to look at all of them. Compaction keeps their number down. When `compaction.l0_threshold` level-0 files exist (4), they are merged with the overlapping files of level 1 into new sorted files. A level from 1 on is limited in size: level 1 to `compaction.l1_max_size` (100 MiB), every following level to `compaction.level_size_ratio` times the one before (10). When a level exceeds its limit, its largest file is merged with the overlapping files of the next level. A merge writes its output as a stream, one file at a time, each at most `compaction.max_sstable_size` (64 MiB); its memory does not grow with the size of its inputs. A merge drops the versions of a key that no reader can still see, and a deletion marker only once no older version of the key exists below it. The loop checks for work every `lsm.compaction_check_interval_ms` (1 s). ## The value log keeps large values and a janitor cleans it SSTables hold keys and small values. A large value lives in the value log, a file that is only appended to, so that merging SSTables never copies it. An overwrite or a delete leaves the old bytes in the value log as dead space. Every `janitor.check_interval_secs` (60 s) the janitor estimates the dead share. Once the value log is at least `janitor.min_vlog_size_bytes` (64 MiB) and at least `janitor.dead_bytes_threshold` of it is dead (30 %), it copies the live values into a new generation of the file, rebuilds the SSTables that point into the old one and deletes the old generations once no reader uses them. A run waits when the volume lacks the room for the copy. `vlog_size_bytes` in `/health` is the size of the value logs summed over the shards. ## The log is trimmed once its contents are in SSTables A write-ahead log is a directory of segment files of 64 MiB. A new segment starts when the current one is full. Once a second the server drops every segment whose records all shards already have in SSTables. A shard that rarely writes would keep old segments alive; so when the segments of a log reach `storage.wal_max_size` (256 MiB), the shards that still hold records of the oldest segment only in memory write them out, and the segment is deleted. A segment that has held records for five minutes is closed and dropped the same way. The entry for `storage.wal_max_size` explains the trade-off between early writes and recovery time. ## After a crash, the log is replayed The next start reads each log and replays the records that are not yet in SSTables, streaming them so that memory stays bounded. Sequence numbers go on where they stopped. A clean shutdown writes the MemTables out first, so little is left to replay; a crash leaves the MemTables' contents in the log, and nothing confirmed is lost. The more the log holds, the longer the replay takes, which is what `storage.wal_max_size` limits. ## Expired keys leave in two steps A key with a TTL stays visible for at least its TTL and becomes invisible to reads within a second after that. The TTL sweeper then removes it for good: every `ttl_sweeper.interval_secs` (60 s) it checks up to `ttl_sweeper.batch_size` (500) candidates and writes a tombstone and a delete event for each expired one. Compaction drops the tombstone later, by the rule above. With `ttl_sweeper.enabled` off, expiry is purely lazy: expired keys are hidden on read but stay in the files until compaction meets them. ## Readers work on snapshots A read works on one consistent set of the engine's files and MemTables, so a flush or a compaction that finishes during the read cannot make it miss a key. Queries that need one moment, such as a JSON search or a `SELECT`, read in a snapshot of their own. A batch of writes, such as the documents of one bulk-import step, becomes visible all at once. ### Local clients can read snapshots from shared memory With `[shm]` switched on, the server publishes a snapshot of the key-value data into shared memory for clients on the same host. It builds the snapshot from one consistent point across all data shards, checks every `shm.snapshot_interval_ms` (100 ms) and rebuilds it only when the data changed. A local client reads it without locks and without a network round trip; values that live in the value log come through a command ring to the server. The segments are two data buffers of `shm.data_buffer_size` each (256 MiB) and a state header: ```text luradb_docs.lock luradb_docs_data_a luradb_docs_data_b luradb_docs_state ``` These are the files in `/dev/shm` of a server started with `shm.enabled` and `shm.instance_id` set to `docs`. The path where clients register is `shm.registration_socket_path`. The feature is off by default: members of the `luradb` group can read all key-value data through it without an API key, and with authentication on only the users listed in `auth.trusted_uids` can register as clients. Every rebuild briefly holds back the writes of all shards. `/store-api/metrics` carries the counters in its `shm` block. ## What the data directory looks like With the packaged configuration, the files of one server are laid out like this under `/var/lib/luradb`, here for one data shard: ```text luradb.wal/00000001.wal key-value write-ahead log: segments of 64 MiB luradb.wal/00000002.wal the next segment, prepared in advance luradb_json.wal/ the same for the JSON engine luradb_rel.wal/ and for the relational engine luradb_sys/ system store: users, API key hashes, permissions, shard layout shard_0/luradb.vlog value log of the key-value engine shard_0/luradb_json.vlog value log of the JSON engine shard_0/luradb_rel.vlog value log of the relational engine sstables/shard_0/MANIFEST list of the SSTables of the key-value engine sstables/shard_0/sstable_000000.sst luradb_json_sstables/shard_0/ SSTables of the JSON engine luradb_rel_sstables/shard_0/ SSTables of the relational engine ``` Each log is one directory for all shards. The other files exist once per shard, under `shard_/`: inside the SSTable directories, and beside the configured path for the value logs. Never change a file in these directories by hand. The paths are set by `storage.wal_path`, `storage.vlog_path`, `storage.sstable_dir`, `storage.system_dir`, `json.wal_path`, `json.vlog_path`, `json.sstable_dir`, `rel.wal_path`, `rel.vlog_path` and `rel.sstable_dir`. Related settings: `storage.wal_max_size`, `storage.wal_queue_capacity`, `storage.wal_path`, `storage.vlog_path`, `storage.sstable_dir`, `storage.system_dir`, `json.wal_path`, `json.vlog_path`, `json.sstable_dir`, `rel.wal_path`, `rel.vlog_path`, `rel.sstable_dir`, `lsm.memtable_size_threshold`, `lsm.vlog_inline_threshold`, `lsm.flush_check_interval_ms`, `lsm.compaction_check_interval_ms`, `compaction.l0_threshold`, `compaction.l1_max_size`, `compaction.level_size_ratio`, `compaction.max_sstable_size`, `janitor.check_interval_secs`, `janitor.dead_bytes_threshold`, `janitor.min_vlog_size_bytes`, `ttl_sweeper.enabled`, `ttl_sweeper.interval_secs`, `ttl_sweeper.batch_size`, `shm.enabled`, `shm.snapshot_interval_ms`, `shm.data_buffer_size` # Multicore Source: https://docs.luradb.org/how-it-works/multicore/ How LuraDB spreads domains over data shards and cores. LuraDB spreads its domains over several data shards by name; each shard is one thread with its own storage engines. Reads scale across cores, while the writes of one domain stay on one. ## How requests reach the cores ### Every domain lives on one shard, so its writes run on one core Drawing: Three clients write. A frontend worker reads the domain name of each request and hands it to the shard that owns that domain. Two writes to the domain orders end up on shard 0, one after the other; a write to sessions runs on shard 1 at the same time. ### Reads of one domain run on many cores at once Drawing: Three reads of the domain orders run at the same time on three different threads: a point read on the connection thread, a search and a prefix scan on two reader threads. All three read the data of shard 0, while shard 0's own thread keeps writing. The shard numbers in the drawings are examples. LuraDB hashes the name of a domain into one of 256 fixed slots and gives the slot to shard number `slot mod shards`; the result depends only on the name and the shard count, and nothing is stored per domain. The keys, documents and tables of a domain all lie on that shard. ## What that means for one domain - **Reads scale across cores.** Point reads run on the thread that holds the connection, longer reads on a pool of reader threads, both against the shard of the domain, from any number of connections at once. - **Writes of one domain run on exactly one core**, the thread of its shard. Write parallelism is at most the number of domains being written at the same time; spread independent write traffic over several domains. - **One connection serves one request at a time**, also with HTTP/2. A client that wants parallelism opens several connections. ## Each kind of thread has one job | Thread | Sized by | Job | |---|---|---| | Frontend workers | `multicore.frontend_workers` | Accept connections, terminate TLS, parse HTTP, find the shard of the domain in the path, answer point reads, hand everything else on. | | Data shards | `multicore.shards` | Each shard is one thread with its own storage engines: it runs every write of the domains it owns. | | Reader pool | `multicore.reader_threads` | Runs the longer reads of all shards: scans, listings, searches and `SELECT` statements. | | Control plane | one | Runs the requests that name no domain, such as creating a domain or a user, and carries the backup and restore jobs. | | Storage thread | one | Writes the write-ahead logs of all engines, see [Write path](https://docs.luradb.org/how-it-works/write-path/). | | CPU offload | `multicore.cpu_offload_threads` | Takes CPU-heavy parsing, such as the body of a bulk import, off the engine threads. | The MCP listener, when enabled, runs on a runtime of its own with one worker, so that its long-lived streams take no frontend worker. A request waits in a queue when its thread is busy, and the queues are bounded. A data shard takes `multicore.shard_queue_capacity` requests at once, running or waiting; the reader pool queues `multicore.reader_queue_capacity` reads. A request beyond that is answered `503 Service Unavailable` with `Retry-After: 1`: it was not processed and may be retried. ## Automatic sizing The cores are split automatically between frontend workers (HTTP/TLS), data shards and reader threads, and `[multicore]` in `luradb.toml` overrides each part. | Part | Automatic size | 4 cores | 8 cores | 12 cores | 32 cores | |---|---|---|---|---|---| | Frontend workers | cores / 6, 2 to 4; 1 below 4 cores | 2 | 2 | 2 | 4 | | Data shards (new data directory) | cores / 4, 1 to 8 | 1 | 2 | 3 | 8 | | Reader threads | cores − 2 − frontend − shards, at least 1 | 1 | 2 | 5 | 18 | The start log reports the split. On a host limited to four cores: ```text INFO luradb::server: 4 cores: 2 frontend workers, 1 data shards, 1 reader threads; shard queue capacity: 1024 INFO luradb::server: Reader pool queue capacity: 4096 ``` The CPU offload takes the cores minus two, at least one; the log says `CPU offload permits: 2` there. A shard count that you set applies as given; the table shows the automatic size for a data directory that is created now. For an existing one, see below. ## Every shard adds memory The memory budgets of the storage engines are split across the shards, except the MemTable, which is per shard. The block cache, 64 MiB per engine, is divided evenly, so more shards do not mean more cache. The MemTable threshold `lsm.memtable_size_threshold` applies to every engine on every shard, so MemTable memory grows to engines × shards × threshold, plus the MemTables being flushed. The start log shows each shard's share. A server with one shard and one with eight: ```text INFO luradb::server::control: Shard 0: block cache 65536 KiB per engine; MemTable threshold 4194304 bytes per engine; registered I/O buffers off. ``` ```text INFO luradb::server::control: Shard 0: block cache 8192 KiB per engine; MemTable threshold 4194304 bytes per engine; registered I/O buffers off. … INFO luradb::server::control: Shard 7: block cache 8192 KiB per engine; MemTable threshold 4194304 bytes per engine; registered I/O buffers off. ``` When the memory that the server takes regardless of load exceeds half of `resources.memory_budget`, the start logs a warning that lists the parts. ## The shard count belongs to the data directory The data of a domain lies in the files of its shard, so the shard count is part of the layout of the data directory. The first start records it in the system store. With `multicore.shards` at `0`, an existing directory keeps the count it was written with, also after an update or a move to a host with another number of cores; the table above applies to new directories only. When the host would pick another count, the start logs: ```text WARN luradb::server::layout: Data shards: 1, as the data directory was written; this host would use 2. Writes stay on 1 core(s) until you stop the server and run: luradb --migrate-shards 2 ``` A count that you set explicitly and that differs from the stored one refuses the start, and nothing changes on disk: ```text Error: shard count changed (stored 2, configured 3) — run `luradb --migrate-shards 3` ``` `luradb --migrate-shards N` rewrites the data directory for `N` shards while the server is stopped, more or fewer, down to 1, and moves key-value, JSON and relational data alike. A domain may end up on another shard, since the shard of a domain follows the count. The procedure, with its preconditions and what happens when it is interrupted, is in [Upgrading](https://docs.luradb.org/getting-started/upgrading/#change-the-shard-count). Related settings: `multicore.shards`, `multicore.frontend_workers`, `multicore.reader_threads`, `multicore.reader_queue_capacity`, `multicore.shard_queue_capacity`, `multicore.cpu_offload_threads`, `lsm.memtable_size_threshold` # Consistency and conditional writes Source: https://docs.luradb.org/how-it-works/consistency/ ETag, If-Match and If-None-Match, and what 412 and 428 mean. Keys and documents carry an `ETag`. `If-Match` makes a write conditional on the version you read, and `If-None-Match: *` creates only when nothing exists yet. A domain created with `require_conditional_writes` rejects unconditional writes of single keys or documents with `428`. ## Every key and document has an ETag A read of a key or a document answers with an `ETag` header that names the version you got: ```sh curl -si http://127.0.0.1:3000/store-api/kv/default/keys/greeting \ -H "Authorization: Bearer $KEY" ``` ```text HTTP/1.1 200 OK content-type: application/octet-stream etag: "1a1c1c23b440000" content-length: 5 hello ``` A document answers the same way, `"4182c7d5033b1bdc-1"` being its tag at `_version` 1. Treat an ETag as an opaque string and send it back unchanged. Every write gives the key or document a new one, and a key or document that is deleted and written again never gets a tag it had before, so a stale tag cannot match by accident. A key in the explicit null state has an ETag too: its read answers `204` with the header. ## If-Match writes only if nothing changed since you read Send the tag of the version you read in `If-Match`. If another writer got in between, the write is refused with `412 Precondition Failed`, nothing is written, and the answer carries the tag of the current version: ```sh ETAG='"1a1c1c23b440000"' curl -si -X PUT http://127.0.0.1:3000/store-api/kv/default/keys/greeting \ -H "Authorization: Bearer $KEY" -H "If-Match: $ETAG" -d 'hello again' ``` ```text HTTP/1.1 200 OK ``` The same request again, now with a stale tag, loses: ```text HTTP/1.1 412 Precondition Failed etag: "1a1c1c23b9a0000" 412 Precondition Failed: the key's current version does not satisfy the write precondition ``` A client that wants to merge reads the key again and retries with the new tag. The check and the write are one step: they run while the key's write lock is held, so no other single-key write of the same domain can fall between them. - `If-Match` on a key or document that does not exist answers `412` without an `ETag`, because there is no current version to name. - A value that is not a tag, such as `If-Match: nonsense`, answers `400 Bad Request`. - `PUT`, `DELETE` and `PATCH …/null` on a key take the header, and so do `PUT` and `DELETE` on a JSON document. For a JSON document the refusal reads differently: ```sh curl -si -X PUT http://127.0.0.1:3000/store-api/json/orders/documents/o-1001 \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -H 'If-Match: "4182c7d5033b1bdc-1"' -d '{"status": "cancelled", "total": 42.5}' ``` ```text HTTP/1.1 412 Precondition Failed etag: "4182c7d5033b1bdc-2" version conflict: expected "4182c7d5033b1bdc-1", actual "4182c7d5033b1bdc-2" ``` Releases before 0.5.1 answered `409` here; see [Compatibility](https://docs.luradb.org/reference/compatibility/). ## If-None-Match: * creates only `If-None-Match: *` writes only when the key or document does not exist. The first request creates, the second finds the key and is refused with `412` and the current tag: ```sh curl -si -X PUT http://127.0.0.1:3000/store-api/kv/default/keys/fresh \ -H "Authorization: Bearer $KEY" -H "If-None-Match: *" -d 'first' ``` ```text HTTP/1.1 200 OK ``` The literal `*` is the only value accepted; anything else answers `400`. Use it to claim a name, a lock or an idempotency key without a read first. When a request carries both headers, `If-Match` is evaluated first and `If-None-Match` second. On a key that does not exist, the failing `If-Match` decides and the answer is `412`. ## A domain can require conditional writes A strict domain refuses single-key and single-document writes that carry neither header. The setting `require_conditional_writes` names the engines it applies to, `kv` for keys and `json` for documents; a field left out is `false`. It is made when the domain is created and stays with the domain: ```sh curl -s -X POST http://127.0.0.1:3000/store-api/domains \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"name": "ledger", "require_conditional_writes": {"kv": true, "json": true}}' curl -si -X PUT http://127.0.0.1:3000/store-api/kv/ledger/keys/o-1001 \ -H "Authorization: Bearer $KEY" -d '{"status": "open"}' ``` ```text HTTP/1.1 428 Precondition Required cache-control: no-store 428 Precondition Required: domain 'ledger' requires If-Match or If-None-Match: * on writes ``` The same request with `If-None-Match: *` is accepted. The rule covers the single-key REST writes: `PUT`, `DELETE` and `PATCH …/null` on a key, `PUT` and `DELETE` on a JSON document. It does not cover bulk operations, such as the NDJSON import and the delete by prefix, or other write paths; the contract says so for both engines. Tables have no such setting. A plain `true` instead of the object answers `400 Bad Request: require_conditional_writes must be an object {"kv": bool, "json": bool}`. A backup keeps the setting, and a restore that creates the domain sets it again. | Status | Meaning | |---|---| | `400` | `If-Match` is not a tag from a prior read, or `If-None-Match` is not `*`. Nothing is written. | | `412` | The precondition does not hold. Nothing is written; the answer carries the current `ETag` unless the key does not exist. | | `428` | The domain requires conditional writes and the request carries neither header. | ## Bulk operations are atomic in steps, not as a whole - **A bulk import of JSON documents** is applied in batches of 100 documents. Each batch is atomic: its documents appear to readers together, or not at all. The import as a whole is not. A document that fails its checks, or a line that is not valid JSON, is reported and skipped, and the rest goes on; an error of the storage aborts the call, and the batches already applied stay. The answer counts what happened: ```sh printf '%s\n' '{"_key": "o-2001", "status": "open"}' '{"_key": "o-2002", "status": "open"}' 'not json' \ | curl -s -X POST http://127.0.0.1:3000/store-api/json/orders/bulk \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/x-ndjson" --data-binary @- ``` ```json { "imported": 2, "failed": 1, "errors": [{ "key": "line 3", "error": "invalid JSON: expected ident at line 1 column 2" }] } ``` - **A delete by prefix** removes all matching keys in one atomic step, or none. A selection of more than `domains.max_bulk_delete_keys` keys is refused with `413` and nothing is deleted; with the limit at 5 and eight matching keys the answer is `413 Payload Too Large: 8 keys match the selection, limit is 5`. ```sh curl -s -X DELETE "http://127.0.0.1:3000/store-api/kv/default/keys?prefix=tmp-" \ -H "Authorization: Bearer $KEY" ``` ```json { "deleted": 3 } ``` - **A CSV import into a table** imports row by row. A row that fails is logged and skipped, and the import goes on. A bulk write takes no preconditions. The JSON import is limited in size by `json.bulk_body_limit_bytes`, the table import by `rel.import_body_limit_bytes`. ## What a reader sees - **A confirmed write is visible to every read that starts after the answer.** The answer is sent after the write reached the MemTable, see [Write path](https://docs.luradb.org/how-it-works/write-path/). - **A search or a query sees one moment.** A JSON search returns its documents and its `total` from one state, and a `SELECT` reads in one snapshot, also while writes and compactions go on. - **Requests on one connection are processed in order**, HTTP/2 included. A client that writes and then reads on one connection sees its own write; parallelism needs several connections. - **An export is not a snapshot.** The export of the documents of a domain is a stream: it lists the keys first and then reads one document after the other, so a document changed or deleted during the export is exported in its newer state or skipped. Related settings: `domains.max_bulk_delete_keys`, `json.bulk_body_limit_bytes`, `rel.import_body_limit_bytes` # Resource guard Source: https://docs.luradb.org/how-it-works/resource-guard/ How LuraDB protects itself when disk space or memory runs short. The server checks the free space of its data volumes and its own memory use every second. Below the warn thresholds it logs a warning and `GET /health` reports `degraded`; below the block thresholds it refuses writes with `507 Insufficient Storage` and `Retry-After` while reads continue, and it resumes on its own once there is room again. ## The server watches every volume its data lies on Once a second the server reads the free space of every volume that one of its data paths lies on: the data files, the write-ahead logs, the log directory and the backup directory. A volume that several paths share is watched once. "Free" is what an unprivileged process can use, without the share reserved for root. A volume that hangs, such as an unreachable network mount, holds up nothing else: it keeps its last reading, and the log shows a warning after five seconds. The server also reads its own anonymous memory (`RssAnon` in `/proc`) and compares it with a budget. The start log reports what is watched: ```text INFO luradb::control::resources: Watching the volume of /var/lib/luradb/sstables: 1081101176832 bytes, 836397944832 free; warning below 834397000000 bytes free, writes refused below 830397000000, resumed above 832397000000. INFO luradb::control::resources: Memory budget 12259860480 bytes of 16346480640 (MemTotal); warning from 80 %, writes refused from 95 %, resumed below 90 %. ``` | Setting | Default | Meaning | |---|---|---| | `resources.disk_free_warn` | `"15% max 10 GB"` | Free space below which the server warns. | | `resources.disk_free_block` | `"5% max 2 GB"` | Free space below which the server refuses writes. | | `resources.disk_free_resume` | `"10% max 4 GB"` | Free space each volume needs before refused writes resume. | | `resources.memory_budget` | `"75%"` | The anonymous memory the server may use: a share of the host's memory, or of the cgroup limit `memory.max` when that is lower. | A disk threshold is a size, a percentage of the volume, or both, of which the smaller counts. The thresholds are resolved once at start, separately for each volume, and must satisfy `block <= resume <= warn` with a block threshold of at least 64 MiB, or the start is refused. The memory thresholds are fixed shares of the budget: warning from 80 %, writes refused from 95 %, writes accepted again below 90 %. The budget is at least 256 MiB. ## Three states: ok, warning, blocked | State | When | Writes | `GET /health` | |---|---|---|---| | `ok` | Every volume is above its warn threshold and memory is below 80 % of the budget. | Accepted. | `"status": "ok"` | | `warning` | A volume is below its warn threshold, or memory is at 80 % or more. | Accepted. | `"status": "degraded"`, HTTP status `200` | | `blocked` | A volume is below its block threshold, or memory is at 95 % or more. | Refused with `507`. | `"status": "degraded"`, HTTP status `200` | The state is one value for the whole server: the worst of all volumes and of memory. `/health` carries the parts in its `resources` field, without paths or numbers: ```json { "status": "degraded", "resources": { "disk_state": "warning", "memory_state": "ok", "state": "warning" } } ``` `GET /store-api/metrics`, which needs the admin key, adds the volumes, their paths and the numbers in its own `resources` block. ## Warning: nothing is refused yet The warning is the early notice. The server logs one line per state change and repeats it every minute while the state lasts: ```text WARN luradb::control::resources: Resources running short: disk /var/lib/luradb/sstables free 833397870592 of 1081101176832, threshold 834397000000. Nothing is refused yet; writes are refused below the block threshold. ``` Let monitoring poll `/health` and alert on `degraded`; that gives you the time to add space or remove data before writes stop. ## Blocked: writes answer 507 and reads go on Below the block threshold the server logs an error, repeated every minute, and every write answers `507 Insufficient Storage` with `Retry-After: 5`: ```sh curl -si -X PUT http://127.0.0.1:3000/store-api/kv/default/keys/k3 \ -H "Authorization: Bearer $KEY" -d v3 ``` ```text HTTP/1.1 507 Insufficient Storage retry-after: 5 507 Insufficient Storage: write blocked: disk space below threshold, retry in 5 s ``` ```text ERROR luradb::control::resources: Writes refused: disk /var/lib/luradb/sstables free 829397864448 of 1081101176832, threshold 830397000000. Writes, deletes and new backups on a short volume answer 507 until every volume is above its resume threshold; reads, health, backup downloads and deletions and sign-ins go on. ``` The write is not applied. What is refused and what goes on: | Refused with `507` | Goes on | |---|---| | Writes, deletes and `PATCH …/null` on keys | Reads of keys, documents and rows | | Document writes and bulk imports | JSON searches, SQL `SELECT`, listings and counts | | SQL `INSERT`, `UPDATE`, `DELETE` and DDL, table imports | `/health` and `GET /store-api/metrics` | | Creating domains | Creating users, rotating keys, sign-ins | | Restores and the write tools of MCP | Downloading and deleting backups | | New backups, unless the backup directory is on another volume above its warn threshold and memory is not short | Compaction and the cleanups of the value log and the write-ahead log, which free space where they can | Background jobs that only write deletion markers, such as the TTL sweeper, wait. Clients of the shared-memory path get the same error. A refused write was not applied; the client can try it again after the `Retry-After` of 5 seconds. ## Writes resume two calm seconds after there is room Writes are accepted again once every volume has more free space than `resources.disk_free_resume` and memory is below 90 % of the budget, for two readings in a row: ```text INFO luradb::control::resources: Writes are accepted again: every volume is above its resume threshold and memory below 90 % of its budget. Still low: disk /var/lib/luradb/sstables free 833397870592 of 1081101176832, threshold 834397000000. ``` The state then falls to `warning`, not to `ok`. `/health` keeps reporting `degraded` until every volume is above the warn threshold again, which takes two more readings and ends with `INFO … Disk space and memory are back above their warn thresholds.` A gap between the three thresholds is what keeps a server that hovers around one value from switching between accepting and refusing writes. A delete does not free space at once: it writes a marker that compaction removes later. Faster ways out are deleting old backups (`DELETE /store-api/backups/{id}`), moving files off the volume or growing it. ## Memory shortage flushes the MemTables The memory that counts is the anonymous memory of the server process, which includes MemTables, caches and buffers. At 95 % of `resources.memory_budget` writes are refused with `507 … write blocked: memory budget exhausted`. While memory is short, the server flushes its MemTables to disk and returns free heap to the kernel, at once and then every ten seconds. When the budget is a percentage, it is a share of the host's memory, or of the memory limit of the server's cgroup when that is lower; the start log names which one it used (`MemTotal` or `cgroup memory.max`). To cap the memory of the service from the outside as well, set `MemoryHigh=` in a drop-in (`sudo systemctl edit luradb`). At start, the server adds up the memory it takes whatever the load, such as block caches and MemTables, see [Multicore](https://docs.luradb.org/how-it-works/multicore/#every-shard-adds-memory). When that exceeds half of the budget, it logs a warning that lists the parts. ## When the disk fails A disk that fails is a different matter from a disk that is full. The server stops with its own exit code in two cases: - **Exit code 3: written data may not be on disk.** The disk reported an error while making data durable (`fsync`), or writes to a data file (write-ahead log, value log, SSTable) failed for good: at once on a read-only file system, otherwise at the third failure in a row of the same log, or of three flushes in a row, a failed `fsync` of a new SSTable included. A full disk or an exceeded quota is not counted; the watch refuses writes before that happens. The log shows `data sync failed on ` or `data write failed on `. Until the stop, `/health` answers `status: "degraded"` with the failures in a row in `io`, and `GET /store-api/metrics` names the file. systemd starts the service again, and the start recovers every confirmed write from the write-ahead log. A write that failed with an error to the client may be there after the restart. Meanwhile, a failing flush or compaction logs its error once and then every 60th time, and a flush is retried once a second. - **Exit code 4: no room to recover.** At start, a volume has less free space than the recovery needs (`not enough free disk space to recover`). systemd does not restart the service (`RestartPreventExitStatus=4`); free space, then run `sudo systemctl start luradb`. A start below the block threshold with room for the recovery does not stop: the service starts with writes refused and reads going on. The unit allows three starts within five minutes, manual ones included; after that systemd refuses further starts until `sudo systemctl reset-failed luradb`. A container needs a restart policy that fits the codes: Docker cannot leave out an exit code, so `restart: on-failure:3` restarts after an exit 3, and after any failure at most three times, while `unless-stopped` would restart an exit 4 in a loop. ## Try it on a test host To see the three states, set thresholds a few gigabytes below the free space of the volume, then take that space away. This prints the three lines for the `[resources]` section of `luradb.toml`: ```sh FREE=$(df --output=avail -B1 /var/lib/luradb | tail -1) echo "disk_free_warn = \"$(( (FREE - 2000000000) / 1000000 )) MB\"" echo "disk_free_resume = \"$(( (FREE - 4000000000) / 1000000 )) MB\"" echo "disk_free_block = \"$(( (FREE - 6000000000) / 1000000 )) MB\"" ``` ```text disk_free_warn = "834397 MB" disk_free_resume = "832397 MB" disk_free_block = "830397 MB" ``` Restart the service, then take space from the volume in two steps and watch `/health` and a write after each: ```sh sudo fallocate -l 3GB /var/lib/luradb/fill1 # free space is now below warn: degraded, writes still accepted sudo fallocate -l 4GB /var/lib/luradb/fill2 # below block: writes answer 507 sudo rm /var/lib/luradb/fill2 # above resume: writes accepted, still degraded sudo rm /var/lib/luradb/fill1 # above warn: ok ``` Related settings: `resources.disk_free_warn`, `resources.disk_free_block`, `resources.disk_free_resume`, `resources.memory_budget`, `backup.dir`, `log.path` # Configuration reference Source: https://docs.luradb.org/operating/configuration/ Every key of luradb.toml with its default, what it does and why it exists. Every key of `/etc/luradb/luradb.toml`: its default, what it does and why it exists. The page is assembled from the shipped configuration file and the server code of each release, so no key is missing and none is stale. Type a key into the search to land on its entry. ## [server] swagger_enabled Serves the Swagger UI and /api-docs/openapi.json without a key, also with auth on; the API calls made from the UI still need one. - Default: `false` - Since: v0.1.0 ### Effect With `true`, the server serves two things next to the API: the Swagger UI at the path of `server.swagger_url` and the OpenAPI document of the running binary at `/api-docs/openapi.json`. The document path is fixed. With `false`, neither route is registered. Since v0.7.0 both routes and the assets of the UI are served without an API key, also while `auth.enabled` is on. The requests that the UI sends to the API need a key like any other request. In a test of v0.7.1 with authentication on, `/test-ui/` and `/api-docs/openapi.json` answered `200` without a key, while `/store-api/domains` and `/version` answered `401`. The document lists every endpoint, the admin-only ones included. `luradb --dump-openapi` prints the same document and exits. ### Background The UI lets you read the API description and send requests from the browser, which is useful while you build a client. Since it needs no key, it hands the full description of the API, including its administrative endpoints, to everyone who reaches the port. Data stays protected by the API keys, but on a host that clients on other machines can reach, switch the UI on only if the description may be public. ## [server] swagger_url URL path of the Swagger UI; a sub-path starting with /. Not /, /store-api, /health, /version or /api-docs/openapi.json (they would shadow the API), and no placeholders ({}, *, :). - Default: `"/test-ui"` - Since: v0.1.0 ### Effect The URL path under which the Swagger UI is served. The server reads it only while `server.swagger_enabled` is `true`. The UI answers on the path with a trailing slash; the same path without the slash redirects to it with `303`. The OpenAPI document stays at `/api-docs/openapi.json` whatever the path is. The value must be a sub-path that starts with `/`. Since v0.7.0 the start checks it while the UI is on and refuses a value that would break the API: in a test of v0.7.1, `docs` was refused with `invalid config: server.swagger_url (docs) must start with /`, `/` with `invalid config: server.swagger_url (/) would shadow every API route; use a sub-path such as /test-ui`, and `/store-api` with `invalid config: server.swagger_url (/store-api) would shadow the API route /store-api; use a sub-path such as /test-ui`. Paths under `/health` and `/version`, the path `/api-docs/openapi.json`, and paths with a placeholder (`{`, `}`, or a segment that starts with `*` or `:`) are refused the same way. While the UI is off, the value is not checked; `docs` then starts the server. ### Background The default path rarely needs a change. Change it when something else on the same host name already uses it, for example behind a reverse proxy that routes by path. ## [server] bind_address Address of the HTTP and HTTPS listeners; with auth off, only loopback is allowed. - Default: `"127.0.0.1"` - Since: v0.1.0 ### Effect The IP address that the TCP listeners bind to: the plain HTTP listener (`server.port`), the HTTPS listener (`server.tls_port`) and the MCP listener (`mcp.port`). The value is an IPv4 or IPv6 address, not a host name. `0.0.0.0` and `::` bind to all interfaces of that family; `::1` is the IPv6 loopback address. The Unix socket of `server.unix_socket_path` is not affected. A value that is not an IP address refuses the start with `invalid config: server.bind_address 'localhost' is not a valid IP address`. With `auth.enabled` off, an address that is not a loopback address refuses the start as well, with `invalid config: auth.enabled = false and server.bind_address = '0.0.0.0' is not loopback`. With authentication on, any address is accepted. ### Background The server is reachable only from its own host until you change this key, and it cannot run without authentication on an address that other machines can reach. To accept remote clients, set the address of the network interface they connect to (or a wildcard address), turn authentication on, and consider TLS: either the server's own (`server.tls_enabled`) or a reverse proxy in front of it. A reverse proxy on the same host can keep the loopback address. ## [server] port Port of the plain HTTP listener. - Default: `3000` - Since: v0.1.0 ### Effect The port of the plain HTTP listener, which binds on `server.bind_address`. The value is a whole number from 0 to 65535; anything else is rejected when the file is read. The listener exists only while `server.http_enabled` is `true`. The port must differ from `server.tls_port`, even while one of the two listeners is off, and the start is refused otherwise. While the MCP listener runs, `mcp.port` must differ from this port as well. A port that another process holds makes the start fail with the bind error of the operating system, and so does a port below 1024 unless the host lets unprivileged users bind it. The packaged service runs as the unprivileged user `luradb` and its unit grants no capability for low ports. ### Background The REST API, the health check and, when switched on, the Swagger UI all answer on this port, so it is the one setting that decides where clients connect. A host often runs other services; change the port when 3000 is taken, or when a firewall rule or a proxy configuration expects a fixed port. Clients on the same host can use the Unix socket of `server.unix_socket_path` instead and need no port. ## [server] http_enabled Starts the plain HTTP listener; at least one of HTTP and HTTPS must be on. - Default: `true` - Since: v0.2.0 ### Effect With `false`, the server does not open the plain HTTP listener and logs `HTTP listener disabled by config (server.http_enabled = false).` at start. The Unix socket and the MCP listener are not affected. At least one of this key and `server.tls_enabled` must be `true`. If both are `false`, the start is refused with `invalid config: server.http_enabled and server.tls_enabled are both false — no listener would start`. The port numbers are still compared while one listener is off, see `server.port`. ### Background Turn the plain listener off when clients must reach the server over HTTPS only, so that no cleartext port exists. Health checks and other tools then have to use the HTTPS port as well; `/health` answers there like on the plain port. ## [server] hello_enabled Registers the root route / that answers with the hello message. - Default: `true` - Packaged value: `false` - Since: v0.1.0 ### Effect With `true`, the server answers `GET /` with status `200` and a JSON body of the form `{"message": "…"}`, the text coming from `server.hello_message`. With `false`, the route does not exist; with authentication off, `GET /` then answers `404`. The route sits outside the authentication layer. It answers without an API key even while `auth.enabled` is on. ### Background The route is a plain "is something listening here" answer. `/health` is the endpoint for monitoring: it reports the version, the state of every data shard and the resource state. Leave the root route off unless you want a response that every client gets without a key. ## [server] hello_message Response text of the root route. - Default: `"Hello from LuraDB"` - Since: v0.1.0 ### Effect The text returned in the `message` field of the root route. Any string is accepted and no length is checked; the server escapes it for JSON, so quotes in the text are safe. The value is read only while `server.hello_enabled` is `true`. ### Background The text lets you tell instances apart, for example by environment name. The route answers without an API key, so the text is visible to every client that can reach the port; do not put anything in it that should not be public. ## [server] unix_socket_path Unix domain socket for local clients. /run/luradb is created by systemd (RuntimeDirectory). Access: group luradb (fixed socket mode 0o660). - Default: not set (no socket) - Packaged value: `"/run/luradb/luradb.sock"` - Since: v0.1.0 ### Effect When the key is set, the server also listens on a Unix domain socket at this path and serves the same API through it as on the TCP listeners. Without the key there is no socket. The socket comes in addition to the TCP listeners: `server.http_enabled` and `server.tls_enabled` must still not both be `false`. The path must be absolute, and its directory must exist; the server does not create it. The start is refused with `unix_socket_path must be absolute: …` or `parent directory of unix_socket_path does not exist: …` otherwise. A file at the path that is not a socket also refuses the start (`unix_socket_path exists and is not a socket: …`) and is left untouched. A socket file left behind by an earlier run is removed and created again. The server sets the mode of the socket to `0660`; the mode is not configurable. The owner and group are the account the server runs as. The socket file is removed again on an orderly shutdown. Requests on the socket are authenticated like those on the TCP listeners: with an API key as Bearer token while `auth.enabled` is on. The exception are processes whose user ID is listed in `auth.trusted_uids`: the kernel reports the user ID of the connecting process to the server, and such a connection gets admin access without a key. ### Background A local client that uses the socket needs no TCP port, and who may connect is decided by file permissions. With trusted user IDs, local tools such as backup or monitoring scripts can work without an API key stored in a file. The packaged service runs as user and group `luradb` and has systemd create `/run/luradb` with mode `0750` (`RuntimeDirectory`), which is why the packaged configuration places the socket there: members of the group `luradb` can reach the directory and, with mode `0660`, the socket. A client in that group but with a user ID that is not trusted still has to send an API key. ## [server] tls_enabled Starts the native HTTPS listener, opt-in. Quickstart to enable: packaging/INSTALL.md "Enabling HTTPS". - Default: `false` - Since: v0.2.0 ### Effect With `true`, the server terminates TLS itself: it opens an HTTPS listener on `server.tls_port` at `server.bind_address`, using the certificate and key from `server.tls_cert_path` and `server.tls_key_path`. The listener offers HTTP/2 and HTTP/1.1 and does not ask clients for a certificate. A TLS handshake that does not finish within 10 seconds is dropped. The plain HTTP listener keeps running next to it unless `server.http_enabled` is `false`; the server does not redirect from one to the other. A plain HTTP request to the HTTPS port, or the other way round, fails at the connection. The MCP listener shares the setting. With `true` and `mcp.enabled`, the listener on `mcp.port` serves HTTPS only, with the same certificate. The certificate and the key are loaded once while the server starts. An unreadable or invalid file refuses the start with a message that names the key, such as `cannot open server.tls_key_path '…': No such file or directory (os error 2)` or `server.tls_cert_path '…' contains no certificate`. With `false`, the two paths are not read at all, and a missing file does no harm. ### Background TLS needs a certificate and a key that the operator provides. Native TLS lets a single host serve clients over HTTPS without a reverse proxy. Because the files are read only at start, a renewed certificate takes effect after a restart of the service, and a renewal tool needs a hook that restarts it. If you terminate TLS in a reverse proxy instead, leave this key off and see `proxy.trusted_proxies` for how the server treats the client address the proxy forwards. ## [server] tls_port Port of the HTTPS listener; must differ from the HTTP port. - Default: `3443` - Since: v0.2.0 ### Effect The port of the HTTPS listener, which binds on `server.bind_address`. The value is a whole number from 0 to 65535; anything else is rejected when the file is read. The listener exists only while `server.tls_enabled` is `true`. The port must differ from `server.port`, whether or not both listeners run. The start is refused otherwise with `invalid config: server.tls_port (N) must differ from server.port (N)`. While `mcp.enabled` and TLS are both on, `mcp.port` must differ from this port too. A port held by another process makes the start fail with the bind error of the operating system. ### Background Change the port when it is taken, or when a firewall rule or a proxy expects a fixed port. Ports below 1024, such as 443, are not available to the unprivileged account of the packaged service unless the host allows unprivileged users to bind them. ## [server] tls_cert_path PEM certificate of the HTTPS listener, optionally with its chain. - Default: `"/etc/luradb/tls/server.crt"` - Since: v0.2.0 ### Effect The PEM file with the server certificate. The file may hold the certificate chain: the server reads every certificate in it and presents them in the order they appear, so the server certificate must come first. The server reads the file once, while it starts, and only while `server.tls_enabled` is `true`. A file that cannot be opened, cannot be parsed or holds no certificate refuses the start, with `cannot open server.tls_cert_path '…'`, `cannot parse server.tls_cert_path '…'` or `server.tls_cert_path '…' contains no certificate`. A certificate that does not match the key of `server.tls_key_path` refuses it with `invalid TLS certificate/key pair`. ### Background The service account must be able to read the file. The package creates `/etc/luradb/tls`, owned by root with the group `luradb` and mode `0750`, for the certificate and the key; the server never writes there. A certificate that is renewed in place is not picked up before the next start of the service. ## [server] tls_key_path PEM private key (PKCS#8, RSA or EC) of the HTTPS listener. - Default: `"/etc/luradb/tls/server.key"` - Since: v0.2.0 ### Effect The PEM file with the private key that belongs to the certificate of `server.tls_cert_path`. If the file holds several private keys, the server uses the first one. It reads the file once, while it starts, and only while `server.tls_enabled` is `true`. A file that cannot be opened or parsed, or holds no private key, refuses the start, with `cannot open server.tls_key_path '…'`, `cannot parse server.tls_key_path '…'` or `server.tls_key_path '…' contains no private key`. A key that does not belong to the certificate refuses it with `invalid TLS certificate/key pair`. ### Background The key is a secret. Give the file only to root and the service group, for example mode `0640` with owner root and group `luradb`, and keep it in the directory `/etc/luradb/tls` that the package creates for it with group access for `luradb` and no access for others. Like the certificate, the key is read only at start. ## [auth] enabled Requires a key on every request; off is only allowed on a loopback address. - Default: `false` - Packaged value: `true` - Since: v0.1.0 ### Effect With `true`, every request except `GET /health` needs an API key, sent as `Authorization: Bearer `. A missing or unknown key is answered with `401 Unauthorized`. An admin account may use every endpoint. A regular account may use only the domains it holds a permission for (`Read`, `Write` or `Ddl`, each level covering the lower ones) and is answered with `403 Forbidden` for anything else, including every endpoint that has no domain in its path, such as the account, metrics and configuration endpoints. The exceptions are `GET /version` and `GET /store-api/auth/whoami`, which accept any valid key, and the domain listings, which show a regular account the domains it may see. The root route of `server.hello_enabled` is open as well, and so are the Swagger UI and `/api-docs/openapi.json` while `server.swagger_enabled` is on. With `false`, the server checks nothing and every client has full access. The server only starts in this mode when `server.bind_address` is a loopback address; otherwise it refuses the start with `invalid config: auth.enabled = false and server.bind_address = '…' is not loopback`. Every start in this mode logs a warning that the server is unauthenticated, and `GET /store-api/auth/whoami` answers with the role `Disabled`. The accounts of `auth.admins.name` are still created at start. Other settings depend on this one. `auth.trusted_uids` has an effect only with authentication on. Registering a shared-memory client (`shm.enabled`) is open to everyone with authentication off and limited to the trusted user IDs with it on. `mcp.oauth_enabled` requires it, and the start is refused with `invalid config: mcp.oauth_enabled = true requires auth.enabled = true` otherwise. With `mcp.enabled` on and authentication off, the server warns that any client that reaches the MCP port has full access. With authentication on and no admin configured, it warns `Auth is enabled but no admins are configured in luradb.toml`, and no admin key exists. ### Background A database that listens on a network address without authentication gives every client that reaches it full access to all data. The loopback rule makes that state impossible to reach by mistake: to open the server to other machines, you also have to turn authentication on. Switch authentication off only for local development or for a server whose every client is on the same host and trusted, such as a private test instance on a developer machine. ## [auth] trusted_uids Unix user IDs that authenticate by their peer credentials instead of a key. Warning: these UIDs get full access without an API key via the Unix socket and SHM. - Default: `[]` - Since: v0.1.0 ### Effect A list of Unix user IDs, whole numbers from 0 up; a negative or non-numeric entry is rejected when the file is read. A process that connects over the Unix socket of `server.unix_socket_path` and whose user ID is in the list is treated as an admin without an API key. The kernel tells the server the user ID of the process at the moment it accepts the connection, so a client cannot claim another one. `GET /store-api/auth/whoami` answers such a connection with the role `TrustedPeer` and no name. Only the Unix socket evaluates the list. A request on the HTTP or HTTPS listener still needs a key, whatever user ID the client runs as. The list has an effect only while `auth.enabled` is on. The same list also decides which local processes may register as a shared-memory client when `shm.enabled` is on: with authentication on, only listed user IDs may register, because that protocol carries no API key. An empty list trusts nobody. ### Background The list lets local tools such as backup or monitoring scripts work with the database without an admin key stored in a file or an environment variable; the operating system account takes the place of the key. Listing a user ID gives every process of that account the same power as the admin key, so list only accounts whose processes you would trust with it, and prefer dedicated service accounts. Listing `0` gives every root process admin access. A client that may reach the socket but is not listed can still use it with an API key. The socket file allows access to the service group, see `server.unix_socket_path`. ## [auth.admins] name Name of the admin account. - Default: `"admin"` - Since: v0.1.0 ### Effect The name of an admin account. Each `[[auth.admins]]` entry describes one account, with a name and a key (`auth.admins.api_key`); both are required, and an entry without one refuses the start with `missing field` followed by the field name. At every start the server compares the entries with the admin accounts in its system store (`storage.system_dir`). It creates or updates one account with the role Admin per entry, deletes every admin account that has no entry, together with its permissions, and leaves regular accounts alone. The start log shows `Auth: admin '' reconciled` per entry and `Auth: removed stale admin ''` per deleted account. Renaming an entry therefore replaces the account: the old name is removed, the new one is created. The accounts are created or removed even while `auth.enabled` is off. The name is what `GET /store-api/auth/whoami` and the account list return for the key. The server checks it for nothing at start, so spaces and colons are accepted, unlike the names of accounts that are created through the API, which are 1 to 50 characters of letters, digits, `_` and `-`. If two entries have the same name, the later one wins, and the key of the earlier one stops working. If the name belongs to a regular account, the account becomes an admin with the new key. ### Background Give each person or system that administers the server its own entry. A key can then be rotated or withdrawn by changing or deleting its entry and restarting, without touching the other admins. Regular accounts for applications are created through the API, with domain permissions, and survive restarts; the configuration file holds only the accounts that may do everything. ## [auth.admins] api_key Secret of the admin account, sent as a Bearer token. Placeholder — postinst replaces it with a random key on first install. - Default: `"@GENERATED_ON_INSTALL@"` - Since: v0.1.0 ### Effect The secret of the admin account `auth.admins.name`. A client sends it as `Authorization: Bearer `. The server accepts any non-empty text and checks no format; an empty text creates the account, but no request can authenticate with it. The key is required for every `[[auth.admins]]` entry. At start the server stores only the SHA-256 hash of the key in its system store and discards the text. The configuration file keeps the text, so protect the file: the package installs it with mode `0640`, owner root, group `luradb`. The endpoint that returns the effective configuration (`GET /store-api/config`) leaves the key out. A change of the text takes effect at the next start. From then on the old key is refused with `401`, and so are the OAuth access tokens that MCP clients obtained with the old key, because a token is valid only while the account still has the key it was issued for. The server does not know the placeholder `@GENERATED_ON_INSTALL@` of the example file. Started from that file unchanged, it would accept this text as the admin key. The package replaces the placeholder on the first installation with `lura_` and 32 random hexadecimal characters and leaves an existing key alone on updates and reinstalls. The Docker image does the same on its first start, using the environment variable `LURADB_ADMIN_KEY` if it is set and printing a generated key to the container log. ### Background Admin keys are the credentials that are not created through the API, so a new installation can be reached before any account exists. Choose a long random text; the keys the server generates for regular accounts are `lura_` and 64 random hexadecimal characters. To rotate an admin key, replace the text and restart the service; to retire a key, delete the entry. Clients that send the old key are refused from the restart on. ## [storage] wal_path Write-ahead log: a directory of segment files of about 64 MiB each, which the server creates, writes and deletes; never change anything in it by hand. The path may be a symlink, the segments then lie at its target. A log file of an earlier LuraDB version at the path becomes such a directory on the first start; an earlier version does not start on it. - Default: `luradb.wal` - Packaged value: `"/var/lib/luradb/luradb.wal"` - Since: v0.1.0 ### Effect The directory of the write-ahead log of the key-value engine. It holds segment files named `00000001.wal`, `00000002.wal` and so on; a segment is closed at 64 MiB and the next one is prepared ahead of time. All data shards of the key-value engine share this one log, so unlike the other data files it is not placed in a `shard_` directory. The other engines keep their logs elsewhere: `json.wal_path`, `rel.wal_path` and a `wal` directory inside `storage.system_dir`. The server creates the directory and its parent at start and manages the files itself. The storage thread of the server appends every write to the log and waits for the data to be on disk before the write is confirmed. How much of the log the server keeps is set by `storage.wal_max_size`. No two data paths may resolve to the same location (symbolic links resolved); the start is refused with `invalid config: … resolve to the same location '…'` otherwise. A relative path resolves against the working directory of the server process. ### Background A confirmed write is safe because it is in this log; after a crash the server replays what the SSTables do not yet hold. Every write waits for the log to reach the disk, so the latency of the volume that holds the log sets the lower bound for the latency of writes. The server watches the free space of this volume as well: when it falls below the block threshold, writes are refused with `507` (`resources.disk_free_block`). A separate volume for the log is therefore a way to keep log space and data space apart; the service account needs write access to the directory. ## [storage] vlog_path Value log for large values. - Default: `luradb.vlog` - Packaged value: `"/var/lib/luradb/luradb.vlog"` - Since: v0.1.0 ### Effect The value log of the key-value engine. Values of at least `lsm.vlog_inline_threshold` bytes are appended to it, and the SSTables keep only a pointer to them. Each data shard has its own file: the server inserts a directory `shard_` before the file name, so `/var/lib/luradb/luradb.vlog` becomes `/var/lib/luradb/shard_0/luradb.vlog` for shard 0. The server creates it at start. A relative path resolves against the working directory of the server process. When the value log is cleaned (see `janitor.dead_bytes_threshold`), the live values move into a new generation, whose file name is the configured name with `.2` appended, then `.3`, and so on. Because of these names no other data path may equal the name followed by a dot and digits; the start is refused if one does. The size of the value logs of the key-value engine, all shards and generations together, is the `vlog_size_bytes` field of `GET /health`. The JSON engine and the relational engine have their own value logs, `json.vlog_path` and `rel.vlog_path`, and the system store keeps one in `storage.system_dir`. ### Background Keeping large values out of the SSTables means that a compaction rewrites only keys and pointers, not the values themselves. The price is that overwritten and deleted values stay in the log as dead space until the cleanup rewrites the log, so this volume needs room for the data plus the dead space that builds up between cleanups. The server watches its free space with the other data volumes, and a cleanup waits while the volume has less room than the live values take. ## [storage] sstable_dir SSTable directory. - Default: `luradb_sstables` - Packaged value: `"/var/lib/luradb/sstables"` - Since: v0.1.0 ### Effect The directory of the SSTables of the key-value engine. Each data shard keeps its files in a subdirectory `shard_` of it, with the files `sstable_.sst` and a `MANIFEST` that lists them and their levels. The server creates the directory at start. A relative path resolves against the working directory of the server process. A flush of a MemTable (`lsm.memtable_size_threshold`) adds a file at level 0, and compactions (`compaction.l0_threshold`) merge files into the levels below. The files hold the keys and the values below `lsm.vlog_inline_threshold` bytes; longer values are in the value log, and the files hold a pointer to them. The server does not move data when the path changes. A start with another path opens an empty set of SSTables there, and the data in the old directory is not read. If `storage.system_dir` is not set in the file, the server derives it from this path: it is `luradb_sys` in the parent directory of the SSTable directory, so changing this key then moves the system store, with the accounts, as well. ### Background A compaction writes its output before it deletes its inputs, so the volume needs free room of at least the size of the inputs of the next compaction; the server holds the compaction back and logs `Compaction of level … waits for disk space` while it has less. Plan the volume with headroom beyond the data size, and see `resources.disk_free_warn` for the thresholds at which the server warns and refuses writes. ## [storage] system_dir Directory of the system store, which keeps the users, API key hashes and permissions apart from domain data. Its write-ahead log wal is a directory of segment files the server creates, writes and deletes; never change anything in it by hand. wal may be a symlink, the segments then lie at its target. - Default: `luradb_sys` beside the SSTable directory - Packaged value: `"/var/lib/luradb/luradb_sys"` - Since: v0.5.1 ### Effect The directory of the system store, an LSM instance of its own that holds what belongs to no domain: the accounts with their key hashes and permissions, the OAuth clients and tokens of the MCP listener, and the server's markers such as the shard count of the data directory. It is not divided into shards. The server creates the directory at start and puts four things in it: a `wal` directory with the write-ahead log, a `vlog` file, an `sstables` directory and a `lock` file. The lock file keeps a second server process off the data. A process that finds it taken stops with ` is in use by another LuraDB process`. If the key is not set in the file, the server uses `luradb_sys` in the parent directory of `storage.sstable_dir`. The path takes part in the checks for data paths: the directory and the three items in it must not resolve to the same location as another data path. ### Background The system store is not subject to the refusal of writes. When writes are refused for lack of space or memory, requests under `/store-api/auth/` still go through, so that sign-in and the management of keys keep working; their few records go into the system store, from the space that is left below the block threshold (`resources.disk_free_block`). Because the directory holds the accounts and the shard count (`multicore.shards`), move or restore it together with the rest of the data directory. A server started with a new, empty directory creates the admin accounts of `auth.admins.name` again, but does not have the regular accounts, their permissions or the recorded shard count of the old directory. ## [storage] wal_queue_capacity Writes waiting for the storage thread, which writes the write-ahead logs of all engines; a full queue holds further writes back. 1 to 65536. - Default: `1024` - Since: v0.5.1 ### Effect The length of the queue in front of the storage thread, which writes the logs of all engines. A write takes a place in the queue before it is stamped and appended; when no place is free, the write waits until one is. The client sees a slower answer, not an error. The value is a whole number from 1 to 65536. Anything else refuses the start with `invalid config: storage.wal_queue_capacity (…) must be 1 to 65536`; a negative number is rejected when the file is read. The value also adds to the size of the queue for wake-ups from other threads that each data shard and the control-plane thread allocate (together with `multicore.shard_queue_capacity`), which is why the upper limit exists. ### Background The storage thread writes the records that have gathered as one group and waits once per group and log for the data to reach the disk. The queue bounds how many writes can wait for the thread at the same time. Each queued write holds its record in memory until the thread has written it, so the length of the queue times the size of the writes bounds the memory it can hold. The default suits most installations; raise it only if many concurrent writers are slowed by waiting for a place, and measure the effect. ## [storage] wal_max_size Cap on the write-ahead log of each engine, the system store's included. Once its segments reach it, the shards whose records in the oldest segment are not in SSTables yet write them there, and the segment is deleted; a larger cap means fewer such writes and a longer recovery after a crash. At least 128 MiB. A number with a unit: B, kB, MB, GB, TB (powers of 1000) or KiB, MiB, GiB, TiB (powers of 1024), as in "512 MiB". - Default: `"256 MiB"` - Since: v0.5.1 ### Effect Each engine (key-value, JSON, relational) keeps a write-ahead log, and so does the system store. A log is a directory of segment files of 64 MiB each. This key caps the segments of one log. The value is a number with a unit, as in `"256 MiB"`. The units are B, kB, MB, GB and TB (powers of 1000) and KiB, MiB, GiB and TiB (powers of 1024), in any case; the number may have decimals. The smallest allowed value is 128 MiB, which is two segments, so the segment to drop is never the one being written. A number without a unit, an unknown unit or a value below 128 MiB refuses the start with an `invalid config: storage.wal_max_size …` message. Once a second the server looks at each log. When its closed segments plus one full segment reach the cap, the shards that still hold records of the oldest segment only in memory write them to SSTables, and the segment is deleted. A segment that has held records for five minutes is closed and dropped the same way, whatever the cap, so a quiet database does not keep records in its log for long. A log stays within about one segment of the cap. ### Background A write is confirmed once it is in the log, and the log is what recovery replays after a crash. A segment can only be deleted when every shard has its records in SSTables. A shard that rarely writes would keep old segments alive for a long time, so the cap makes such shards write their records out and lets the server delete the segment. A larger cap means fewer of these early writes and a longer recovery after a crash, because more records sit in the log. A smaller cap, down to 128 MiB, keeps the log and the recovery short at the price of more early writes. Each log can use the cap plus about one segment of disk space, so the volumes of `storage.wal_path`, `json.wal_path`, `rel.wal_path` and `storage.system_dir` need room for that. A shard also writes its MemTable out on its own when it reaches `lsm.memtable_size_threshold`, which shortens the log without the cap. The default of 256 MiB (four segments) suits most installations. Raise it on a host with sustained heavy writes and plenty of disk, lower it on a small volume. ## [resources] disk_free_warn Free space below which the server warns. - Default: `"15% max 10 GB"` - Since: v0.5.1 ### Effect Once a second the server reads the free space of every volume that one of its data paths lies on: the SSTable and system directories, the directories of the page file, the write-ahead log and the value log, those of the JSON and relational engines while they are on, the backup directory while backups are on, and the log directory when `log.path` is set. Volumes that several paths share are watched once. "Free" is the space an unprivileged process can use, without the share reserved for root. When the free space of a volume falls below this threshold, the state of the server changes to `warning`. The server logs `Resources running short: disk free … of …, threshold …. Nothing is refused yet; writes are refused below the block threshold.` and repeats the line every 60 seconds while the state lasts. `GET /health` answers `status: "degraded"` with `resources.disk_state: "warning"`, still with HTTP status 200. The metrics endpoint shows the free space per volume. Nothing is refused. The state returns to normal, with a log line, once every volume has been above the threshold for two readings in a row. The value is a size, a percentage of the volume, or both. A size is a number with a unit: B, kB, MB, GB, TB (powers of 1000) or KiB, MiB, GiB, TiB (powers of 1024), in any case, as in `"2 GB"`. A percentage is above 0 and up to 100, decimals allowed, as in `"5%"` or `"2.5%"`. A percentage followed by `max` and a size, as in `"15% max 10 GB"`, takes the smaller of the two. The server resolves the value once at start, separately for each volume, against the total size of that volume. A value in another form refuses the start with `invalid config: resources.disk_free_warn (…) needs a size such as "2 GB", a percentage above 0 up to 100 such as "5%", or a percentage with a cap such as "15% max 10 GB"`. For every volume, the resolved thresholds must satisfy `disk_free_block <= disk_free_resume <= disk_free_warn`, and the block threshold must be at least 64 MiB. Otherwise the start is refused with a message that lists the three resolved values in bytes. ### Background The warning is the early notice: it fires while nothing is wrong yet, so that monitoring, which can read the `degraded` status of `/health`, and the operator have time to add space or remove data before the server has to refuse writes (`resources.disk_free_block`). Choose a threshold that gives that time at the rate your data grows. A percentage with a cap suits both small and large volumes: with `"20% max 50 GB"`, a 100 GB volume warns below 20 GB and a 1 TB volume below 50 GB, instead of at 200 GB. ## [resources] disk_free_block Free space below which the server refuses writes. - Default: `"5% max 2 GB"` - Since: v0.5.1 ### Effect When the free space of any watched volume falls below this threshold, the server refuses writes. The volumes and the form of the value are described at `resources.disk_free_warn`. A refused write is answered with `507 Insufficient Storage`, the header `Retry-After: 5` and the body `507 Insufficient Storage: write blocked: disk space below threshold, retry in 5 s`. The write is not applied. The server logs `Writes refused: …` as an error with the volume, its free space and the threshold, and repeats the line every 60 seconds while the state lasts. Everything that writes is refused: puts, deletes, bulk requests, new domains, tables and indexes, and new backups. The exception is a new backup whose directory (`backup.dir`) lies on a volume that is above its warn threshold, as long as memory is not the reason for the block. Three groups go on: reads, `GET /health` and the downloads of existing backups; sign-in and the management of accounts and keys, that is every request under `/store-api/auth/`; and the deletion of a backup, which frees space. Deleting keys does not free space, because a delete is a write and is refused too. The TTL sweeper (`ttl_sweeper.enabled`) writes no tombstones while writes are refused. A compaction or a value-log cleanup waits whenever its volume has less room than its inputs or its live values take, blocked or not. The state ends as described at `resources.disk_free_resume`. The threshold must be at least 64 MiB on every volume and may not exceed the resume threshold; the start is refused otherwise, see `resources.disk_free_warn`. ### Background A server that fills its disk cannot finish the work that is already under way: a flush needs room for its SSTable, and a failed write of a data file can force the server to stop. The block threshold leaves free space for that work and for the sign-in records, which still go through below the threshold, and it gives clients a defined answer, `507` with `Retry-After`, instead of errors from a full disk. Set the threshold above the space the server may still need after it stops accepting writes: the SSTables for the MemTables in memory (`lsm.memtable_size_threshold` per engine and shard) and the output of a compaction that is running, which can be as large as its inputs. The readings come once a second, so a fast writer can use up a good part of the margin before the state changes. ## [resources] disk_free_resume Free space each volume needs before refused writes resume. - Default: `"10% max 4 GB"` - Since: v0.5.1 ### Effect The free space that every watched volume needs before refused writes are accepted again. The form of the value is described at `resources.disk_free_warn`. While any volume is below this threshold after a block (`resources.disk_free_block`), the state stays blocked: the server keeps answering writes with `507` and logs `Writes refused: …`, naming the volumes that hold the block. When every volume has been above the threshold for two consecutive readings, which come once a second, and memory is below its resume level, the server logs `Writes are accepted again` and moves to the warning state; if a volume is still below the warn threshold, the line adds `Still low: …`. Two more readings above the warn threshold bring it back to normal (`resources.disk_free_warn`). The threshold must lie between the block and the warn threshold on every volume: `disk_free_block <= disk_free_resume <= disk_free_warn`. Otherwise the start is refused, see `resources.disk_free_warn`. ### Background The gap between the block and the resume threshold keeps the server from switching between accepting and refusing writes every second. Without a gap, the first writes after a block would fill the volume past the block threshold again. Choose a resume threshold that leaves room for a useful stretch of writing. You reach it by freeing space, for example by deleting old backups, which is allowed while writes are refused. ## [resources] memory_budget Anonymous memory the server may use: a percentage of the host's memory, or of its cgroup's memory.max when that is lower, or a size; at least 256 MiB. Writes warn from 80 %, are refused from 95 % and resume below 90 % of it. - Default: `"75%"` - Since: v0.5.1 ### Effect The amount of anonymous memory, in bytes, that the server may use: the `RssAnon` figure of the process, which is its heap and anonymous mappings and leaves out the page cache and the memory-mapped SSTables. The value is a size, a percentage, or a percentage with a cap, in the form described at `resources.disk_free_warn`. A percentage refers to the memory of the host (`MemTotal`) or, if it is lower, to the `memory.max` of the cgroup (version 2) that the process runs in, so a container limit is honoured. The start log names the result and its source: `Memory budget … bytes of … (MemTotal)` or `(cgroup memory.max)`. The budget must resolve to at least 256 MiB, or the start is refused: with `invalid config: resources.memory_budget (…) must be at least 256 MiB` for a size, and with `… resolves to … bytes of …; it must be at least 256 MiB` for a percentage. The server compares the reading, taken once a second, with the budget. From 80 % it warns, logs `Resources running short: memory …` and reports `degraded` in `GET /health` with `resources.memory_state: "warning"`. From 95 % it refuses writes exactly as for a full disk, with `507`, `Retry-After: 5` and the reason `memory budget exhausted` in the body, see `resources.disk_free_block`. It accepts them again once the reading is below 90 %. While writes are refused for memory, the server writes the MemTables out on the first second and every ten seconds after it, and returns free heap to the operating system once such a flush is done, to bring the reading down; the log shows `Memory block: flushing MemTables and returning free heap to the kernel.` At start, the server adds up the memory it holds regardless of load: two MemTables per engine and shard (`lsm.memtable_size_threshold` for the key-value engine, the built-in size for the others), the block caches, and, when they are on, the shared-memory segments (`shm.data_buffer_size`) and the registered I/O buffers (`io_engine.enabled`). If the sum is more than half of the budget, it logs `The fixed memory of the server, … bytes (…), takes more than half the memory budget of … bytes.` ### Background A database that grows until the operating system or the container runtime kills it loses its in-memory state and has to recover from the write-ahead log. The budget makes the server act first: it warns, then stops taking writes that would grow memory, and flushes. Reads continue. The default leaves a quarter of the memory for the page cache and for other processes on the host. Lower the budget when other services share the host. Raise it only if you know that nothing else needs the memory. If the fixed-memory warning appears, the budget is too small for the configured MemTables, caches and buffers, or those are too large for the host. ## [io_engine] enabled Registers I/O buffers with the storage engine thread's io_uring ring; not used on the data path yet. The storage thread — a dedicated io_uring thread that writes the write-ahead logs of all engines and batches concurrent writes into one fsync per log — runs either way; the server does not start without it. - Default: `false` - Since: v0.1.0 ### Effect With `true` and exactly one data shard (`multicore.shards`), the shard allocates 128 buffers of 64 KiB, registers them with its io_uring ring and keeps a handle to the value log and to every SSTable that exists at start. A successful start logs `IoEngine ready: 128 registered buffers x 65536 bytes.`, and the per-shard memory line ends with `registered I/O buffers on`. No read or write of the engines uses the buffers; nothing in the server calls the code that would. If the kernel rejects the registration, the server logs `IoEngine disabled: … Continuing without registered buffers.` and runs without them. With more than one data shard the key has no effect, and the start logs `io_engine.enabled has no effect with more than one data shard.` ### Background The registered buffers are scaffolding: the code to use them exists, but the engines do not call it. Switching the key on costs 8 MiB of pinned memory, which counts toward the fixed memory that `resources.memory_budget` is compared with, and one more open file per SSTable, and it gives nothing back in this release. Leave it off. The packaged service sets `LimitMEMLOCK=infinity` so that the registration can succeed. ## [multicore] cpu_offload_threads Parallel CPU-heavy tasks moved off the request thread: 0 is automatic (cores minus 2, at least 1), otherwise at most the number of cores. - Default: `0` - Since: v0.5.1 ### Effect The number of CPU-heavy tasks that may run at the same time on helper threads instead of on the threads that serve requests. A task that finds all places taken waits for one; it does not fail. In this release the server offloads the parsing of the body of a JSON bulk load and the parsing of an uploaded file that creates a relational table. The same number caps the pool of blocking threads of the frontend runtime. `0` is automatic: the number of cores minus two, at least 1. The start log shows the result as `CPU offload permits: N`. An explicit value must not exceed the number of cores the process can use; the start is refused with `invalid config: multicore.cpu_offload_threads (…) must be 0 (auto) or 1 to N (available cores)` otherwise. ### Background Parsing a large body takes a core for as long as the body is large. Done on the thread that runs the request, it would hold up that thread's other work, so the server moves it to a bounded pool and keeps cores free for the rest. Lower the value to keep more cores free for the data shards and readers on a host that parses large uploads; raising it above the automatic value only helps when many large uploads arrive at once and the cores are otherwise idle. ## [multicore] frontend_workers Threads that accept connections and parse HTTP/TLS in front of the data shards: 0 is automatic (cores / 6, 2 to 4 on hosts with at least 4 cores, otherwise 1), otherwise at most the number of cores. - Default: `0` - Since: v0.5.1 ### Effect The number of threads of the frontend runtime. They accept the connections of the HTTP, HTTPS and Unix socket listeners, run the TLS handshakes and parse HTTP, resolve the client address behind a trusted proxy (`proxy.trusted_proxies`), check the API key, answer point reads of one key, document or row directly, and hand every other request on to a data shard, the control plane or the reader pool. The MCP listener has a runtime of its own and takes no frontend worker. `0` is automatic: a sixth of the cores, but at least 2 and at most 4, on hosts with at least 4 cores, and 1 on smaller hosts. The start log shows the result in the line `N cores: M frontend workers, …`. An explicit value must not exceed the number of cores the process can use; the start is refused with `invalid config: multicore.frontend_workers (…) must be 0 (auto) or 1 to N (available cores)` otherwise. The result also takes part in the automatic count of `multicore.reader_threads`, which gets the cores that are left after the frontend workers and the data shards. ### Background The workers do the work that every request needs before and after the engines: connection handling, TLS and authentication. A worker serves many connections. Each connection runs one request at a time, so a client that wants parallelism opens several connections. Raise the value when many clients connect at once, or when TLS handshakes of short-lived connections use most of a core; keep it low on small hosts so that the cores stay available for the data shards. ## [multicore] shards Data shards, each a thread with its own storage engines that writes the domains assigned to it. The data directory layout depends on it: 0 keeps the count an existing data directory was written with, and gives a new one cores / 4, 1 to 8. A set count that differs from the one the data was written with refuses the start; `luradb --migrate-shards N` changes the count of a data directory while the server is stopped. - Default: `0` - Since: v0.5.1 ### Effect The number of data shards. A shard is one thread with its own storage engines, and it writes the domains assigned to it. The value is a whole number from 0 to 65535. `0` is automatic. A data directory that already exists keeps the count it was written with, also after an upgrade or a move to a host with another core count; a directory laid out without shard directories counts as one shard. A new data directory gets a quarter of the cores, at least 1 and at most 8. When the host would pick another count than the one stored, the start logs a warning that names the migration command. A value above 0 is used as given, but only on a data directory written with that count. A different count refuses the start with `shard count changed (stored N, configured M)` and names `luradb --migrate-shards M`. The first start records the count. Only the migration tool changes it, on a stopped server. Every domain lives on exactly one shard, chosen from the name of the domain and the same for all three engines. The writes of a domain run on the thread of its shard, so domains that fall on the same shard take turns. Reads do not wait for the thread of the shard: point reads run on the connection thread and longer reads on the reader pool, see `multicore.reader_threads`. Each shard adds a thread. The block cache of each engine is split evenly across the shards, but the MemTable threshold applies per engine and shard, so MemTable memory grows with the count. The automatic `multicore.reader_threads` takes the cores that are left after the shards and the `multicore.frontend_workers`. ### Background The shard count decides which thread owns which domain, so it is part of the layout of the data and not a knob to turn at run time. Data written for three shards cannot be served by a server that routes for two without moving it first. The server therefore refuses a mismatch instead of rerouting silently, and the count changes only through an offline tool that rewrites the data directory. More shards let more domains write at the same time. They do not help a single busy domain, because its writes stay on one core, and they use cores and memory that readers could use. Leave the key at `0` unless the automatic count does not fit the host, for example when the writes are spread over many domains on a large host, or when a small host should keep its cores for readers. ## [multicore] shard_queue_capacity Requests one data shard takes at once, running or waiting; further requests are answered with 503 and Retry-After: 1. At least 1. - Default: `1024` - Since: v0.5.1 ### Effect The number of requests that one data shard takes at the same time, running or waiting. Every shard has its own limit. A request counts from the moment the frontend hands it to the shard until it is answered. This covers the writes of the shard's domains and the other requests that run on the shard's thread; reads that run on the reader pool or on the frontend do not count (see `multicore.reader_queue_capacity`). A request that finds the limit reached is not processed. It is answered at once with `503 Service Unavailable`, the header `Retry-After: 1` and the body `503 Service Unavailable: the server is overloaded, retry later`, and the client may send it again. The value must be at least 1; the start is refused with `invalid config: multicore.shard_queue_capacity (0) must be at least 1` otherwise. The start log shows it in the line `N cores: …; shard queue capacity: N`. Writes without a domain, such as the management of accounts, run on the control-plane thread and are not limited by this key. The number also adds to the queue for wake-ups from other threads that each shard and the control-plane thread allocate, together with `storage.wal_queue_capacity`. ### Background Every domain lives on one shard and its writes run one after another on the thread of that shard. When writes arrive faster than the shard completes them, the limit stops the queue from growing without bound: the server sheds the excess quickly with a status that tells clients to retry, instead of letting requests wait ever longer in memory. A burst on one domain fills the lane of that shard only; domains on the other shards go on. Raise the value if bursts of concurrent writes to a few domains produce `503` answers while the CPU has room. If the lane is full for long, the shard itself is the bottleneck, and a longer queue only moves the waiting from the client to the server. In that case, spread the writes over more domains or add shards (`multicore.shards`). ## [multicore] reader_threads Threads that serve read requests next to the data shards: 0 is automatic (cores minus 2, minus the data shards and the frontend threads, at least 1), otherwise at most the number of cores. - Default: `0` - Since: v0.5.1 ### Effect The number of threads of the reader pool. The pool runs every read that is not a lookup of a single key, document or row, which the frontend answers itself: key listings, counts, document searches, SQL requests, metrics, streams such as the watch endpoint, and downloads. It also takes over a single-item read that would have to wait for the disk, which the frontend then does not serve itself. It reads the same engines as the data shards and runs on its own threads, so reads do not wait for the thread of a shard. `0` is automatic: the cores minus two, minus the data shards and the frontend workers, at least 1. The start log shows the result in the line `N cores: M frontend workers, K data shards, R reader threads; …`. An explicit value must not exceed the number of cores the process can use; the start is refused with `invalid config: multicore.reader_threads (…) must be 0 (auto) or 1 to N (available cores)` otherwise. The server does not check that the frontend workers, the data shards and the reader threads together fit the cores. ### Background Reads scale with these threads, writes with the shards. A read-heavy installation gets more from additional reader threads than from additional shards. On a host that is busy with other work, set a value that fits the cores you want to give the database; the automatic value counts all cores of the host. If clients receive `503` answers on reads, look at `multicore.reader_queue_capacity` and at whether the pool has enough threads for the load. ## [multicore] reader_queue_capacity Read requests that may wait for a reader thread; a request beyond that is answered with 503 and Retry-After: 1. Running reads and open streams do not count. At least 1. - Default: `4096` - Since: v0.5.1 ### Effect The number of read requests that may wait for the reader pool. A request waits from the moment the frontend hands it to the pool until the pool takes it up; reads that run on the pool and open streams no longer count. A request that finds the queue full is not processed. It is answered at once with `503 Service Unavailable`, `Retry-After: 1` and the body `503 Service Unavailable: the server is overloaded, retry later`, and the client may send it again. The value must be at least 1; the start is refused with `invalid config: multicore.reader_queue_capacity (0) must be at least 1` otherwise. The start log shows it as `Reader pool queue capacity: N`. ### Background The queue absorbs bursts of reads that arrive faster than the pool takes them up. Without a limit, a flood of reads would wait in memory and grow the latency of every request behind it; with the limit, the excess is turned away quickly and clients can retry. A queue that is often full means the pool does not keep up, and more threads (`multicore.reader_threads`) help more than a longer queue. Raise the capacity if short bursts cause `503` while the CPU is idle. ## [lsm] vlog_inline_threshold Values of at least this many bytes go to the value log instead of the SSTables. - Default: `1024` - Since: v0.1.0 ### Effect A value of at least this many bytes is appended to the value log (`storage.vlog_path`) when it is written. The MemTable and the SSTables then keep only a pointer to it. A shorter value stays inline, in the MemTable and in the data blocks of the SSTables. For the REST API the size of a value is the size of the request body. The test is made once, when the value is written or replayed from the write-ahead log; changing the key does not move values that are already stored. With `0`, every value goes to the value log. The key applies to the key-value engine. The JSON and relational engines and the system store use a built-in value and ignore the key. The server does not check the value at start. The size of the pointer, not of the value, counts toward the size of the MemTable (`lsm.memtable_size_threshold`), so values that go to the value log let a MemTable hold many more entries before it is flushed. ### Background The value log keeps large values out of the SSTables. A compaction rewrites keys and pointers but not the values, so large values are not rewritten at every level they pass through. The cost is a second read for a value in the log, and dead space after overwrites and deletes, which the cleanup of `janitor.dead_bytes_threshold` reclaims. A higher threshold keeps more values inline, which makes reads of them cheaper and SSTables and compactions larger; a lower one does the opposite. Change the default only with a measurement of your own workload. ## [lsm] memtable_size_threshold MemTable size in bytes (keys plus stored values) at which it is written to disk. - Default: `4194304` - Since: v0.1.0 ### Effect The size at which the active MemTable of a shard is frozen and queued to be written to an SSTable at level 0. The size is the number of bytes of the encoded keys, which are the stored key (the internal domain prefix and the user key) plus an 8-byte timestamp, and of the values kept inline. A value that goes to the value log counts only with its pointer (`lsm.vlog_inline_threshold`). The check runs at the start of every write, so the write that follows the moment the MemTable reaches the threshold freezes it, and a MemTable can exceed the threshold by the writes that are in flight. The flush loop then writes one frozen MemTable per turn (`lsm.flush_check_interval_ms`). The same check applies while the server replays the write-ahead log at start. Each data shard has a MemTable of its own for the key-value engine, so the memory for them grows with the number of shards. The key applies to the key-value engine only; the JSON and relational engines and the system store use a built-in size and ignore it. The server does not check the value at start, and `0` is accepted. The start log prints the value for every shard in the line `Shard N: … MemTable threshold … bytes per engine`, even though only the key-value engine uses it. For the memory the server holds regardless of load, it counts two MemTables per engine and shard; see `resources.memory_budget`. ### Background A MemTable absorbs writes in memory while the write-ahead log keeps them safe. A larger MemTable turns more writes into one SSTable, so there are fewer, bigger L0 files and less work for compaction, at the price of more memory and a longer replay of the log after a crash, because more records are in the log and not yet in an SSTable. A smaller one keeps the log and the recovery short and produces more L0 files, which reach the limit of `compaction.l0_threshold` sooner. Independently of this key, `storage.wal_max_size` makes shards write their MemTables out when the log has grown to the cap, so the log stays bounded. Raise the key on a host with plenty of memory and heavy writes; lower it where memory is tight or where a short recovery matters more than throughput. ## [lsm] max_key_length Longest stored key in bytes, including the internal domain prefix. Must leave room for domains.max_user_key_length plus the 19-byte prefix. - Default: `512` - Since: v0.1.0 ### Effect The limit, in bytes, for the keys of the key-value engine as the engine stores them. A stored key is the user key with a prefix of 19 bytes in front of it (`d:`, 16 hexadecimal digits that identify the domain, and `:`). The value must be at least 20 and must not exceed 100663296 bytes (96 MiB), the largest field that the recovery of the write-ahead log reads; the start is refused with `invalid config: lsm.max_key_length (19) must be at least 20` or with `invalid config: lsm.max_key_length (…) exceeds the WAL recovery field cap (100663296 bytes) — writes this large could never be recovered` otherwise. The longest key a client may use is `domains.max_user_key_length`, but never more than this value minus 19. If that key asks for more, the start caps it and logs a warning per data shard, such as `domains.max_user_key_length (256) is capped to 81 by lsm.max_key_length (100) minus the 19-byte internal domain prefix; raise lsm.max_key_length to use the full length`. In a test of v0.7.1 with this key set to 100, a put with a key of 82 bytes was answered with `400 Bad Request: Key length 82 exceeds maximum of 81 bytes`, and a bulk delete by prefix (`DELETE /store-api/kv/{domain}/keys?prefix=…`) removed a key of 81 bytes with `200`. Every key that a put accepts can therefore be removed by a bulk delete as well. With the defaults, 256 bytes for a user key and 512 here, nothing is capped. The JSON and relational engines have their own limits (`json.lsm.max_key_length` and `rel.lsm.max_key_length`), and the system store uses a built-in one. ### Background A key is stored in every MemTable entry, every write-ahead log record and every SSTable entry, together with an 8-byte timestamp per version, so the length of the keys is paid for in memory and on disk. The limit guards the engine against keys of unreasonable size. The default was 256 before v0.7.0; a `luradb.toml` that still sets 256 caps user keys at 237 bytes with the warning above, so set it to 512 or remove the line. Raise it together with `domains.max_user_key_length` if you need keys longer than 493 bytes. ## [lsm] max_value_size Largest value in bytes; larger writes are rejected. - Default: `524288` - Since: v0.1.0 ### Effect The largest value, in bytes, that the key-value engine stores. The value must not exceed 100663296 bytes (96 MiB), the largest field that the recovery of the write-ahead log reads; the start is refused with `invalid config: lsm.max_value_size (…) exceeds the WAL recovery field cap (100663296 bytes) — writes this large could never be recovered` otherwise. Since v0.7.0 the REST API applies the limit to the value of a put, before anything is written. In a test of v0.7.1 with the default of 524288 bytes, a put of 524288 bytes was answered with `200` and one of 524289 bytes with `413 Payload Too Large: value of 524289 bytes exceeds lsm.max_value_size (524288 bytes)`; with the key set to 1000, a put of 1001 bytes was refused the same way. The request body is limited to 2 MiB (2097152 bytes) on its own: a put of 2.2 MB was answered with `413` and `Failed to buffer the request body: length limit exceeded`, so a value larger than 2 MiB cannot be written whatever this key says. The JSON engine and the relational engine have limits of their own (`json.lsm.max_value_size` and `rel.max_row_size`), and the system store uses a built-in one. ### Background The key is the ceiling for the size of a single value in the key-value store. Its upper bound exists so that no value can be written that the recovery of the write-ahead log would refuse to read after a crash. Lower it if clients should not store large objects; raising it above 2 MiB has no effect over REST. ## [lsm] flush_check_interval_ms How often, in milliseconds, the flush loop checks for a full MemTable. At least 1. - Default: `100` - Since: v0.1.0 ### Effect The pause, in milliseconds, between two turns of the flush loop of a shard. In each turn the loop writes the oldest frozen MemTable of the shard to a new SSTable at level 0, if there is one, and then sleeps for this long. A MemTable is frozen by the write that follows the moment it reaches `lsm.memtable_size_threshold`. After a failed flush the loop waits for `lsm.compaction_check_interval_ms` instead. The loop writes at most one MemTable per turn; the shutdown of the server and the steps that need all data in SSTables (the cleanup of the value log, the write-ahead log cap of `storage.wal_max_size`) flush MemTables on their own. The value is a whole number of milliseconds and must be at least 1; `0` refuses the start with `invalid config: lsm.flush_check_interval_ms (0) must be at least 1`. ### Background A frozen MemTable stays in memory, and stays in the write-ahead log, until the loop reaches it. A short pause gets data into SSTables quickly and keeps the memory of frozen MemTables and the log short, at the price of more wake-ups of an idle shard. With the default MemTable size, one flush per turn is an upper bound of a few tens of MiB per second and shard for the loop; if you raise the write rate beyond what one MemTable per turn can absorb, lower the pause or enlarge the MemTable. The pause is rarely the first setting to look at. ## [lsm] compaction_check_interval_ms How often, in milliseconds, the compaction loop checks for work. At least 1. - Default: `1000` - Since: v0.1.0 ### Effect The pause, in milliseconds, between two turns of the compaction loop of a shard. In each turn the loop checks the levels of the shard's SSTables against the limits of `compaction.l0_threshold`, `compaction.l1_max_size` and `compaction.level_size_ratio`. If a level is over its limit, it runs one compaction, for the lowest such level, and then sleeps for this long. A shard therefore starts at most one compaction per interval. The same value is the pause of the flush loop after a failed flush (`lsm.flush_check_interval_ms`). The value is a whole number of milliseconds and must be at least 1; `0` refuses the start with `invalid config: lsm.compaction_check_interval_ms (0) must be at least 1`. ### Background Compactions rewrite data, so they compete with writes for the disk and the CPU, and the pause caps how often a shard starts one. The `l0_sstable_count` field of `GET /health` shows how many level-0 files are waiting. If it keeps growing under sustained writes, compaction does not keep up; a shorter pause lets a shard start its next compaction sooner, a longer one spares the disk. Leave the default unless you see that. ## [lsm] wal_event_channel_capacity Change events buffered for watch streams; a watcher further behind gets `reset`. At least 1. - Default: `256` - Since: v0.1.0 ### Effect The number of change events that the key-value engine of a shard buffers for the watch streams (`GET /store-api/kv/{domain}/watch`). Every write and delete publishes an event after it is visible. A shard has one channel for the events of all its domains, and every open watch has a relay channel of the same size behind it. A watcher that falls further behind than this number of events loses the events it did not read. It receives `event: reset` with the reason `lagged` instead, and has to read the domain again before it applies events. Because the channel carries the events of every domain on the shard, a watcher of a quiet domain can lag when other domains on its shard are busy. The value must be at least 1; `0` refuses the start with `invalid config: lsm.wal_event_channel_capacity (0) must be at least 1`. The key applies to the key-value engine; the JSON and relational engines and the system store use a built-in size. ### Background Writers never wait for a slow watcher. The channel drops the oldest events of a watcher that does not keep up, and the `reset` tells the client that its picture of the domain has a gap. A larger channel gives slow or bursty watchers more room before that happens, at the price of memory for the buffered events, which hold their keys. Raise the value if watchers regularly receive `reset` with the reason `lagged` during write bursts. The ring for resuming after a reconnect is a separate setting, `lsm.watch_replay_buffer_size`. ## [lsm] watch_replay_buffer_size KV watch replay-ring size. 0 = resume off (every reconnect with a Last-Event-ID gets `reset`); id: fields always exist. - Default: `1024` - Since: v0.4.0 ### Effect The number of change events that each shard keeps for clients that reconnect to a watch stream. Every event of the stream carries an `id:`. A client that reconnects with that id in the `Last-Event-ID` header (or `?last_event_id=`) gets the events it missed, without a gap, if they are still in the ring. Otherwise the stream starts with `event: reset` and a reason: `window_exceeded` if the id is older than the ring, `restart` if the server has been restarted since the id was issued, `unknown_id` for an id the server does not know. After a `reset` the client should read the domain again and then keep applying events. The ring holds the events of all domains of a shard, and all watchers share it. Its size counts events, not time, so the window in time is the size divided by the write rate of the shard. The ring is filled up to its size and then overwritten from the oldest event; memory grows with the number of stored events, which hold their keys. With `0`, the ring stores nothing: every reconnect with a `Last-Event-ID` gets `reset`, but the events still carry ids. The key applies to the key-value engine; the JSON and relational engines have no watch. The channel that feeds the watchers that stay connected is set by `lsm.wal_event_channel_capacity`. ### Background A watch stream is a long-lived connection, and clients such as a browser's `EventSource` reconnect on their own and send the last id. The ring lets them continue without reading the domain again after a short interruption. Size it for the longest interruption you want to bridge at the write rate of a shard: with 1000 writes per second on a shard, a ring of 60,000 events covers a minute. If the clients are always connected, or if they read the domain again after every reconnect anyway, the ring brings nothing, and `0` saves its memory. ## [compaction] l0_threshold Number of level-0 SSTables that starts a compaction into level 1. - Default: `4` - Since: v0.1.0 ### Effect The number of SSTables at level 0 of a shard at which the compaction loop (`lsm.compaction_check_interval_ms`) starts a compaction of level 0 into level 1. The comparison is "at least": with the value 3, the compaction starts when the third file has arrived. Every flush of a MemTable (`lsm.memtable_size_threshold`) adds one file at level 0. Files at level 0 can overlap each other in their key ranges, so the compaction merges all of them, together with the files of level 1 whose key ranges they touch, into new files at level 1 (the size of those is limited by `compaction.max_sstable_size`). Older versions of a key that no reader can still need are dropped, and, when no level below holds files, so are deleted and expired entries. The server does not check the value. The number of level-0 files of all shards together is the `l0_sstable_count` field of `GET /health`, and `compaction_runs` in the system block of the metrics endpoint counts the compactions that have run. ### Background The value sets how many unmerged files a shard may carry. A low value merges early: fewer files overlap, so there are fewer places to look for a key, but data is rewritten more often. A high value postpones the work and leaves more files at level 0 for reads to go through. Lower it for read-heavy installations that suffer from a growing `l0_sstable_count`; raise it for write-heavy ones that can afford slower reads. ## [compaction] l1_max_size Level-1 size in bytes that starts a compaction into level 2. - Default: `104857600` - Since: v0.1.0 ### Effect The total size, in bytes, of the SSTables at level 1 of a shard at which the compaction loop starts a compaction of level 1 into level 2. The comparison is "at least". The compaction takes the largest single file of level 1 and merges it with the files of level 2 whose key ranges it touches. Deeper levels follow the limit of this key multiplied by the factor of `compaction.level_size_ratio` once per level below level 1: level 2 holds the limit times the factor, level 3 times the factor squared, and so on. The value is a whole number of bytes and is not checked at start. A shard whose data stays below this size never moves beyond level 1. That has a consequence for deleted data: deleted and expired entries are dropped when a compaction runs and no level below its target holds files, and the compaction of level 0 into level 1 is such a run while level 2 is empty. ### Background The limit decides how much data sits in the first merged level before it is pushed down. A larger limit keeps small and medium data sets in a single level of files whose key ranges do not overlap, so that a read looks at one file there, and it postpones the first large compaction. A smaller limit pushes data down earlier and spreads it over more levels. It is a limit per shard: with several shards (`multicore.shards`) the data of the key-value engine is divided among them, and each shard reaches the limit with its own share. ## [compaction] level_size_ratio Size factor between consecutive levels (level 2 holds 10 times level 1). - Default: `10` - Since: v0.1.0 ### Effect The factor by which the size limit grows from one level to the next. Level 1 is limited by `compaction.l1_max_size`; level n from 2 on is limited to that value times this factor raised to the power n - 1. With a factor of 4 and a level-1 limit of 50 MiB, levels 2 and 3 are limited to 200 MiB and 800 MiB. A level is compacted into the next one when its total size reaches its limit. The calculation saturates instead of overflowing, so a very large value does not wrap around. The value is a whole number and is not checked at start. ### Background The factor shapes the tree: with a larger factor, the same amount of data spreads over fewer levels, and each level holds more before it is pushed down. With a smaller factor, there are more levels with smaller steps between them. Change it only together with `compaction.l1_max_size` and after you have measured the compaction work for your own data volume. ## [compaction] max_sstable_size Largest SSTable in bytes a compaction writes; larger results are split. - Default: `67108864` - Since: v0.1.0 ### Effect The size at which a compaction closes an output file and starts the next one. While it writes a file, the compaction adds up the length of every key and of every value, where a value that lives in the value log counts as its pointer and an inline value as its length plus 8 bytes. When the sum reaches this number, the file is closed at the next boundary between two user keys, so that all versions of a key stay in one file. A file is therefore at least as large as the limit unless the data runs out, and it is somewhat larger on disk than the sum, because of the structure around the data: in a test of v0.5.1 with a limit of 20000, the full files of a compaction were about 22 KB. The files that a flush writes at level 0 are not cut by this key; they are as large as the MemTable they come from. The value is a whole number of bytes and is not checked at start. With `0`, every user key gets a file of its own. ### Background Each compaction step merges one file of a level (the largest) with the files of the next level that it overlaps, or all files of level 0, so the size of the files bounds the work and the temporary disk space of one step: a compaction waits while its volume has less free space than its inputs take. Smaller files make the steps smaller and let a compaction touch less data that did not change, at the price of more files and a longer manifest. Larger files do the opposite. Change the default only if compactions of the current size are too slow or too disruptive. ## [janitor] check_interval_secs How often, in seconds, the janitor checks whether a GC run is due. At least 1. - Default: `60` - Since: v0.1.0 ### Effect The pause, in seconds, between two checks of the janitor, the task that cleans the value log of a shard. The janitor sleeps for this long first and then runs one check, so the first check comes one interval after the start. Each check estimates how much of the value log is dead; it reads the pointers that the SSTables and MemTables of the shard hold to do so. If the estimate reaches `janitor.dead_bytes_threshold` and the log has at least `janitor.min_vlog_size_bytes` bytes, the check goes on to clean the log. The three keys of the `[janitor]` section apply to the key-value engine; the JSON and relational engines and the system store clean their logs with built-in values. The value is a whole number of seconds and must be at least 1; `0` refuses the start with `invalid config: janitor.check_interval_secs (0) must be at least 1`. A cleanup writes two lines to the standard error output (the journal of the packaged service): `[Janitor] Starting GC: generations=…, vlog_size=…, dead(est)=… (…%)` and, when it is done, `[Janitor] GC complete: …`. The `janitor_runs` field in the system block of the metrics endpoint counts the cleanups that have run. ### Background The check itself costs a read of the pointers of the shard's SSTables, which grows with the amount of data, while the dead space it looks for grows only as values are overwritten or deleted. A longer pause is cheaper on large stores and delays the reclaiming of space; a shorter one reclaims sooner. Shorten it for a test that has to see a cleanup quickly. ## [janitor] dead_bytes_threshold Share of dead bytes in the value log (0 to 1) that starts a GC run. - Default: `0.30` - Since: v0.1.0 ### Effect The share of the value log that has to be dead before the janitor cleans it, as a number from 0 to 1 with decimals. The janitor estimates the share as the size of the log minus the bytes that the pointers in the MemTables and SSTables of the shard still reference, divided by the size of the log. A cleanup starts when the estimate is at least this number and the log has at least `janitor.min_vlog_size_bytes` bytes. The server does not check the value at start: a number above 1 is never reached, so the log is never cleaned, and `0` cleans at every check that passes the size minimum. The estimate lags behind the writes. A value that was overwritten or deleted counts as live for as long as an older version of its key is still in a MemTable or an SSTable, so the dead share rises only once flushes and compactions have merged those versions away. In a test of v0.5.1, a log of 180,000 bytes with a threshold of 0.2 was cleaned after compactions had dropped the overwritten versions, with the log lines `[Janitor] Starting GC: … dead(est)=84000 (46.7%)` and `[Janitor] GC complete: … reclaimed=84000 bytes`. A cleanup opens a new generation of the value log, copies the live values into it, rewrites the SSTables with the new pointers, and deletes the old generation (see `storage.vlog_path`). It needs free space on the volume of the value log for the live values; while the volume has less, the cleanup waits and logs `Value log cleanup waits for disk space`. ### Background A cleanup copies every live value, however little is dead, so its cost depends on the live part of the log, while the space it returns is the dead part. A low threshold cleans often and returns little each time; a high one lets dead space pile up and returns much at once, but needs more free disk space beforehand for the log to grow into. Choose it by how much extra disk space you can spare for dead values. A value of 0.5 lets the log be about twice as large as its live data before a cleanup. ## [janitor] min_vlog_size_bytes Value-log size in bytes below which GC never runs. - Default: `67108864` - Since: v0.1.0 ### Effect The size, in bytes, that the value log of a shard needs before the janitor may clean it, however much of it is dead. The size is that of all generation files of the shard's log together (`storage.vlog_path`); the cleanup of `janitor.dead_bytes_threshold` is skipped while the sum is below it. The limit applies to each shard on its own, not to the sum over all shards. The value is a whole number of bytes and is not checked at start. In a test of v0.5.1 with a value log of 180,000 bytes and a dead-bytes threshold of 0.2 that was met, a janitor with this key at 1 cleaned the log, and one with the default did not (`janitor_runs` stayed at 0). ### Background The cleanup copies the live values and rewrites SSTables, which is wasted effort for a small log. The minimum keeps small stores from being cleaned: until the log of a shard has grown to this size, dead values in it stay where they are. Lower the value where disk space is tight, or for a test; raise it where space is plentiful and you want fewer cleanups. ## [ttl_sweeper] enabled Runs the sweeper; while off, expired keys are only hidden on read. - Default: `true` - Since: v0.4.0 ### Effect With `true`, each shard runs a sweeper for the keys of its key-value engine that have a time to live (the `ttl` parameter of a put). The sweeper finds keys whose time has run out, writes a tombstone for each one and publishes a `delete` event for it to the watch streams. The tombstone is a logged write like any other delete. The sweeper does not run while writes are refused for lack of disk space or memory (`resources.disk_free_block`). Its pace is set by `ttl_sweeper.interval_secs` and `ttl_sweeper.batch_size`. With `false`, expiry is lazy. A key past its time is hidden from reads: `GET` answers `404`. Its data is removed only when a compaction that has no level below it passes over it, and no `delete` event is published for it. In a test of v0.5.1 with a key put with `ttl=1`, a watcher received a `set` and a `delete` event with the sweeper on and only the `set` event with it off; three seconds after the put, the `GET` answered `404` in both cases. The system store has a sweeper of its own, because the OAuth clients and tokens of the MCP listener have a time to live. It runs when `mcp.enabled`, `mcp.oauth_enabled` and this key are all `true`. Setting this key to `false` therefore also stops the sweeping of expired OAuth records there. ### Background Reads never return an expired key either way, so the sweeper does not change what a client reads. It changes what watchers see, since expiries arrive as `delete` events, and it replaces the expired value with a tombstone instead of leaving the value until a compaction with no level below it passes over it. The price is a periodic pass over the keys of each shard. Turn the sweeper off if you use no time to live, or if neither watchers nor the early tombstone matter to you and the passes cost too much. ## [ttl_sweeper] interval_secs Seconds between two sweeper ticks. At least 1. - Default: `60` - Since: v0.4.0 ### Effect The pause, in seconds, between two ticks of the TTL sweeper of a shard. A tick runs at once when the shard starts, and the next one follows after this pause. In a tick the sweeper scans the keys of the shard's MemTables and SSTables for expired versions, takes up to `ttl_sweeper.batch_size` of the keys it finds and writes a tombstone for each key that is still expired. The delay between the end of a key's time and its `delete` event is therefore at most the pause plus the time of one tick, and more if more keys have expired than a tick takes; reads hide the key within a second of the end of its time whatever the pause is. The value is a whole number of seconds and must be at least 1; `0` refuses the start with `invalid config: ttl_sweeper.interval_secs (0) must be at least 1`. The check runs even while `ttl_sweeper.enabled` is `false`. The key has no effect while `ttl_sweeper.enabled` is `false`. It applies to the key-value engine and to the sweeper of the system store, which `ttl_sweeper.enabled` describes. ### Background Every tick reads the keys of all MemTables and SSTables of the shard, whatever the batch size is, so the cost of a tick grows with the data and the pause sets how often it is paid. A short pause makes the `delete` events follow the expiries closely and suits small data sets with watchers that react to them. On a large data set, a longer pause spares the disk and the CPU. ## [ttl_sweeper] batch_size Candidates checked per tick — discarded ones count too. - Default: `500` - Since: v0.4.0 ### Effect The number of expired keys that one tick of the TTL sweeper looks at. The sweeper collects up to this many candidate keys, the smallest ones above the point where the last tick stopped, checks each of them again, and writes a tombstone only for those that are still expired. Candidates that turn out not to need a tombstone count toward the number too, so a tick may write fewer tombstones than this. A tick therefore writes at most this many tombstones. The sweeper remembers where a tick stopped and goes on from there in the next one, so a backlog of expired keys is worked off tick by tick. When a tick finds fewer candidates than this number, the sweeper starts again from the beginning of the key space at the next tick. The position is not kept over a restart. The value is a whole number and is not checked at start; with `0`, no tick finds a candidate, and the sweeper writes nothing. The memory of a tick is proportional to this number, not to the number of keys in the shard. ### Background A larger batch clears a backlog of expired keys in fewer ticks, but each tombstone is a logged write like a delete by a client, so a large batch makes a burst of writes next to the writes of clients. A smaller batch spreads the work more evenly over time and takes longer to catch up. With many keys that expire at the same moment, such as sessions with the same time to live, the batch size and `ttl_sweeper.interval_secs` together set how fast the `delete` events come: about one batch per pause. ## [domains] max_name_length Longest domain name in characters ([a-zA-Z0-9_-]), in every engine. At most 438, so that the name fits the keys of the system store; json.lsm.max_key_length and rel.lsm.max_key_length are raised at the start, with a warning, to take it. - Default: `50` - Since: v0.1.0 ### Effect The longest name, in characters, that a domain may have. A name consists of the characters `a-z`, `A-Z`, `0-9`, `_` and `-`. A request that creates a longer name (`POST /store-api/domains`) is answered with `400` and `400 Bad Request: invalid domain name '…': allowed are [a-zA-Z0-9_-], 1 to N characters`. The limit is checked when a domain is created; domains that already exist keep working when the value is lowered. Since v0.7.0 the limit applies to every engine, because one domain holds keys, documents and tables alike. In a test of v0.7.1 with the key set to 10, a domain with 11 characters was refused and one with 10 characters was created. The name of `domains.default_domain` is not checked against the limit: with the value 5, the start still created the domain `default`, while creating `abcdef` was refused. The value must not exceed 438, so that a domain name fits the keys of the system store; a larger value refuses the start with `domains.max_name_length = 439 exceeds the maximum of 438`. The JSON and relational engines store the name in their keys. A start therefore raises `json.lsm.max_key_length` to at least 19 plus this value and `rel.lsm.max_key_length` to at least 23 plus this value, with a warning for each raised key: with 438, the log said `json.lsm.max_key_length (256) is raised to 457, the least that takes domain names of domains.max_name_length (438) characters`, and the same for `rel.lsm.max_key_length` with 461. The default of 50 needs no raise. ### Background The name of a domain appears in every path of the API, in backup scopes (`domain:`) and in the stored keys of the JSON engine, the relational engine and the system store. The default of 50 characters is enough for names such as tenant or project identifiers. Raise the value only if you need longer names. ## [domains] max_user_key_length Longest key a client may use in the key-value engine, in bytes. - Default: `256` - Since: v0.1.0 ### Effect The longest key, in bytes, that a client may use in the key-value engine. The limit counts bytes, not characters: a four-byte character such as an emoji counts four times. A put, a read, a delete, a set-to-null or a metadata request with a longer key is answered with `400 Bad Request: Key length 257 exceeds maximum of 256 bytes`. Two rules are fixed: a key must not be empty and must be valid UTF-8. The prefix and substring parameters of listings, counts and bulk deletes are not checked against this key. The engine stores a key with a prefix of 19 bytes in front of it, and `lsm.max_key_length` limits the stored key. A value above that limit minus 19 is capped there at start, with a warning per data shard: in a test of v0.7.1 with the value 600 and the default `lsm.max_key_length` of 512, the log said `domains.max_user_key_length (600) is capped to 493 by lsm.max_key_length (512) minus the 19-byte internal domain prefix; raise lsm.max_key_length to use the full length`. Every key that a client can write therefore also fits the stored-key limit, and a bulk delete by prefix can remove it. The key applies to the key-value engine. JSON document keys and relational primary keys have their own limits (`json.lsm.max_key_length` and `rel.lsm.max_key_length`). ### Background Every version of a key is kept in the MemTable, in the write-ahead log and in the SSTables, so the length of the keys is paid for in memory and on disk. The default of 256 bytes is long enough for composite keys such as `tenant:42:order:2026-11-03`. Keep the limit as small as your keys allow. With the default `lsm.max_key_length` of 512 you can raise it to 493 bytes; beyond that, raise `lsm.max_key_length` as well. ## [domains] default_domain Domain created in every engine at a start if it is missing. - Default: `"default"` - Since: v0.1.0 ### Effect The name of the domain that every start creates if it does not exist. Like every domain, it holds keys, documents and tables: the start creates it in each engine that is on, and `GET /store-api/domains` lists it. A new data directory starts with this one domain. The start does not check the name against the rules for domain names (the characters `a-z`, `A-Z`, `0-9`, `_`, `-` and at most `domains.max_name_length` characters). In a test of v0.7.1, `default_domain = "bad name!"` started the server and created a domain of that name, which answered `GET /store-api/kv/bad%20name!/keys` with `200`; a name of 60 characters was created as well, with the limit at 50. `POST /store-api/domains` refuses such names, so use one that follows the rules. The domain is an ordinary domain. It can be deleted, and the next start creates it again: in a test of v0.7.1, `DELETE /store-api/domains/default` was answered with `202`, the listing no longer showed the domain at once, the purge had removed it after about 6 seconds, and after a restart the domain was back. A start that finds the domain still being deleted leaves it to the purge, and requests for it get `410 Gone: domain 'default' is being deleted`; the domain is created at the first start after the purge has finished. Changing the key moves nothing. In a test of v0.7.1, a data directory that already had `default` listed both `default` and `main` after a start with `default_domain = "main"`, and `main` answered on the key-value, JSON and relational routes; the old domain and its data stay. Since v0.7.0 the key names the default domain of all three engines; before, the JSON and relational engines always created `default`. ### Background No request falls back to this domain: clients always name the domain in the path, and the server does not use the default domain anywhere else. Its only purpose is that a new installation has one domain to try the API on without creating one. Change the key if you want a different name for it. The server has no setting that starts it without such a domain; a domain you delete is created again at the next start. ## [domains] purger_batch_size Keys removed per step while a deleted domain is purged in the background. - Default: `100` - Since: v0.1.0 ### Effect The number of keys that one purge step removes from the key-value part of a deleted domain. `DELETE /store-api/domains/{name}` answers `202` at once and makes the domain unreachable: requests for its keys get `410 Gone: Domain '…' is being deleted`, the domain listing no longer shows it, and creating the name again is answered with `409 Conflict: domain '…' is being deleted` until the purge has finished. The data is removed in the background. Each step, every shard looks at each deleted domain it owns, reads the full list of its remaining keys, writes a tombstone for the first N of them, and leaves the rest for the next step. A step that finds no key left ends the key-value part, so a domain with 200 keys needs four steps for the keys and a fifth to finish. The JSON and relational engines purge their parts of a deleted domain with a fixed batch of 100 keys every 5 seconds, and the domain and its name are free only when all three parts are gone. In a test of v0.7.1 with the value 50 and a pace of one second (`domains.purger_interval_secs`), a domain with 200 keys could be created again 4.8 seconds after the delete. No step runs while writes are refused for lack of disk space or memory (`resources.disk_free_block`). With `0`, a step removes no key. A domain that holds keys then stays in the deleting state, and its name stays blocked; in a test of v0.7.1, creating the name again 12 seconds after the delete was answered with `409 Conflict: domain 'd2' is being deleted`. A deleted domain that holds no keys is still removed. ### Background Deleting a domain does not freeze the server, because the keys leave in small batches that share the write path with normal traffic; each tombstone is a logged write like any other delete. A larger batch finishes a big domain sooner and needs fewer steps, and every step reads the whole remaining key list, so a small batch on a large domain repeats that read many times. The defaults of 100 keys every 5 seconds remove 1,200 keys a minute from the key-value part of each deleted domain; raise the batch if deleting domains with millions of keys takes too long. ## [domains] purger_interval_secs Seconds between two purge steps. At least 1. - Default: `5` - Since: v0.1.0 ### Effect The number of seconds between two purge steps of the key-value part of a deleted domain. Each shard runs one purge loop for the domains it owns: it takes a step (see `domains.purger_batch_size`), waits this many seconds, and takes the next. The first step runs at start. The key-value part of a deleted domain is therefore removed after at most one interval plus the time of the steps it needs, which depend on its number of keys. The key applies to the key-value engine. The JSON and relational engines purge their parts on a fixed pace of 5 seconds, and a deleted domain, with its name, is free only when all three parts are gone. The value must be at least 1; `0` refuses the start with `invalid config: domains.purger_interval_secs (0) must be at least 1`. ### Background A deleted domain is removed in the background so that the delete request returns at once and the purge does not compete with normal traffic. A short interval clears deleted domains sooner, which frees the name for reuse sooner; a long interval spreads the load further. The loop also runs when no domain is deleted, where a step does little more than ask each shard for its deleted domains, so the default of 5 seconds costs almost nothing. Change it only if you delete domains often and need the names back sooner. ## [domains] max_bulk_delete_keys Cap on keys removed by one DELETE …/keys?prefix= bulk delete. - Default: `10000` - Since: v0.4.0 ### Effect The most keys that one `DELETE /store-api/kv/{domain}/keys?prefix=…` request may remove. The request first collects the keys that match the prefix (and the optional `contains` filter), and only then deletes them, all in one atomic write. If more keys match than this key allows, nothing is deleted and the answer is `413` with `413 Payload Too Large: 4 keys match the selection, limit is 3`. The request that is allowed answers `200` with the number of deleted keys, `{"deleted":1}`. The value `0` rejects every selection that matches at least one key, and does not mean unlimited: in a test of v0.5.1, the request answered `413 Payload Too Large: 1 keys match the selection, limit is 0`, and a prefix that matches nothing answered `200` with `{"deleted":0}`. The prefix must not be empty, so a request without one cannot empty the domain; removing a whole domain, with its documents and tables, is `DELETE /store-api/domains/{name}`, which is for admins. The request takes one write token and one read token of the rate limit of the domain (`rate_limit.default_write_iops`). The key applies to the key-value engine only. The server does not check the value at start. ### Background A bulk delete is atomic: either every matching key is gone or none is. That needs the whole list of keys in memory and one large batch in the write-ahead log, so the cap bounds the memory and the size of that batch. To remove more keys than the cap allows, split them by prefix and send several requests, or delete the domain. Raise the cap only if you need larger atomic deletes and have measured the memory and the time of the delete. ## [rate_limit] default_read_iops Reads per second per domain. - Default: `1000` - Since: v0.1.0 ### Effect The read budget of each domain, in operations per second, for its keys and, separately, for its tables. Every domain has budgets of its own, counted independently: a busy domain cannot use up the budget of another, and the key-value part and the relational part of one domain do not share theirs. The budget is a bucket that holds up to one second's worth of operations and starts full. Each read takes one token out of it, and tokens flow back continuously at the rate of the key. A read that finds the bucket empty is answered with `429 Too Many Requests` and the header `Retry-After: 1`; the body is `429 Too Many Requests: read rate limit exceeded` for a key-value read and `rate limit exceeded for domain '…'` for a relational one. After a quiet second a client can therefore send up to this many reads at once. What counts as one read: in the key-value part, a key lookup, a metadata lookup, a key listing and a count (one token for the whole listing, however many keys it returns); in the relational part, a `SELECT` statement and every request that lists or reads tables, views or rows. A bulk delete by prefix also takes one read token for its scan. A point read that has to wait for the disk is taken over by the reader pool, and the token of the first attempt is given back, so such a read costs one token, not two. Documents are not limited: in a test of v0.7.1 with the write budget set to 3, twelve document writes in a row into one domain all succeeded. Domain listings, metrics and other requests outside the key-value and relational routes of a domain take no token. The values are read at start. With `0`, every read of every domain is refused with `429`. The rejections of a domain are counted in the field `rate_limit_rejections` of its entry under `domains` in `GET /store-api/metrics`. ### Background The budget keeps one domain from taking the whole server: the clients of a domain that reaches its rate are slowed down, and other domains are not. It is a limit per domain, not a global one; ten domains that all reach their limits together use ten times the rate. The default of 1,000 reads a second suits a domain used by a few clients. A domain that serves many clients, or a client that reads in large bursts, needs a higher value. Raise it in steps and watch `rate_limit_rejections` and the response times. ## [rate_limit] default_write_iops Writes per second per domain. - Default: `500` - Since: v0.1.0 ### Effect The write budget of each domain, in operations per second, for its keys and, separately, for its tables. It works like the read budget of `rate_limit.default_read_iops`, with a bucket of its own: one second's worth of tokens at the start, one token per write, continuous refill. A write that finds the bucket empty is refused with `429 Too Many Requests` and `Retry-After: 1`, before anything is written; the body is `429 Too Many Requests: write rate limit exceeded` for a key-value write and `rate limit exceeded for domain '…'` for a relational one. In a test of v0.7.1 with the key set to 3, five puts in a row into one domain were answered `200 200 200 429 429`, while a put into a second domain and an `INSERT` into the tables of the first were still accepted. What counts as one write: in the key-value part, a put, a delete, a set-to-null and a bulk delete by prefix (one token for the whole delete, however many keys it removes); in the relational part, every `INSERT`, `UPDATE`, `DELETE` and DDL statement, every insert, update and delete of a row through the row endpoints, and a file import (`tables/from-file`, one token for the whole file). A relational statement is classified by the statement, not by the number of rows it affects: one `INSERT` with many rows takes one token. Document writes are not limited. The values are read at start. With `0`, every write of every domain is refused with `429`. The rejections of a domain are counted in the field `rate_limit_rejections` of its entry under `domains` in `GET /store-api/metrics`. ### Background A write waits for the write-ahead log to reach the disk before it is confirmed, so a client that writes without pause loads the log for everyone. The write budget caps what one domain may ask of it. It is a limit per domain, not a global one. Batch writes where your data allows it, since a bulk delete, a multi-row `INSERT` and a file import cost one token each, and raise the value for domains that need a higher steady rate than 500 writes a second. ## [json] enabled Starts the JSON document engine. While disabled, relational tables show JSON references as NULL and the document routes answer 503; the domains stay, and a start with the engine on creates, deletes and clears their JSON parts as the domains changed meanwhile. - Default: `true` - Since: v0.1.0 ### Effect With `true`, the server runs the JSON document engine: it opens its write-ahead log, value log and SSTables (`json.wal_path`, `json.vlog_path`, `json.sstable_dir`), gives every domain its JSON part, and serves the `/store-api/json/…` endpoints. The engine runs on a storage instance of its own, so JSON work does not share MemTables, caches or compactions with the key-value engine. With `false`, no JSON instance starts and the log says `JSON engine disabled by config.`. In a test of v0.7.1, no JSON files were created, every `/store-api/json/…` endpoint answered `503 Service Unavailable: JSON engine is disabled (json.enabled = false)`, and `/health` stayed `ok`. The domains stay: they are created, listed and deleted as usual, and the other engines keep working, with these exceptions: - A relational table keeps its `JSONREF` columns, but their values read as `null`, because the documents cannot be looked up. Writing a value into such a column is refused with `409` and `cross-engine json target unavailable for domain '…'`, and creating a table with such a column with `409` and `cross-engine json target unavailable`. - A backup of scope `json` or `json:` is refused with `503 Service Unavailable: scope requires the JSON engine, which is disabled (json.enabled = false)`; the scopes `all` and `domain:` leave JSON out. - A domain deleted while the engine is off stays in the deleting state until a start with the engine on has purged its JSON part. In the test, creating the name again 12 seconds after the delete was answered with `409 Conflict: domain 'delme' is being deleted`, and after a restart with the engine on it could be created again. Data already written stays in the files. A start with the engine on brings the JSON parts in line with the domains as they changed meanwhile: in the test, a domain created while the engine was off answered on the document routes, and a `JSONREF` value read as before. While the engine is off, the paths of its files are not checked against the other data paths, but its limits (`json.bulk_body_limit_bytes`, `json.lsm.max_key_length` and `json.lsm.max_value_size`) are still validated at start. ### Background Switch the engine off if the installation stores no documents. It saves what the engine reserves: two MemTables of 4 MiB per shard, a block cache of 64 MiB (divided across the shards), and one write-ahead log that the storage thread has to write. The reservation is part of the fixed memory that the server compares with `resources.memory_budget`. ## [json] wal_path Write-ahead log; relative paths resolve against the working directory. A directory of segment files the server creates, writes and deletes; never change anything in it by hand. The path may be a symlink, the segments then lie at its target. A log file of an earlier LuraDB version at the path becomes such a directory on the first start; an earlier version does not start on it. - Default: `"luradb_json.wal"` - Since: v0.1.0 ### Effect The directory of the write-ahead log of the JSON engine. It holds segment files of 64 MiB each, named `00000001.wal`, `00000002.wal` and so on, which the server creates, writes and deletes; nothing in it should be changed by hand. All data shards of the JSON engine share this one log, so unlike the value log and the SSTables it is not placed in a `shard_` directory. A log file of an earlier LuraDB version at the path becomes such a directory on the first start, and an earlier version does not start on it. The path may be a symbolic link, and the segments then lie at its target. A relative path resolves against the working directory of the server process; the packaged service sets that to `/var/lib/luradb`, so the packaged `luradb_json.wal` is `/var/lib/luradb/luradb_json.wal`. The parent directory is created at start. No two data paths may resolve to the same location (symbolic links resolved). In a test of v0.5.1, setting this key to the value of `storage.wal_path` refused the start with `invalid config: storage.wal_path and json.wal_path resolve to the same location '…'`. The check is skipped while `json.enabled` is `false`. How much of the log the server keeps is set by `storage.wal_max_size`, which caps each engine's log. ### Background A document write is confirmed once it is in this log, and recovery after a crash replays what the SSTables do not yet hold. The write waits for the log to reach the disk, so the latency of the volume sets the lower bound for the latency of document writes. The storage thread of the server writes the logs of all engines and batches concurrent writes into one `fsync` per log. Place the log on a volume with room for `storage.wal_max_size` plus one segment. ## [json] vlog_path Value log for large documents. - Default: `"luradb_json.vlog"` - Since: v0.1.0 ### Effect The value log of the JSON engine. A stored document of 1,024 bytes or more is appended to it, and the SSTables keep only a pointer to it. The threshold is built in: the JSON engine does not use `lsm.vlog_inline_threshold`. A stored document is a little larger than the JSON that the client sent, because a version number and an incarnation id are stored with it. Each data shard has its own file: the server inserts a directory `shard_` before the file name, so a path `/var/lib/luradb/luradb_json.vlog` becomes `/var/lib/luradb/shard_0/luradb_json.vlog` for shard 0. A relative path resolves against the working directory of the server process (under the packaged service, `/var/lib/luradb`). When the value log is cleaned, the live values move into a new generation whose file name is the configured name with `.2` appended, then `.3`, and so on. No other data path may equal this name followed by a dot and digits; the start is refused if one does. The cleanup runs with the built-in settings of the janitor, not with the `janitor` section of the file, which applies to the key-value engine. No two data paths may resolve to the same location. The check is skipped while `json.enabled` is `false`. The key-value engine and the relational engine have their own value logs, `storage.vlog_path` and `rel.vlog_path`. ### Background Keeping large documents out of the SSTables means that a compaction rewrites keys and pointers, not the documents. The price is that overwritten and deleted documents stay in the log as dead space until the cleanup rewrites it, so the volume needs room for the data plus the dead space that builds up between cleanups. The cleanup waits while the volume has less room than the live values take. ## [json] sstable_dir SSTable directory. - Default: `"luradb_json_sstables"` - Since: v0.1.0 ### Effect The directory of the SSTables of the JSON engine. Each data shard keeps its files in a subdirectory `shard_` of it, with the files `sstable_.sst` and a `MANIFEST` that lists them and their levels. The server creates the directory at start. A relative path resolves against the working directory of the server process (under the packaged service, `/var/lib/luradb`). A flush of the MemTable of the JSON engine adds a file at level 0, and compactions merge files into the levels below. The JSON engine runs these with the built-in defaults (a flush at a MemTable of 4 MiB, a compaction at four level-0 files, level 1 at 100 MiB, a factor of 10 between levels, SSTables of at most 64 MiB), not with the `lsm` and `compaction` sections of the file, which apply to the key-value engine only. Documents of 1,024 bytes or more are not in the SSTables but in the value log (`json.vlog_path`). The server does not move data when the path changes. A start with another path opens an empty set of SSTables there, and the data in the old directory is not read. No two data paths may resolve to the same location; the check is skipped while `json.enabled` is `false`. ### Background A compaction writes its output before it deletes its inputs, so the volume needs free room of at least the size of the inputs of the next compaction; the server holds a compaction back and logs `Compaction of level … waits for disk space` while it has less. Plan the volume with headroom beyond the data size, and see `resources.disk_free_warn` for the thresholds at which the server warns and refuses writes. ## [json] bulk_body_limit_bytes Largest request body of POST /store-api/json/{domain}/bulk in bytes. The whole request body is held in memory. - Default: `67108864` - Since: v0.1.0 ### Effect The largest request body, in bytes, that `POST /store-api/json/{domain}/bulk` accepts. The body is NDJSON, one document per line, and it is read into memory as a whole before the first line is parsed. A larger body is refused with `413` and `Failed to buffer the request body: length limit exceeded`; in a test of v0.5.1 with the key set to 3000, a body of 4,190 bytes was refused and one of 830 bytes imported 20 documents. The value must be at least 1; `0` refuses the start with `invalid config: json.bulk_body_limit_bytes (0) must be at least 1`. The check runs even while `json.enabled` is `false`. Every other JSON endpoint takes bodies of up to 2 MiB; the key does not change that. In a test with `json.lsm.max_value_size` raised to 8 MiB, a `PUT` of a document of 3 MB was still refused with the same `413`. A document larger than 2 MiB, which also needs `json.lsm.max_value_size` above that size, can therefore enter only through the bulk endpoint, as one line of the body. The bulk body is imported in batches of 100 documents; a document that fails (for example because it is too large or its key is invalid) is listed under `errors` in the `200` answer and does not stop the others. ### Background The limit exists because the body is held in memory while it is parsed and imported, so several concurrent imports add up. With the default of 64 MiB, an NDJSON export (`GET /store-api/json/{domain}/export`) of up to that size can be imported again in one request. Lower the value on a small host; for larger files, split them into several requests or raise it. ## [json.lsm] max_key_length Longest stored key in bytes; document keys get this minus an internal prefix, at most 256 bytes. Raised at the start, with a warning, below 19 + domains.max_name_length. - Default: `256` - Since: v0.1.0 ### Effect The limit, in bytes, for the keys of the JSON engine as the engine stores them. A document is stored under its key with a prefix of 21 bytes in front of it (`DOC:`, 16 hexadecimal digits that identify the domain, and `:`). The longest key a client may give a document is therefore this value minus 21, but never more than 256; with the default of 256 it is 235 characters. Document keys may contain only `a-z`, `A-Z`, `0-9`, `.`, `_` and `-`. In a test of v0.7.1 with the key set to 100, a document key of 80 characters was refused with `400` and `invalid document key: key length 80 exceeds maximum of 79 characters`, and one of 79 characters was accepted. A bulk import lists such a key under `errors` instead. The index entries of a document are stored under longer keys: `IDX:`, the domain prefix, the field name, the indexed value and the document key. An entry whose key would exceed this limit is not written, and the server does not report it. The document is stored, but a search on that value does not find it. In the test with the limit 100, a document with an 80-character `city` value was stored and returned by `GET`, and a search for that value returned `"total":0`, while a document with the value `Essen` was found. The management keys of the engine hold the domain name, so the value must be at least 19 plus `domains.max_name_length`, 69 with the default. Since v0.7.0 a smaller value is raised to that at start, with a warning: in a test of v0.7.1, the value 10 started the server and logged `json.lsm.max_key_length (10) is raised to 69, the least that takes domain names of domains.max_name_length (50) characters`. The value must not exceed 100663296 bytes (96 MiB), the largest field that the recovery of the write-ahead log reads; a larger one refuses the start with `invalid config: json.lsm.max_key_length (200000000) exceeds the WAL recovery field cap (100663296 bytes) — writes this large could never be recovered`. Both happen even while `json.enabled` is `false`. ### Background A key is stored in every MemTable entry, every write-ahead log record and every SSTable entry, so the length of the keys is paid for in memory and on disk. Keep the limit as small as your keys allow. Raise it if you index long string values and want every document to be found by them, or if you need document keys longer than 235 characters. For the key-value engine and the relational engine see `lsm.max_key_length` and `rel.lsm.max_key_length`. ## [json.lsm] max_value_size Largest stored document in bytes. - Default: `524288` - Since: v0.1.0 ### Effect The largest stored document of the JSON engine, in bytes. The size counts the document as it is stored, which is a little larger than the JSON that the client sent because a version number and an incarnation id are stored with it. A write of a larger document is refused with `413` and `payload of 4166 bytes exceeds maximum of 4096 bytes`; in a test of v0.5.1 with the key set to 4096, a document whose content was 4,108 bytes was stored as 4,166. A bulk import does not fail as a whole: it lists such a document under `errors` in its `200` answer, with the same message. The limit applies on top of the size of the request. Single-document endpoints take bodies of up to 2 MiB (see `json.bulk_body_limit_bytes`), so with a larger value here a document above 2 MiB can still enter only through the bulk endpoint. In a test with the value 8 MiB, a `PUT` of a 3 MB document was refused with `413` and `Failed to buffer the request body: length limit exceeded`. The value must be at least 4096 and must not exceed 100663296 bytes (96 MiB), the largest field that the recovery of the write-ahead log reads. The start is refused with `invalid config: json.lsm.max_value_size (100) must be at least 4096` or `invalid config: json.lsm.max_value_size (…) exceeds the WAL recovery field cap (100663296 bytes) — writes this large could never be recovered`. The check runs even while `json.enabled` is `false`. ### Background A document is written, read and compacted as one value, so the limit bounds the size of every single write and read of the engine. Documents of 1,024 bytes or more are stored in the value log (`json.vlog_path`) and the SSTables keep a pointer. Raise the limit only for documents that are large by nature, and remember that a single write cannot exceed the request limit of 2 MiB unless it goes through the bulk endpoint. ## [rel] enabled Starts the relational engine. While disabled, the relational routes answer 503; the domains stay, and a start with the engine on creates, deletes and clears their relational parts as the domains changed meanwhile. - Default: `true` - Since: v0.1.0 ### Effect With `true`, the server runs the relational engine (LuraSQL): it opens its write-ahead log, value log and SSTables (`rel.wal_path`, `rel.vlog_path`, `rel.sstable_dir`), gives every domain its relational part, and serves the `/store-api/rel/…` endpoints. The engine runs on a storage instance of its own, so SQL work does not share MemTables, caches or compactions with the other engines. With `false`, no relational instance starts and the log says `Relational engine disabled by config.`. In a test of v0.7.1, no relational files were created, and `POST /store-api/rel/default/sql` and `GET /store-api/rel/default/tables` were answered with `503 Service Unavailable: relational engine is disabled (rel.enabled = false)`. The domains stay: they are created, listed and deleted as usual, and the other engines keep working, with these exceptions: - A backup of scope `rel` or `rel:` is refused with `503 Service Unavailable: scope requires the relational engine, which is disabled (rel.enabled = false)`; the scopes `all` and `domain:` leave relational data out. - A domain deleted while the engine is off stays in the deleting state, and its name blocked, until a start with the engine on has purged its relational part. Data already written stays in the files, and a start with the engine on brings the relational parts in line with the domains as they changed meanwhile. While the engine is off, the paths of its files are not checked against the other data paths, but its limits (`rel.max_tables_per_domain`, `rel.max_row_size`, `rel.max_limit`, `rel.max_sort_rows` and `rel.lsm.max_key_length`) are still validated at start. ### Background Switch the engine off if the installation runs no SQL. It saves what the engine reserves: two MemTables of 4 MiB per shard, a block cache of 64 MiB (divided across the shards), and one write-ahead log that the storage thread has to write. The reservation is part of the fixed memory that the server compares with `resources.memory_budget`. ## [rel] wal_path Write-ahead log; relative paths resolve against the working directory. A directory of segment files the server creates, writes and deletes; never change anything in it by hand. The path may be a symlink, the segments then lie at its target. A log file of an earlier LuraDB version at the path becomes such a directory on the first start; an earlier version does not start on it. - Default: `"luradb_rel.wal"` - Since: v0.1.0 ### Effect The directory of the write-ahead log of the relational engine. It holds segment files of 64 MiB each, named `00000001.wal`, `00000002.wal` and so on, which the server creates, writes and deletes; nothing in it should be changed by hand. All data shards of the relational engine share this one log, so unlike the value log and the SSTables it is not placed in a `shard_` directory. A log file of an earlier LuraDB version at the path becomes such a directory on the first start, and an earlier version does not start on it. The path may be a symbolic link, and the segments then lie at its target. A relative path resolves against the working directory of the server process; the packaged service sets that to `/var/lib/luradb`, so the packaged `luradb_rel.wal` is `/var/lib/luradb/luradb_rel.wal`. The parent directory is created at start. No two data paths may resolve to the same location (symbolic links resolved); the start is refused with `invalid config: … resolve to the same location '…'` otherwise. The check is skipped while `rel.enabled` is `false`. How much of the log the server keeps is set by `storage.wal_max_size`, which caps each engine's log. ### Background A DDL or DML statement is confirmed once its changes are in this log, and recovery after a crash replays what the SSTables do not yet hold. The statement waits for the log to reach the disk, so the latency of the volume sets the lower bound for the latency of writes. The logs of the other engines are `storage.wal_path` and `json.wal_path`. Place the log on a volume with room for `storage.wal_max_size` plus one segment. ## [rel] vlog_path Value log for large rows. - Default: `"luradb_rel.vlog"` - Since: v0.1.0 ### Effect The value log of the relational engine. An encoded row of 1,024 bytes or more is appended to it, and the SSTables keep only a pointer to it. The threshold is built in: the relational engine does not use `lsm.vlog_inline_threshold`. Each data shard has its own file: the server inserts a directory `shard_` before the file name, so a path `/var/lib/luradb/luradb_rel.vlog` becomes `/var/lib/luradb/shard_0/luradb_rel.vlog` for shard 0. A relative path resolves against the working directory of the server process (under the packaged service, `/var/lib/luradb`). When the value log is cleaned, the live rows move into a new generation whose file name is the configured name with `.2` appended, then `.3`, and so on. No other data path may equal this name followed by a dot and digits; the start is refused if one does. The cleanup runs with the built-in settings of the janitor, not with the `janitor` section of the file, which applies to the key-value engine. No two data paths may resolve to the same location. The check is skipped while `rel.enabled` is `false`. The key-value engine and the JSON engine have their own value logs, `storage.vlog_path` and `json.vlog_path`. ### Background Keeping large rows out of the SSTables means that a compaction rewrites keys and pointers, not the rows. The price is that overwritten and deleted rows stay in the log as dead space until the cleanup rewrites it, so the volume needs room for the data plus the dead space that builds up between cleanups. The cleanup waits while the volume has less room than the live values take. ## [rel] sstable_dir SSTable directory. - Default: `"luradb_rel_sstables"` - Since: v0.1.0 ### Effect The directory of the SSTables of the relational engine. Each data shard keeps its files in a subdirectory `shard_` of it, with the files `sstable_.sst` and a `MANIFEST` that lists them and their levels. The server creates the directory at start. A relative path resolves against the working directory of the server process (under the packaged service, `/var/lib/luradb`). The SSTables hold the rows, the index entries and the catalog of tables and views. A flush of the MemTable of the relational engine adds a file at level 0, and compactions merge files into the levels below. The relational engine runs these with the built-in defaults (a flush at a MemTable of 4 MiB, a compaction at four level-0 files, level 1 at 100 MiB, a factor of 10 between levels, SSTables of at most 64 MiB), not with the `lsm` and `compaction` sections of the file, which apply to the key-value engine only. Rows of 1,024 bytes or more are not in the SSTables but in the value log (`rel.vlog_path`). The server does not move data when the path changes. A start with another path opens an empty set of SSTables there, and the data in the old directory is not read. No two data paths may resolve to the same location; the check is skipped while `rel.enabled` is `false`. ### Background A compaction writes its output before it deletes its inputs, so the volume needs free room of at least the size of the inputs of the next compaction; the server holds a compaction back and logs `Compaction of level … waits for disk space` while it has less. Plan the volume with headroom beyond the data size, and see `resources.disk_free_warn` for the thresholds at which the server warns and refuses writes. ## [rel] max_tables_per_domain Most tables per relational domain. Catalog entries are held in memory. - Default: `256` - Since: v0.1.0 ### Effect The most tables and views that one domain may hold. Both count: creating a table or a view in a domain that has reached the limit is refused with `400` and `limit exceeded: max_tables_per_domain (max 2)`, which is the answer in a test of v0.5.1 with the key set to 2. Dropping a table or a view makes room again. The limit is checked when the object is created; lowering the key does not remove tables or views that already exist. The value must be between 1 and 4294967295; anything else refuses the start with `invalid config: rel.max_tables_per_domain (0) must be between 1 and 4294967295`. The check runs even while `rel.enabled` is `false`. Two other limits of a table are fixed: 128 columns and 16 indexes per table. ### Background The server keeps the catalog, the definitions of all tables and views of all domains, in memory. Changing a table (dropping it, dropping or renaming a column, renaming it) makes the server bind again every view of the domain to see which ones depend on it, so the number of objects also bounds that work. Raise the limit only for a domain that creates tables dynamically, for example one table per customer, and then watch the memory and the time of such statements. ## [rel] max_row_size Largest encoded row in bytes; the storage accepts values up to this or 512 KiB, whichever is larger. - Default: `524288` - Since: v0.1.0 ### Effect The largest encoded row, in bytes, that an `INSERT` or an `UPDATE` may write. The size is that of the row in its stored form, not the length of the SQL text. A statement that would write a larger row is refused with `400` and `row size 332 exceeds maximum of 200 bytes`; in a test of v0.5.1 with the key set to 200, a row with one `TEXT` value of 300 characters was encoded to 332 bytes. The same limit applies to the row endpoints and to rows imported from a file, where it is reported per row. The value must be at least 5 and must not exceed 100663296 bytes (96 MiB), the largest field that the recovery of the write-ahead log reads. The start is refused with `invalid config: rel.max_row_size (1) must be at least 5` or `invalid config: rel.max_row_size (…) exceeds the WAL recovery field cap (100663296 bytes) — writes this large could never be recovered`. The check runs even while `rel.enabled` is `false`. The engine's own value limit is the larger of 512 KiB and this key, because the catalog needs its room. A smaller value here therefore limits the rows but not the catalog, and a larger one raises the limit of the engine to the same size. Fixed limits apply as well: a `TEXT` value, including `KVREF` and `JSONREF`, is at most 64 KiB (`text length N exceeds maximum of 65536 bytes`), and a SQL statement is at most 64 KiB. A row of the default size of 512 KiB therefore needs several large values. ### Background A row is stored, read and compacted as one value, so the limit bounds the size of every single write into a table. Rows of 1,024 bytes or more go to the value log (`rel.vlog_path`). Large objects can live in a JSON document or a key-value entry and be linked from the row (`JSONREF`, `KVREF`), which keeps the rows small. Raise the limit only for rows that are large by nature. ## [rel] max_limit Most rows a query returns; a larger LIMIT is reduced to it. All result rows up to this limit are held in memory. - Default: `10000` - Since: v0.1.0 ### Effect The most rows that one `SELECT` returns. A `LIMIT` above the value is reduced to it, and a statement without `LIMIT` returns at most 1,000 rows or this value, whichever is smaller. When the cap cut the result, the answer says so with `"limit_applied": true`. In a test of v0.5.1 with the key set to 5 and ten rows in the table, `SELECT id FROM t LIMIT 100`, `SELECT id FROM t` and the row endpoint `GET …/rows?limit=100` each returned five rows with `limit_applied` true, and `LIMIT 3` returned three. `COUNT(*)` is not affected. A negative `LIMIT` or `OFFSET` is refused with `400`. The same cap applies to the browse endpoint of a table (`GET /store-api/rel/{domain}/tables/{table}/rows`). A response whose serialized size is above 32 MiB is refused with `413 Payload Too Large: response exceeds max_response_bytes; reduce LIMIT`, whatever this key says. All rows of a result are collected in memory before the answer is sent, so the memory per statement grows with the number of rows and their size. The value must be at least 1; `0` refuses the start with `invalid config: rel.max_limit (0) must be at least 1`. The check runs even while `rel.enabled` is `false`. ### Background The cap keeps one careless `SELECT` from loading a whole large table into memory and into a single response. Clients that need more rows page through the result with `LIMIT` and `OFFSET`; an `ORDER BY` that needs a sort buffer is bound by `rel.max_sort_rows` before the limit applies. Raise the cap if your clients read larger result sets in one request and the host has the memory; lower it to protect a small host. ## [rel] max_sort_rows Most rows an ORDER BY sorts or an unindexed join scans; more fail with 400. Rows up to this limit are held in memory while sorting. - Default: `100000` - Since: v0.1.0 ### Effect The most rows that the server collects in memory to sort a result, and the most rows that an unindexed join (`rel.allow_unindexed_joins`) may scan in one statement. An `ORDER BY` needs the sort buffer unless the order is free. It is free when a single column is sorted and the chosen access path already delivers the rows in that order: the primary key, or a `NOT NULL` column that has an index. Otherwise the server reads all rows that pass the `WHERE` clause into memory, sorts them, and only then applies `OFFSET` and `LIMIT`. If more rows than the limit pass, the statement fails with `400` and `sort buffer of 4 rows exceeds maximum of 3; narrow the result with WHERE/LIMIT or add a matching index`, which is the answer in a test of v0.5.1 with the key set to 3 and ten rows. A `LIMIT` does not help, because the sort comes first; a `WHERE` clause that matches fewer rows, or an index on the sorted column, does. For an unindexed join the key bounds the rows scanned in the right-hand table, counted over the whole statement: `unindexed join fallback scan visited 5 rows, exceeding the limit of 4; add an index or narrow the result`. The value must be at least 1; `0` refuses the start with `invalid config: rel.max_sort_rows (0) must be at least 1`. The check runs even while `rel.enabled` is `false`. ### Background The server sorts in memory and does not spill to disk, so the sort buffer is the memory cost of an unindexed `ORDER BY`: the rows are held decoded, and a wide row costs more than a narrow one. The cap turns a sort that would not fit into an error at a known size instead of a slow or failed server. Prefer an index on the columns you sort by; raise the cap only if you sort larger results regularly and the host has the memory for them. ## [rel] allow_unindexed_joins Lets a join on an unindexed column scan the table per row instead of failing with 400. - Default: `false` - Since: v0.1.0 ### Effect Decides what a `LEFT JOIN` does when the column of the joined table in its `ON` clause is neither the primary key nor indexed. With `false`, such a join is refused with `400` and a hint with the statement that fixes it, such as `join column 'u.tid' is neither the primary key nor indexed; CREATE INDEX ON u (tid)`. A join on a primary key or an indexed column looks up the matching rows directly. The check also applies when a view that contains such a join is created. With `true`, the server instead scans the joined table once for each row of the left side. The scan is bounded: all rows visited by such scans in one statement count together against `rel.max_sort_rows`, and a statement that exceeds it fails with `400` and `unindexed join fallback scan visited 5 rows, exceeding the limit of 4; add an index or narrow the result`. In a test of v0.5.1 with a left table of three rows and a right table of three rows, the join succeeded with the default cap and failed with the key set to 4. ### Background An unindexed join costs about the number of left rows times the number of right rows, so it is fast on tiny tables and slow on large ones. The default refuses it so that a missing index shows up as an error you can fix instead of as a statement that gets slower as the data grows. Switch it on for development or for tables that stay small, and create an index for anything else. ## [rel] import_body_limit_bytes Body-size cap for POST .../tables/from-file. - Default: `67108864` - Since: v0.4.0 ### Effect The largest request body, in bytes, that `POST /store-api/rel/{domain}/tables/from-file` accepts. The endpoint takes a CSV or TSV file and creates a table from it; the file is read into memory as a whole before the table is created. A larger body is refused with `413` and `Failed to buffer the request body: length limit exceeded`; in a test of v0.5.1 with the key set to 100, a file of 169 bytes was refused and one of 20 bytes created a table with four rows. The other relational endpoints take bodies of up to 2 MiB; the key does not change that. The import counts as one write of the rate limit of the domain (`rate_limit.default_write_iops`). Each row of the file then goes through the normal write path, so `rel.max_row_size` and `rel.lsm.max_key_length` apply to it; a row that fails is listed under `errors` in the `201` answer and does not stop the import. The server does not check the value at start. ### Background The limit exists because the body is held in memory while the file is parsed and imported, so several concurrent imports add up. The default of 64 MiB equals the limit for JSON bulk imports (`json.bulk_body_limit_bytes`). Lower it on a small host; for larger files, split them into several requests or raise the value. ## [rel.lsm] max_key_length Longest stored key in bytes; it bounds primary-key and index values. Raised at the start, with a warning, below 23 + domains.max_name_length. - Default: `256` - Since: v0.1.0 ### Effect The limit, in bytes, for the keys of the relational engine as the engine stores them. The engine stores a row under a key made of the prefix `ROW:`, an identifier of the domain, an identifier of the table and the encoded primary key, and an index entry under a key made of the prefix `IDX:`, the same identifiers, the indexed value and the primary key. A statement that would write a longer key is refused with `400` and `key length 108 exceeds maximum of 100 bytes`. In a test of v0.7.1 with the key set to 100, the primary key of the row was an ASCII `TEXT` value of 80 characters and the stored key was 108 bytes: the key was 28 bytes longer than the value. With the default of 256, an ASCII `TEXT` primary key of 228 characters was accepted and one of 229 characters was refused. An index lengthens the keys further, since each entry holds the indexed value and the primary key. `CREATE INDEX` on a table whose existing rows would make a key too long fails with the same message. The management keys of the engine hold the domain name, so the value must be at least 23 plus `domains.max_name_length`, 73 with the default. Since v0.7.0 a smaller value is raised to that at start, with a warning: in a test of v0.7.1, the value 10 started the server and logged `rel.lsm.max_key_length (10) is raised to 73, the least that takes domain names of domains.max_name_length (50) characters`. The value must not exceed 100663296 bytes (96 MiB), the largest field that the recovery of the write-ahead log reads; a larger one refuses the start with `invalid config: rel.lsm.max_key_length (…) exceeds the WAL recovery field cap (100663296 bytes) — writes this large could never be recovered`. Both happen even while `rel.enabled` is `false`. ### Background A key is stored in every MemTable entry, every write-ahead log record and every SSTable entry, so the length of the keys is paid for in memory and on disk. Keep the limit as small as your keys allow, and raise it if you use long `TEXT` columns as a primary key or an index. For the key-value engine and the JSON engine see `lsm.max_key_length` and `json.lsm.max_key_length`. ## [events] channel_capacity Events buffered per consumer; one this far behind gets `reset` (reason: lagged). At least 1. - Default: `256` - Since: v0.4.0 ### Effect The number of events that the server buffers for each client of the event stream `GET /store-api/events`. The stream is for admins and carries lifecycle and DDL events of all three engines: domains created, deleted and purged, relational table, view and index changes, and JSON index changes. It carries no data changes; the key-value watch of a domain (`lsm.wal_event_channel_capacity`) does that. Each event is a JSON object with `type`, `domain` and `ts`; the events of tables, views and indexes add `engine` and `object`. Since v0.7.0 a domain event comes once per domain and names no engine: in a test of v0.7.1, creating a domain sent `{"type":"domain_created","domain":"evt","ts":…}`, and creating a table in it `{"engine":"rel","type":"table_created","domain":"evt","object":"t","ts":…}`. A client that falls further behind than this number of events loses the events it did not read. It receives `event: reset` with the data `{"reason":"lagged"}` instead, and its id is the current head of the stream, so it can read the state again and continue from there. Writers are never held back by a slow client. With the default of 256, a client has to miss 256 DDL events before that happens. The value must be at least 1; `0` refuses the start with `invalid config: events.channel_capacity (0) must be at least 1`. The key does not change the size of the ring that serves reconnects, which is `events.replay_buffer_size`. ### Background Lifecycle and DDL events are rare compared with data writes, so a small buffer is normally enough. A burst can still produce many at once, for example when a backup is restored into many domains or a script creates hundreds of tables. Raise the value if clients regularly receive `reset` with the reason `lagged` during such bursts. The cost is memory for the buffered events, which hold names but no data. ## [events] replay_buffer_size Ring for Last-Event-ID resume; 0 = resume off. - Default: `1024` - Since: v0.4.0 ### Effect The number of the latest events of the stream `GET /store-api/events` that the server keeps so that a client can reconnect without a gap. Every event carries an `id:` of the form `g--`. A client that reconnects with the id of the last event it saw, in the `Last-Event-ID` header or in `?last_event_id=` (the header wins), receives the events it missed and then the live events. In a test of v0.5.1 with three domains created and a ring of 2, a reconnect with the id of the first event received the second and third event, a reconnect with the id of the second received the third, and a reconnect with the id of the third received nothing until the next event. When the ring cannot serve the id, the stream starts with `event: reset` and a reason: `window_exceeded` if the id is older than the oldest event in the ring, `restart` if the server has been restarted since the id was issued (the boot id differs), and `unknown_id` for an id that is not a valid id of this stream, such as `xyz`, or one from the future. After a `reset` the client should read the state again and then continue from the id in the `reset` event. With `0` the ring keeps nothing: every reconnect with an id receives `reset`, but events still carry ids. The ring lives in memory and is lost at a restart. It grows with the number of stored events up to the value; an event holds names, not data. ### Background A stream is a long-lived connection, and clients such as a browser's `EventSource` reconnect on their own and send the last id. The ring lets them continue without reading the state again after a short interruption. Lifecycle and DDL events are rare, so the default of 1,024 events covers long interruptions in most installations. Set `0` if every client reads the state again after a reconnect anyway. The key-value watch of a domain has a ring of its own (`lsm.watch_replay_buffer_size`). ## [log] level Level: verbose, info or prod (warnings and errors only); RUST_LOG overrides it. - Default: `"info"` - Since: v0.1.0 ### Effect The level of the messages that the server writes to its log: `verbose`, `info` or `prod`. `prod` writes warnings and errors only, `info` adds the normal operating messages (start, stop, shutdown, configuration, backup jobs), and `verbose` adds debugging messages. Internally the three values are the levels `warn`, `info` and `debug`; there is no `trace` level. Any other value refuses the start with a parse error of the configuration file that names the valid values. The level applies to the messages of LuraDB itself. Messages of the libraries it uses are not logged at any level. The level is the default of every module; `log.modules.auth`, `log.modules.api`, `log.modules.engine` and `log.modules.storage` can set their own. The environment variable `RUST_LOG`, if set, replaces the whole setting including the modules; the server then uses its value as the filter directive. Not every message goes through the level. The flush, compaction and value-log cleanup messages of the storage engines (lines that begin with `[Engine]` or `[Janitor]`) and a few error messages of the shutdown are written to standard error as they are, whatever the level, the format and `log.path` say. In a test of v0.5.1 with `prod`, a normal start wrote no line at all. ### Background At `info` a running server writes little: a start, a stop and the events of the background jobs. That is the level to keep in production. `prod` leaves the log empty for a healthy server, which makes every line a reason to look; use it where only problems matter. `verbose` adds, among others, one line for each request of the REST API with the client address (see `proxy.trusted_proxies`); turn it on for a module or for a short time to find a problem, not as a permanent setting. ## [log] format Line format: text or json. - Default: `"text"` - Since: v0.1.0 ### Effect The line format of the log: `text` or `json`. Any other value refuses the start with a parse error of the configuration file. In the `text` format a line is the time (UTC, with microseconds), the level, the module and the message, for example `2026-11-03T20:13:33.550752Z INFO luradb: Starting LuraDB...`. The lines carry ANSI colour escape sequences, also in log files and also when the output is not a terminal: in a test of v0.5.1, 16 lines of a log file contained them, and `GET /store-api/logs` returned them inside the strings of `lines`. In the `json` format each line is one JSON object, for example `{"timestamp":"2026-11-03T20:13:35.718804Z","level":"INFO","fields":{"message":"Starting LuraDB..."},"target":"luradb"}`, without escape sequences. The extra fields that a message carries, such as `admin` and `backup_id` in the audit lines of the backup API, are written into `fields` next to `message`. The format also tells `GET /store-api/logs` how the lines of a file are built: the answer repeats it in `format`, and the client has to parse the lines itself (`log.http_access`). Messages that the server writes straight to standard error (see `log.level`) are always plain text. ### Background Use `json` when a log shipper or a log database reads the log: the fields are separate and there are no colour codes to strip. Keep `text` for reading the log by eye. ## [log] path Directory for log files, created if missing. Not set: stdout only, which systemd hands to journald (journalctl -u luradb). - Default: not set - Since: v0.1.0 ### Effect The directory for the log files. Without the key, or with an empty value, the log goes to standard output, which systemd hands to the journal (`journalctl -u luradb`). With a path, the server writes its log to files in that directory instead and writes nothing to standard output: in a test of v0.5.1, the process output stayed empty. The directory is created at start, with its parents. The file is named `luradb.log` with a suffix that depends on `log.rotation`. A relative path resolves against the working directory of the server process (under the packaged service, `/var/lib/luradb`). If the directory cannot be created, the server does not start: in a test of v0.7.1 with a path under `/proc`, it exited with code 1 and `invalid config: log.path (/proc/luradb-logs) cannot be used: failed to create log directory: No such file or directory (os error 2)`. The path must not resolve to the same location as another data path; the start is refused with `invalid config: … resolve to the same location '…'` otherwise. Some lines never reach the file. The messages of the engines that begin with `[Engine]` or `[Janitor]`, the line that names the reason of a refused start (`Error: …`) and the configuration errors that are found before the log is set up go to standard error (see `log.level`); under systemd they are in the journal. The files are cleaned up by `log.retention_days`, and `log.http_access` serves them over the REST API. ### Background Under systemd the journal needs no setting of LuraDB: `log.rotation` and `log.retention_days` apply to files only. Use a path when you want plain files, for example for a log shipper that tails them or for `GET /store-api/logs`, or when the server does not run under systemd. The service account needs write access to the directory. ## [log] rotation Rotation of the log files: none, daily or hourly; needs a log path. - Default: `"daily"` - Since: v0.1.0 ### Effect When the server starts a new log file. `daily` starts one at midnight UTC, `hourly` at the full hour UTC. The files are named `luradb.log.` and `luradb.log.-`; in a test of v0.5.1 at 20:13 UTC, `daily` wrote `luradb.log.2026-11-03` and `hourly` wrote `luradb.log.2026-11-03-20`. Old files are not touched by the rotation; `log.retention_days` deletes them. `none` writes one file `luradb.log` that grows without bound. Since v0.7.0 any other value refuses the start with a parse error of the configuration file: in a test of v0.7.1, `weekly` was refused with ``unknown variant `weekly`, expected one of `none`, `daily`, `hourly` ``, together with the line number, although `log.path` was not set. Without a log path the key has no other effect. The file for the current period is chosen when the server writes its first line of that period, and the server appends to a file that already exists, so a restart within the period continues the same file. ### Background Daily rotation suits most installations: a file is one day of log, and removing old days is a matter of `log.retention_days`. Choose `hourly` when a day of log is too large to handle, for example on a server with `log.level` set to `verbose`. Choose `none` only if an external tool rotates the file. ## [log] retention_days Days to keep rotated log files; 0 keeps them forever. - Default: `30` - Since: v0.1.0 ### Effect The age, in days, after which the server deletes a log file. A background task looks at the log directory (`log.path`) and deletes every file whose name begins with `luradb.log` and whose last modification is more than this many days ago. Other files in the directory are left alone. With `0` nothing is deleted. The task runs only when a log path is set and the value is above 0. It does not run at start: its first pass comes 24 hours after the process started, and then it repeats every 24 hours of running time. A server that is restarted more often than once a day therefore never deletes anything. The age is the modification time, not the date in the file name, so the file of the current period is never old enough while the server writes to it; with `log.rotation` set to `none` the single file is never deleted. The key has no effect when the log goes to standard output. ### Background Rotated files accumulate unless something deletes them. The task deletes by age only, with no regard to the number or the size of the files, so choose the age from the amount of log that your `log.level` and rotation produce and from the space of the volume. Lower the value on a small volume, raise it if you have to keep logs longer, and use `0` if an external tool manages the files. A server that is restarted daily needs such a tool, because the first pass comes only after a day of running time. ## [log] http_access Serves GET /store-api/logs and /store-api/logs/files; needs a log path. - Default: `false` - Since: v0.3.0 ### Effect With `true`, two admin-only endpoints expose the log files over the REST API. `GET /store-api/logs/files` lists the files `luradb.log*` of `log.path`, newest first, with their size and modification time. `GET /store-api/logs` returns the last lines of one file, oldest line first, as `{"file", "format", "lines", "truncated"}`: the parameter `lines` sets how many (default 100, at most 1,000; `0` is refused with `400`), `q` keeps only lines that contain the text (case-sensitive; only matching lines count toward `lines`), and `file` names a file from the list (default: the newest). A file name must begin with `luradb.log` and contain no path separator, and only regular files are read, so a link is not followed. The server scans at most 4 MiB from the end of the file; if that was not enough for the lines asked for, `truncated` is `true`. A non-admin key gets `403`. With `false` both endpoints answer `503 Service Unavailable: log access is disabled (log.http_access = false)`. With `true` and no `log.path`, the start is refused with `invalid config: log.http_access requires log.path`, since the standard output cannot be read back. With `auth.enabled` off, the start logs a warning that any client that reaches the port can read the log files. The lines are returned as they are in the file. In the `text` format (`log.format`) they contain colour escape sequences. ### Background The endpoints let a monitoring tool or an operator read the recent log without a login on the host, for example from a browser or from a script. They give access to everything the server logs, including the names of domains, admins and backups, which is why they are admin-only and off by default. They are a tail, not a log search: a request returns at most 1,000 lines from the last 4 MiB of one file. For more, read the files or use a log shipper. ## [log.modules] auth Level of the authentication module. - Default: not set - Since: v0.1.0 ### Effect The log level of the authentication module, `luradb::auth`, in place of `log.level`. The values are the same as for the global level: `verbose`, `info` or `prod`. Without the key the module follows the global level. Any other value refuses the start with a parse error of the configuration file. The module covers accounts, API keys, permissions and the OAuth records of the MCP server. In v0.5.1 it writes only three messages, all about the admin accounts of the configuration file at start: `Auth: admin '' reconciled` and `Auth: removed stale admin ''` at `info`, and `Auth is enabled but no admins are configured in luradb.toml` at `warn`. A rejected key (`401`) or a missing permission (`403`) is not logged by this module. The sign-in page of the MCP server belongs to the module `luradb::mcp`, which has no setting of its own and follows `log.level`. The environment variable `RUST_LOG`, if set, replaces all of these settings. ### Background Set the key to quieten or to widen this module alone. In v0.5.1 there is little to widen, so the key matters only to keep the three start-up lines out of the log (`prod`) while the rest of the server logs at `info`. ## [log.modules] api Level of the REST API. - Default: not set - Since: v0.1.0 ### Effect The log level of the REST API, `luradb::api`, in place of `log.level`. The values are the same as for the global level: `verbose`, `info` or `prod`. Without the key the module follows the global level. Any other value refuses the start with a parse error of the configuration file. The module covers the handlers of the REST endpoints and the layer that resolves the client address. In v0.5.1 it writes two kinds of messages. At `verbose` (`debug`) every request of the REST API produces one line, `request client_ip=
peer_ip=
`, which shows the address the server uses for the client and the address of the connection; with the key set to `verbose` and `proxy.trusted_proxies` set, it is how you check what a proxy passes on. At `info`, the backup endpoints write an audit line for each action with the admin's name and the backup id (`backup created admin=admin backup_id=bk_…`), and at `error` an internal error of the backup API with its cause. Requests that fail with a status code are not logged here. The environment variable `RUST_LOG`, if set, replaces all of these settings. ### Background Use `verbose` on this module to see the client addresses of requests, for example when you set up a reverse proxy, without turning on debugging for the whole server. Leave the module at `info` if you want the audit lines of the backup API in the log; `prod` suppresses them. ## [log.modules] engine Level of the storage engines, including the domain registry. - Default: not set - Since: v0.1.0 ### Effect The log level of the storage engines, `luradb::engines`, in place of `log.level`. The values are the same as for the global level: `verbose`, `info` or `prod`. Without the key the module follows the global level. Any other value refuses the start with a parse error of the configuration file. The module covers the key-value engine with its domain registry, the JSON engine and the relational engine. What it writes in v0.5.1 are the messages of the background jobs and of the recovery of metadata, for example `[JsonDomainPurger] domain '…' fully purged` and `[RelDomainPurger] domain '…' fully purged` at `info`; warnings such as `Compaction of level 0 waits for disk space: …`, `Value log cleanup waits for disk space: …`, `[reindex] skipping corrupt document '…'`, `[bulk_export] unparseable doc key …` and `[RelCatalog] cannot deserialize catalog entry …`; and debugging lines of the sweeper of expired keys at `debug`. Many messages of the engines do not belong to the module even though they come from the same code: the flush, compaction and value-log cleanup messages that begin with `[Engine]` or `[Janitor]` are written to standard error without a level (see `log.level`). The environment variable `RUST_LOG`, if set, replaces all of these settings. ### Background The engines log about their background jobs and about the recovery of their metadata. Set this key to make only the engines verbose while everything else stays at `info`, or to keep their warnings about disk space and corrupt data at `info` or `prod` while the global level is `verbose` for another reason. The packaged file shows `engine = "prod"` as a commented example. ## [log.modules] storage Level of the file layer (SSTables, value log, manifest). - Default: not set - Since: v0.1.0 ### Effect The log level of the file layer, `luradb::storage`, in place of `log.level`. The values are the same as for the global level: `verbose`, `info` or `prod`. Without the key the module follows the global level. Any other value refuses the start with a parse error of the configuration file. The module covers the file layer: the SSTable files, the manifest that lists them, the value log and the file manager. In v0.5.1 it writes a handful of messages: `Removed N temporary files left in …` at `info` when a start finds temporary files in an SSTable directory and removes them, `cannot delete …` at `warn` when a replaced file could not be removed, debugging lines about the manifest and about `madvise` at `debug`, and the `error` line `data sync failed on : …; stopping so the next start recovers from the write-ahead log` (or `data write failed …`) that the server writes before it stops with exit code 3 because the disk failed to make data durable. That last line is an error, so the module's level `prod` still lets it through. The write-ahead log and the storage thread belong to `luradb::core`, which has no setting of its own and follows `log.level`. The environment variable `RUST_LOG`, if set, replaces all of these settings. ### Background The file layer is quiet unless something goes wrong with the files. Set the key to `verbose` to see the manifest updates when you look into the lifecycle of SSTables, or leave it at `prod` (the packaged file shows `storage = "prod"` as a commented example) to keep the module's messages down to warnings and errors while another module is verbose. ## [proxy] trusted_proxies Reverse proxies (IPs or CIDR ranges) whose X-Real-IP and X-Forwarded-For headers are trusted. - Default: `[]` (direct access, headers ignored) - Packaged value: `["127.0.0.1", "::1"]` - Since: v0.1.0 ### Effect A list of IP addresses or CIDR ranges (`"203.0.113.7"`, `"10.0.0.0/8"`, `"2001:db8::/32"`) of reverse proxies whose headers the server believes. When a TCP connection comes from an address in the list, the server takes the address of the client from the request headers; for every other connection it uses the address of the connection itself and ignores the headers. The list is empty by default in the code, so the headers are ignored; the packaged file lists `127.0.0.1` and `::1`. A value that does not parse refuses the start, late in the start sequence, with `Invalid trusted_proxies config: invalid IP address syntax`. The client address is resolved like this: the header `X-Real-IP` wins if it holds a valid address. Otherwise the server reads `X-Forwarded-For` from the right and takes the first address that is not private. Private are the loopback addresses, `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `169.254.0.0/16`, `fc00::/7` and `fe80::/10`. If nothing yields an address, the address of the connection stays. In a test of v0.5.1 with `127.0.0.1` listed, `X-Real-IP: 203.0.113.9` gave the client `203.0.113.9`; `X-Forwarded-For: 203.0.113.50, 198.51.100.7, 10.1.2.3` gave `198.51.100.7`; a list of private addresses only gave `127.0.0.1`. In v0.5.1 the resolved address is used in two places. It is shown in the debug line of the REST API (see `log.modules.api`), and it is the key of the two limits of the sign-in of the MCP server (`mcp.oauth_enabled`): five failed sign-ins within 15 minutes and ten client registrations within an hour per sender, where an IPv6 sender counts by its /64 prefix. The list grants no access and does not change the rate limits of the domains (`rate_limit.default_read_iops`), which count per domain. In the same test with `127.0.0.1` not listed, a sender that sent five wrong keys blocked a second sender with a different `X-Real-IP`; with it listed, the second sender was not blocked. ### Background Behind a reverse proxy every connection arrives from the proxy, so without this list all clients share one address: five wrong keys from anyone lock the OAuth sign-in for everyone for 15 minutes. List the addresses of your proxies, and only those. A client address in the list would let that client choose the address the server believes. Leave the list empty for a server that clients reach directly. ## [cors] enabled Cross-origin access for browser clients. Off by default. - Default: `false` - Since: v0.4.0 ### Effect With `true`, the server answers cross-origin requests of browsers on the REST API according to `cors.allowed_origins`. It adds a CORS layer in front of everything the REST listeners serve: the HTTP, HTTPS and Unix-socket listeners, the Swagger UI and the root route. The layer sits outside the authentication, so a `401` carries the CORS headers too, and a browser can read it. The MCP listener does not use this layer; it has its own list, `mcp.allowed_origins`. The layer answers the preflight request (`OPTIONS` with `Origin` and `Access-Control-Request-Method`) itself, with `200` and these fixed headers: `Access-Control-Allow-Methods: GET,HEAD,POST,PUT,PATCH,DELETE`, `Access-Control-Allow-Headers: authorization,content-type,if-match,if-none-match,last-event-id` and `Access-Control-Max-Age: 3600`. On the real responses it adds `Access-Control-Expose-Headers: etag,x-expires-at`, so a script can read the `ETag` for conditional writes and the expiry of a key. Methods, headers and max age are not configurable. For an origin in the list the response carries `Access-Control-Allow-Origin` with that origin; for any other origin it carries none, and the browser blocks the script from reading the response (the server still processes the request). The server does not set `Access-Control-Allow-Credentials`; the API key travels in the `Authorization` header, which is allowed. With `false`, no CORS layer exists and no response carries a CORS header. With `true` and an empty `cors.allowed_origins`, the start is refused with `invalid config: cors.enabled = true but cors.allowed_origins is empty — no origin would ever be allowed`. While the key is `false`, the list is not checked. ### Background Browsers forbid a script of one origin from reading the responses of another unless the server agrees. A single-page application on `https://console.example.com` that calls the API on another host needs this key. CORS is a rule that browsers enforce for their scripts; it is no access control for other clients, which ignore it, and the API key is still required for every request. ## [cors] allowed_origins Exact origins, e.g. ["https://console.example.com", "http://localhost:5173"]. - Default: `[]` - Since: v0.4.0 ### Effect The origins that may read the responses of the REST API from a browser script. An origin is written as a browser sends it in the `Origin` header: scheme, host and, if it is not the default of the scheme, the port, for example `https://console.example.com` or `http://localhost:5173`. The server compares the whole value, byte by byte, with the request's `Origin` header. `http://localhost:5173` and `http://localhost` are two origins, and a different port, scheme or letter case is another origin. Each entry is checked at start, but only while `cors.enabled` is `true`. An entry must have the form `scheme://host[:port]` in lower case, without user name, path, query or fragment; otherwise the start is refused with `invalid config: cors.allowed_origins entry 'https://a.example.com/' is not a valid origin — expected exactly scheme://host[:port] (lowercase, no userinfo/path/query/fragment)`. A trailing slash, a capital letter and a missing scheme are all rejected this way. The single entry `"*"` allows every origin. The server then sends `Access-Control-Allow-Origin: *` on every response, including those to requests without an `Origin` header, and logs a warning at start. Combined with other entries, `"*"` refuses the start with `invalid config: cors.allowed_origins mixes the wildcard "*" with concrete origins — "*" must be the only entry`. ### Background List the origins of the web applications that you operate and nothing else. The wildcard does not open the API to anyone by itself, since the API key is still required for every request, but it lets a script on any website read the responses once that script has a key. Use it for tests only. ## [mcp] enabled Starts the MCP listener. Off by default. - Default: `false` - Since: v0.5.1 ### Effect With `true`, the server starts a second listener for the Model Context Protocol (MCP), the open protocol that assistants, agents and programs use to call tools and read resources. It listens on `server.bind_address` at `mcp.port`, serves the endpoint `/mcp` with the Streamable HTTP transport, and logs `MCP listening on http://127.0.0.1:3100/mcp`. The listener runs on one worker thread of its own, so its clients take no frontend worker. When `server.tls_enabled` is on, the MCP listener uses the same certificate and serves HTTPS only: in a test of v0.5.1, `https://…/mcp` answered and plain `http://…/mcp` did not connect. The server has a catalog of 26 tools and offers a part of it, depending on `mcp.read_only` and `mcp.allow_ddl`. It also offers two resources: `luradb://domains` and the template `luradb://{engine}/{name}/schema`. A tool adds no behavior of its own. Each call becomes the REST requests that do the work, run through the same layers with the caller's `Authorization` header, so the rights of the API key apply: MCP never gives more than the same key gives over REST. Two tools, `metrics` and `create_domain`, use admin-only routes and are listed for admin keys only. With `auth.enabled` on, every request to `/mcp` needs `Authorization: Bearer `: an API key, or an OAuth access token if `mcp.oauth_enabled` is on. A request without it gets `401` with `WWW-Authenticate: Bearer`, and one with an unknown key gets `401` with `WWW-Authenticate: Bearer error="invalid_token"`. With authentication off, every client that reaches the port has full access, and the server warns at start: `mcp.enabled is true and auth.enabled is false — any client that reaches the MCP port has full access`. A request body is limited to 4 MiB, and the result of a tool or a resource to 1 MiB; a larger result comes back as a tool error that tells the client to reduce the `limit` or narrow the request. Browser clients are admitted by `mcp.allowed_origins`; the `Host` header is not checked. ### Background MCP lets a client that speaks the protocol use LuraDB without a client library: it lists the tools, reads the schema of a domain and runs queries. The listener is separate from the REST ports, so you can expose, firewall and switch it on its own, and it is off by default. Keep authentication on, and put TLS in front of the listener, before you reach it from beyond the host. ## [mcp] port Port of the MCP listener on server.bind_address; must differ from the REST ports. - Default: `3100` - Since: v0.5.1 ### Effect The TCP port of the MCP listener, on the address of `server.bind_address`. It has to differ from the ports of the REST listeners that are on: `server.port` while `server.http_enabled` is `true`, and `server.tls_port` while `server.tls_enabled` is `true`. A clash refuses the start with `invalid config: mcp.port (3820) must differ from server.port`. The check runs only while `mcp.enabled` is `true`; with the listener off, the value is not used. The port `0` is accepted and lets the operating system pick a free port, which the start log shows (`MCP listening on …`). A port that another process already uses stops the start: in a test of v0.5.1 the server exited with `Error: Address already in use (os error 98)`. The value is a port number from 0 to 65535; a larger number or text refuses the start with a parse error of the configuration file. A reverse proxy or a client that reaches the listener from another host connects to this port, or to the port the proxy exposes for it (see `mcp.public_url`). ### Background The listener has a port of its own so that the MCP endpoint can be exposed, firewalled and proxied separately from the REST API. Change the value only for a clash with another service or for a convention of your network. ## [mcp] read_only Offers only the tools that read; set to false to also offer the tools that write keys, documents and rows. - Default: `true` - Since: v0.5.1 ### Effect With `true`, the MCP server offers the 17 tools that only read: `whoami`, `list_domains`, `describe_domain`, `metrics` (admin keys only), `list_tables`, `describe_table`, `list_views`, `list_json_indexes`, `health`, `kv_get`, `kv_scan`, `kv_count`, `json_get`, `json_list`, `json_search`, `json_count` and `sql_query`. `sql_query` runs one `SELECT` and refuses every other statement. The tools are marked as read-only in their annotations. With `false`, six tools are added that change data: `kv_put`, `kv_delete`, `kv_set_null`, `json_put`, `json_delete` and `sql_execute`, which runs one `INSERT`, `UPDATE` or `DELETE`. They are marked as destructive. In a test of v0.5.1, the listing had 17 tools with `true` and 23 with `false`. A tool that is not offered is not only hidden: calling it returns the error `tool '…' is not available`. A statement sent to the wrong SQL tool is refused with a hint, for example `this statement does not belong to this tool; use sql_query`. The switch narrows what MCP offers; it does not widen the rights of a key. A write needs both the tool and a key with the permission to write the domain, and the rate limits and the other limits of the REST API apply to every call. The tools that create structure are switched by `mcp.allow_ddl`, and only when this key is `false`. No tool deletes a domain, a table, a view or an index. ### Background An assistant or an agent that explores data can do harm with a wrong or a manipulated instruction. With `true`, no MCP tool can change data, whatever the client sends and whatever key it holds. That is the setting for a server that is queried, not edited, through MCP. Switch to `false` only for clients you trust with writes, and give them a key that holds a permission on the domains they need and nothing more. ## [mcp] allow_ddl Also offers the tools that create domains, tables, views and indexes; only with read_only = false. No tool deletes a domain, table, view or index. - Default: `false` - Since: v0.5.1 ### Effect Adds the three tools that create structure to what the MCP server offers: `create_domain` (a domain, which holds keys, documents and tables alike; admin keys only), `create_json_index` (an index on a field of the documents of a domain) and `sql_ddl`, which runs one `CREATE TABLE`, `CREATE INDEX`, `CREATE VIEW` or `ALTER TABLE … ADD COLUMN`, `RENAME COLUMN` or `RENAME TO`. They are marked as not read-only; `sql_ddl` is marked as destructive, since a rename breaks clients as a drop would. In a test of v0.7.1 with both keys set, the listing had 26 tools, three more than with `mcp.read_only` alone set to `false`. No tool drops anything. `sql_ddl` refuses `DROP TABLE`, `DROP INDEX`, `DROP VIEW` and `ALTER TABLE … DROP COLUMN` before they reach the SQL route, with `dropping a table, an index or a view is not available over MCP` or `dropping a column is not available over MCP`, whatever the permission of the key. Deleting a domain, an index or a table needs the REST API. The key has an effect only while `mcp.read_only` is `false`. With `read_only` still `true`, the server starts and logs the warning `mcp.allow_ddl has no effect while mcp.read_only is true`. The rights of the key apply as for every call: `sql_ddl` needs the `Ddl` permission on the domain, and `create_domain` an admin key. ### Background Structure changes are a different risk from data changes: a new table or a renamed column changes what other clients see. The switch lets you allow an assistant to write rows without letting it change the schema, which is why it is off by default even for a server with `read_only = false`. Switch it on for development or for a controlled setup where the assistant builds tables, and keep the rights of its key narrow. ## [mcp] allowed_origins Origins a browser-based MCP client may send, e.g. ["https://app.example.com"]. A request with any other Origin header is refused; requests without one pass. - Default: `[]` - Since: v0.5.1 ### Effect The origins that a browser-based MCP client may send in the `Origin` header of a request to `/mcp`. Browsers add this header to requests from a web page; programs and desktop clients usually do not. A request without an `Origin` header passes the check. A request with an `Origin` that is not exactly in the list is refused with `403` and `Forbidden: Origin is not allowed`, whatever its credentials, including `Origin: null`. The comparison is by bytes: the scheme, the host and a non-default port must match as written. With the default empty list, every request that carries an `Origin` header is refused. Each entry must have the form `scheme://host[:port]` in lower case, without user name, path, query or fragment. Unlike `cors.allowed_origins`, the wildcard is not allowed. An entry that breaks the form refuses the start with `invalid config: mcp.allowed_origins entry 'https://App.example.com' is not a valid origin — expected exactly scheme://host[:port] (lowercase, no wildcard)`. The check runs only while `mcp.enabled` is `true`. The list guards the endpoint `/mcp`. The OAuth endpoints (`mcp.oauth_enabled`) are not behind it; the sign-in form checks its own `Origin` against `mcp.public_url`. The MCP listener sends no CORS headers, since it does not use the CORS layer of `cors.enabled`; a proxy in front of it has to add them for a browser client of another origin. In a test of v0.5.1 with `https://app.example.com` in the list, a request from that origin passed the check and one from `https://other.example.com` got `403`. ### Background A web page that a user opens can send requests to a service on `localhost` or on the local network, including by DNS rebinding, where the page's own host name is made to point at that service. The check refuses pages that the operator did not name. Programs and desktop clients do not send an `Origin` and are not affected, so the default of an empty list serves them. Add an origin only for a web application that you operate and that talks to MCP from the browser. ## [mcp] oauth_enabled Lets MCP clients that only support OAuth sign in once on a LuraDB page with their API key. Needs auth.enabled = true and public_url. - Default: `false` - Since: v0.5.1 ### Effect With `true`, the MCP listener can sign in clients with OAuth, with LuraDB itself as the authorization server, so that a client which supports only OAuth needs no API key in its configuration. The user signs in once on a LuraDB page with an API key; the client never sees that key. The start requires `auth.enabled` and `mcp.public_url`, and is refused with `invalid config: mcp.oauth_enabled = true requires auth.enabled = true` or `invalid config: mcp.oauth_enabled = true requires mcp.public_url` otherwise. With `false`, clients send an API key as a Bearer token, and the OAuth endpoints do not exist. The endpoints, all on the MCP port: `/.well-known/oauth-protected-resource` and `/.well-known/oauth-authorization-server` (metadata, RFC 9728 and RFC 8414), `/oauth/register` (dynamic client registration, RFC 7591), `/oauth/authorize` (the sign-in page), `/oauth/token` and `/oauth/revoke`. Only public clients register (`token_endpoint_auth_method` `none`), and only the authorization code flow with PKCE `S256` is offered, so a client needs no secret. A registration needs a `client_name` of at most 100 characters and one to ten redirect URIs of at most 2,048 characters each that are `https://`, or `http://` on `localhost`, `127.0.0.1` or `::1`. A client that never signs in is forgotten after 24 hours. The flow, as seen in a test of v0.5.1: a request to `/mcp` without a token gets `401` and `WWW-Authenticate: Bearer resource_metadata="/.well-known/oauth-protected-resource"`. The client reads the metadata, registers, and sends the user to the sign-in page, which shows the client's name and the host the user is sent back to, and asks for an API key. After `Allow access`, the browser is redirected to the client's redirect URI with a one-time code (valid for 60 seconds), which the client exchanges at `/oauth/token` for an access token (`lura_at_…`, valid for 3,600 seconds) and a refresh token (`lura_rt_…`, valid for 30 days). Each use of a refresh token returns a new pair. Using a code or a refresh token a second time revokes the whole grant. An access token is valid on the MCP listener only: the REST API answered `401` to it. A token carries no rights of its own. It stands for the account and the API key hash of the sign-in, and it stops working when that account is deleted, its key is rotated, or `mcp.public_url` changes. In a test, after the key of the account was rotated, the access token got `401` and the refresh token was refused with `the user or its API key changed`. The rights are those of the account, as for an API key. The sign-in form must be sent from the origin of `public_url`: a request with another or no `Origin` gets `403`. Five failed sign-ins from one sender within 15 minutes block that sender with `429 Too many failed sign-ins; try again later`, and ten client registrations per hour and sender are allowed; the sender is the client address as resolved with `proxy.trusted_proxies`, an IPv6 sender counted by its /64 prefix. The records of clients, codes and tokens live in the system store, and expired ones are removed by the sweeper of `ttl_sweeper.enabled`. ### Background Some MCP clients can authenticate only through OAuth and offer no field for a Bearer token. OAuth also keeps the API key out of their configuration files: the user types it into a LuraDB page, and the client holds a token that is limited to MCP, expires within an hour and can be revoked. Clients that can send a Bearer header need none of this and can use an API key. Switch OAuth on only for the clients that need it. ## [mcp] public_url Public base URL of the MCP listener as clients reach it, e.g. "https://db.example.com:3100" or the address of a reverse proxy; https:// is required unless the host is localhost, 127.0.0.1 or ::1. OAuth tokens are bound to it: changing it makes OAuth clients sign in again. Behind a proxy under a path, e.g. "https://db.example.com/luradb", the proxy must also pass /.well-known/oauth-authorization-server/luradb and /.well-known/oauth-protected-resource/luradb/mcp to the listener unchanged, without stripping /luradb: OAuth clients look for the metadata there. - Default: `""` - Since: v0.5.1 ### Effect The base URL under which MCP clients reach the listener, as they see it: the scheme, the host, the port if it is not the default, and optionally a path, for example `https://db.example.com:3100` or, behind a reverse proxy, `https://db.example.com/luradb`. It is used only with `mcp.oauth_enabled`, where it is the issuer of the OAuth tokens and the base of every address in the metadata the server publishes. With OAuth off, the value is ignored and not checked. With OAuth on, the value is checked at start. It must be an absolute `http://` or `https://` URL with a host and no query, fragment or user name; anything else refuses the start with `invalid config: mcp.public_url 'example.com' is not an absolute http(s) URL`. Plain `http://` is accepted only for the hosts `localhost`, `127.0.0.1` and `::1`; otherwise the start is refused with `invalid config: mcp.public_url 'http://example.com' must use https:// unless its host is localhost, 127.0.0.1 or ::1`. A trailing slash is dropped. An empty value refuses the start with `invalid config: mcp.oauth_enabled = true requires mcp.public_url`. The tokens are bound to the address `/mcp`, the resource. Changing the value therefore invalidates the issued tokens, and clients sign in again. The metadata documents list the endpoints below the URL: for `http://127.0.0.1:3821` the issuer is that URL, the sign-in page `…/oauth/authorize`, the token endpoint `…/oauth/token`, the registration endpoint `…/oauth/register` and the revocation endpoint `…/oauth/revoke`. A `401` from `/mcp` points to `/.well-known/oauth-protected-resource`. The sign-in form accepts a request only from the origin of the URL (scheme, host and port in lower case, without the default port of the scheme). If the URL has a path, a client looks for the metadata below `/.well-known/` with the path appended, as RFC 8414 and RFC 9728 define. In a test with `http://127.0.0.1:3821/luradb/`, the server answered `/.well-known/oauth-authorization-server/luradb` and `/.well-known/oauth-protected-resource/luradb/mcp`, and answered `404` for `/.well-known/oauth-protected-resource/luradb`. The listener itself serves its endpoints at its root, `/mcp` and `/oauth/…`, and not below the path. A reverse proxy that publishes the listener under `/luradb` must therefore strip the prefix `/luradb` from the other paths, and pass the two well-known paths to the listener unchanged, with `/luradb` still in them. ### Background The listener cannot know the name under which clients reach it: it may sit behind a proxy, a load balancer or a port mapping, and the clients need absolute addresses in the metadata, in the redirects and in the check of the sign-in form. The operator states that name once. Use `https` outside tests, since the sign-in page takes an API key and the tokens are bearer tokens. ## [shm] enabled Publishes read snapshots in shared memory. Warning: members of the luradb group can read all data via SHM without an API key. - Default: `false` - Since: v0.1.0 ### Effect With `true`, the server publishes a read copy of the key-value data in POSIX shared memory for local clients, and lets local clients register for a command channel. At start it creates three segments in `/dev/shm`, named after `shm.instance_id`: `luradb__state` (4 KiB) and the two data segments `luradb__data_a` and `luradb__data_b` (`shm.data_buffer_size` each), plus a lock file `luradb_.lock`. A publisher builds a snapshot of the keys of all active domains into the data segment that is not in use and then switches to it (`shm.snapshot_interval_ms`), so a client reads the current snapshot with plain memory reads. The snapshot holds the keys, the values that are stored inline, the expiry times and the NULL state. The value of a key that lives in the value log is only marked, and the client fetches it over its command channel. JSON and relational data are not part of it. A client registers at `shm.registration_socket_path` and gets a channel of its own: a command ring and a response ring of 4 MiB each, through which it can get, put, delete, set to null and list keys. The segments of a client are removed when it disconnects; in a test, the four segments of a client existed while it was connected and were gone a second after it closed the socket. The access control is that of the operating system. The code asks for the mode `0660` and the umask of the process applies: in a test with a umask of `022` the segments had the mode `0640`, and the packaged service (`UMask=0027`) gives `0640` as well. The owner can write them and the group of the server can read them, so every process in that group can map the data segments and read all key-value data without an API key and without any permission of a domain. The command channel carries no API key either. A command names a domain, and no permission is checked; the only gate is the registration. With `auth.enabled` on, only the user IDs of `auth.trusted_uids` may register (`ERR unauthorized` for any other); with it off, anyone who can open the registration socket may. A second server with the same instance id on the same host is refused at start with `SHM instance '…' is already in use by another running process`. Segments that a crash of the same id left behind are removed at start with a warning, and a clean stop removes them. If the setup fails, for example because the directory of the registration socket cannot be created, the start stops. The three data buffers count toward the fixed memory that the server compares with `resources.memory_budget`. The block `shm` of `GET /store-api/metrics` counts the publishes, the skipped publishes and the clients that were disconnected. ### Background Shared memory gives a client on the same host reads without HTTP: no connection and no request parsing. The price is that the operating system, not LuraDB, decides who may read. Enable it only on a host where every process of the group `luradb` may read all key-value data, and run clients under dedicated service accounts. Leave it off otherwise; the REST API, also over the Unix socket of `server.unix_socket_path`, is the interface that checks keys and permissions. ## [shm] instance_id Name suffix of the shared-memory segments, so several servers can share a host ([A-Za-z0-9-]). - Default: `"0"` - Since: v0.1.0 ### Effect The name that makes the shared-memory objects of one server distinct on a host. It becomes part of the names of the segments (`/dev/shm/luradb__state`, `…_data_a`, `…_data_b`, and `…_cmd_` and `…_resp_` per client), of the lock file `/dev/shm/luradb_.lock`, and replaces `{instance_id}` in `shm.registration_socket_path`. The value must not be empty and may contain only the characters `A-Z`, `a-z`, `0-9` and `-`; the underscore is not allowed. Anything else refuses the start with `invalid config: shm.instance_id ('a_b') must be non-empty and contain only [A-Za-z0-9-]`. The value is checked even while `shm.enabled` is `false`. Two running servers on one host must have different ids. The lock file holds an exclusive lock for as long as the server runs, and a second server with the same id is refused with `SHM instance '0' is already in use by another running process`. The lock disappears with the process, so a crash does not block the next start. ### Background Segment names live in one namespace for the whole host. The id lets several servers, such as a production instance and a test instance, share a host without touching each other's segments. The underscore is excluded because the server finds the leftovers of a crash by the name prefix `luradb__`: with an underscore allowed, the id `0` would match the segments of an instance `0_backup`. Change the default only when you run more than one instance with shared memory on a host. ## [shm] data_buffer_size Size in bytes of each shared-memory data segment. Two segments of this size plus one copy per rebuild are held in memory. - Default: `268435456` - Since: v0.1.0 ### Effect The size, in bytes, of each of the two data segments in which the server publishes its snapshot of the key-value data. The server alternates between the two: it writes a new snapshot into the one that is not being read and then switches. The value must be at least 4096; smaller values refuse the start with `invalid config: shm.data_buffer_size (100) must be at least 4096`. The check runs even while `shm.enabled` is `false`. The snapshot holds, for every active domain in the order of the domain names, the keys, the inline values and an overhead of 64 bytes per entry. The server fills it only up to 7/8 of this size. When the data does not fit, the snapshot ends in the middle of a domain and leaves out the domains after it. The snapshot is published that way and the server logs a warning, `SHM snapshot truncated in domain '…' (N later domain(s) omitted): accumulated size exceeded budget of … bytes (buffer …)`. A client then sees only part of the data. If the serialized snapshot is still too large for the segment, the publish fails and the server logs `SHM snapshot publish failed: …`. The segments are created at their full size, but the server does not fill them; pages become resident as the snapshot is written. The server counts three buffers (the two segments and the copy made while a snapshot is rebuilt) toward its fixed memory (`resources.memory_budget`). The 4 MiB rings of each registered client come on top and do not depend on this key. ### Background The snapshot has to hold all inline key-value data that clients want to read, so size the buffer from your data: the sum of keys and inline values (`lsm.vlog_inline_threshold`) over all domains, plus 64 bytes per key, with a margin of one eighth and room to grow. The default of 256 MiB is a ceiling, not an allocation. Raise it if the warning about a truncated snapshot appears; lower it to cap the memory that shared memory may use. ## [shm] registration_socket_path Unix socket where SHM clients register; {instance_id} is replaced. It must differ from the Unix socket of the server section. - Default: `"/run/luradb/{instance_id}.sock"` - Since: v0.1.0 ### Effect The Unix socket at which local clients register for shared memory. The text `{instance_id}` in the path is replaced by `shm.instance_id`; with the defaults the socket is `/run/luradb/0.sock`. A client connects, sends the line `REGISTER`, and receives `OK ` with the write end of a pipe attached (to wake the server after a command), or `ERR unauthorized`. The socket stays open as the sign of life of the client: when it closes, the server removes the segments of the client. With `auth.enabled` on, only a process whose user ID is in `auth.trusted_uids` is accepted; the server reads the user ID from the connection, so a client cannot claim another one. In a test of v0.5.1, a process that was not listed got `ERR unauthorized` and a listed one got `OK 1 /luradb__cmd_1 …` with the four segment names of its channel. With authentication off, every process that can open the socket may register. The server creates the socket with the mode `0660` when it starts, replaces a socket file left by an earlier run, and removes it when it stops. Unlike the socket of `server.unix_socket_path`, whose directory must exist, it creates the missing directory of this path; if that fails, the start stops with `Error: create registration socket directory /run/luradb`. The path must differ from the REST socket: the start is refused with `invalid config: shm.registration_socket_path ('…') equals server.unix_socket_path — SHM clients could not register; use a different path`. The check runs only while `shm.enabled` is `true`. ### Background Registration is separate from the REST socket because it speaks a different protocol: a line of text, then file descriptors, then rings of shared memory. A separate socket also makes the trust rule simple: the shared-memory channel has no API key, so the user ID of the connecting process is the only credential. The packaged service creates `/run/luradb` with the mode `0750` for the group `luradb`, which is where the default path puts the socket. ## [shm] snapshot_interval_ms How often, in milliseconds, the snapshot is checked for changes; it is rebuilt only after a change, from one consistent point across all data shards. Lower values mean fresher snapshots and more CPU load; every rebuild briefly holds back the writes of all data shards. - Default: `100` - Since: v0.1.0 ### Effect How often, in milliseconds, the publisher checks whether the shared-memory snapshot is out of date. A check also happens after every MemTable flush. A check compares the position of the key-value write-ahead log and the generation of the domain list with those of the last snapshot. It builds a new snapshot only if they differ, or if a key with an expiry time in the last snapshot has expired since. Otherwise it only confirms the time in the header of the state segment. The build reads the keys of all domains from one consistent point across the data shards and serializes them; while it takes that point, the shards hold their writes back for a moment. The value must be at least 1; `0` refuses the start with `invalid config: shm.snapshot_interval_ms (0) must be at least 1`. The check runs even while `shm.enabled` is `false`. A new snapshot cannot be published while a client still reads the segment that it would overwrite. The publish is then skipped and the server logs, on every tenth skip in a row, `SHM snapshot stale: N consecutive publishes skipped, buffer … still pinned by (client_id, readers) …`, and `SHM snapshot publishing resumed after N skipped publishes` when it works again. `snapshot_consecutive_skips` in the `shm` block of `GET /store-api/metrics` shows the run that is going on. To end a run, see `shm.kick_blocking_client_after_secs`. ### Background The interval is the staleness a client can see after a write, plus the time of the build: with a write every few milliseconds the snapshot is rebuilt at every interval, and a build reads and serializes all inline key-value data, so its cost grows with the size of that data (`shm.data_buffer_size`). A shorter interval gives fresher snapshots at the price of more CPU and more moments in which the shards hold their writes. Raise it if the snapshot is large and clients can live with older data. ## [shm] kick_blocking_client_after_secs Seconds a client may keep the snapshot from being updated, by holding on to a read of the old one, before the server disconnects it; 0 = never. Warning: the disconnected client's reads still in progress may return torn data. - Default: `0` - Since: v0.5.1 ### Effect How long, in seconds, a run of skipped snapshot publishes may last before the server disconnects the clients that cause it. A publish is skipped when a client still reads the data segment that the new snapshot would overwrite (see `shm.snapshot_interval_ms`). The server measures the run in time, from the first skipped publish after the last successful one. When the run has lasted longer than the value, the server closes the registration connection of every client that pins the blocked segment, which removes the segments of those clients, and logs `SHM snapshot blocked longer than the kick threshold: disconnecting (client_id, readers) … pinning buffer …`. The counter `clients_kicked_total` in the `shm` block of `GET /store-api/metrics` goes up for each client. If the segment is still pinned afterwards, the measurement starts again, so the server kicks at most once per interval of the value. A client that is disconnected this way may be in the middle of a read of the old snapshot, and that read can return data that is partly overwritten. The client must treat the disconnect as an error and read again after registering anew. With `0`, the default, the server never disconnects a client. A client that keeps a read open without end then blocks every later publish: the snapshot stops changing, the server logs `SHM snapshot stale: …` on every tenth skipped publish, and `snapshot_consecutive_skips` in the metrics keeps rising. The value is a whole number of seconds from 0. ### Background A client that hangs or is paused in the middle of a read keeps the publisher from switching to the segment it reads. The key decides what is worth more: a snapshot that stays current for all clients, or the guarantee that no read is ever cut off. If a stuck client must not freeze the snapshot for the others, set a value longer than the longest read that your clients legitimately keep open. ## [backup] enabled Enables backups; while off, the backup endpoints answer 503. - Default: `false` - Since: v0.3.0 ### Effect With `true`, the server can write logical backups of its data: an archive file with the key-value entries, the JSON documents and the relational schemas and rows, which it can read back into the same or another server. At start it creates the backup directory (`backup.dir`), removes `.part` files that an earlier run left behind, logs `Backup manager ready (N schedule(s)).` and starts the scheduler of the `[[backup.schedule]]` entries. All backup endpoints are for admins: `POST /store-api/backups` starts a backup (`202` with the id; the body names the `scope` and `include_auth`), `GET /store-api/backups` lists the archives, and there are endpoints to read, download, upload, restore and delete one. With `false`, the endpoints answer `503 Service Unavailable: backup is disabled (backup.enabled = false)` and no scheduler runs; the log says `Backup disabled by config.`. The directory is not created. The schedule entries and the directory are not checked while the key is `false`: in a test of v0.5.1, a schedule with an invalid cron expression did not stop the start. One job runs at a time, a backup or a restore. A second request is answered with `409 Conflict: a backup or restore job is already running`. A backup is written to `.ndjson.part`, synced, and renamed to `.ndjson` when it is complete. The id is `bk__` for a backup on request and `bk__` for a scheduled one. Each engine is exported from one consistent point across the data shards, and the file ends with a checksum line; an archive without it is listed as `incomplete`. The values of key-value entries are written in hex. While the server refuses writes for lack of disk space or memory (`resources.disk_free_block`), a backup starts only if the backup directory is on a volume of its own that has room; a scheduled one is skipped with a warning otherwise. With `auth.enabled` off, the server warns at start that any client that reaches the port can create and download full backups. `GET /store-api/metrics` has a block `backup` with the time, duration and size of the last success, the time per schedule and the number of failures; it is `null` while backups are off. ### Background A logical backup stores keys, documents and rows, not the files of the data directory, and it can be restored into a single domain under a new name. It is taken while the server runs, from a consistent point; the shards hold their writes back only for the moment the point is taken. It is off by default because it writes files and makes data downloadable. Switch it on, give it a directory on a separate volume, and add a schedule so that backups happen without anyone remembering. ## [backup] dir Directory of the backup files; relative paths resolve against the working directory. Warning: use a separate directory per server; retention deletes backups by schedule name. - Default: `"luradb_backups"` - Since: v0.3.0 ### Effect The directory in which the server keeps its backup archives, one file `bk__.ndjson` per backup. The server creates the directory, with its parents, when it starts with `backup.enabled` on, and removes `.ndjson.part` and `upload-*.part` files in it that an earlier run left unfinished. A relative path resolves against the working directory of the server process (under the packaged service, `/var/lib/luradb`, so the default is `/var/lib/luradb/luradb_backups`). Only the files named `bk_*.ndjson` are archives; every other file in the directory is left alone. The path must not be empty, and it must not resolve to the same location as another data path or the log directory; the start is refused with `invalid config: backup.dir must not be empty` or `invalid config: storage.wal_path and backup.dir resolve to the same location '…'`. The checks run only while backups are on. Retention deletes in this directory. After each successful scheduled backup, the server deletes the older archives of that schedule beyond `backup.schedule.keep_last`, found by the schedule name in the manifest of each archive. Two servers that share a directory and both have a schedule of the same name therefore delete each other's archives. Use a directory per server. While the server refuses writes for lack of disk space or memory, a backup may start only if this directory is on a volume of its own that is above the warn threshold (`resources.disk_free_warn`). ### Background A backup on the volume of the data it protects is lost with that volume and uses the space the database needs to run. An archive is plain NDJSON, and the values of key-value entries are written in hex, so they take twice their size. Put the directory on another volume, or on a mount that is copied away. The default is a relative path, which under the packaged service lies on the data volume; set an absolute path on another volume. ## [backup.schedule] name Unique schedule name: 1 to 50 characters of [a-zA-Z0-9_-]. - Default: not set - Since: v0.3.0 ### Effect The name of a schedule, 1 to 50 characters from `a-z`, `A-Z`, `0-9`, `_` and `-`. The key is required: a schedule without it fails to parse, with an error that says `missing field` and names the key, and the server does not start. This holds also while `backup.enabled` is `false`, since the parse comes before every check. The name must be unique among the schedules; the start is refused with `invalid config: backup.schedule.name ('a b') must be 1-50 characters of [a-zA-Z0-9_-]` or `invalid config: backup.schedule.name ('a') must be unique across schedules`. The checks run only while `backup.enabled` is `true`. The name ties the archives to their schedule. A scheduled backup is named `bk__` (for example `bk_20261103T202200Z_nightly`), the manifest in the archive records the name, and the metrics list the time of the last success per schedule name (`last_success_at_by_schedule` in the `backup` block of `GET /store-api/metrics`). Retention uses the name to find the archives it may delete (`backup.schedule.keep_last`): those that are complete, were made by the server and carry this name in their manifest. If you rename a schedule, the archives of the old name are no longer matched and stay until you delete them. Archives made on request (`POST /store-api/backups`) carry no schedule name and are never deleted by retention; neither are uploaded archives, whatever name their manifest carries. ### Background The name is the only link between a schedule and its archives, which is why it has to be unique and why retention cannot reach archives that carry another name. Use a name that says what the schedule does, such as `nightly` or `hourly-orders`, and keep it stable. ## [backup.schedule] cron When the schedule runs: a 5-field cron expression in UTC that fires within 4 years. - Default: not set - Since: v0.3.0 ### Effect When the schedule runs: a cron expression of five fields, `minute hour day-of-month month weekday`, separated by blanks and evaluated in UTC, not in the local time of the host. The key is required. Each field accepts `*`, a value, a list (`1,15`), a range (`1-5`) and a step (`*/10` or `0-30/10`), combined as a comma-separated list. The ranges are 0–59, 0–23, 1–31, 1–12 and 0–6, where 0 is Sunday and 7 is not accepted. Names (`MON`, `JAN`) and special forms (`@daily`, `L`, `#`) are not supported. Example: `0 3 * * *` is every day at 03:00 UTC. When both day-of-month and weekday are restricted, the schedule runs on a day that matches either of them: `0 0 1 * 1` runs on the first of every month and on every Monday. A field counts as restricted unless it is exactly `*`; a step such as `*/3` counts as restricted, which differs from Vixie cron. The checks run at start while `backup.enabled` is `true`. An expression that does not parse refuses the start with a message that names the field, for example `invalid config: backup.schedule.cron ('0 3 * * 7') is not a valid cron expression: cron field 'weekday': value 7 out of range [0, 6] in '7' (schedule 'a')`, or, for four fields, `… must have exactly 5 fields (minute hour day-of-month month weekday), got 4`. An expression that never matches within the next four years (1,461 days), such as 30 February, is refused with `invalid config: backup.schedule.cron ('0 0 30 2 *') has no date within 4 years — the schedule would never run (schedule 'a')`; 29 February is accepted. The scheduler wakes at the start of every UTC minute and starts the backup of each schedule whose expression matches that minute. There is no catch-up: if the server was stopped at the time, the run is missed and the next match counts. A start inside a matching minute does not run that slot. Only one backup or restore runs at a time (the job slot). A schedule that matches while the slot is busy is skipped with `[Backup Scheduler] job slot busy, skipping this tick for schedule '…'`, so two schedules due in the same minute run one and skip the other. A schedule is also skipped, with a warning, while the server refuses writes for lack of disk space or memory and the backup directory has no volume of its own with room. ### Background Cron is the notation operators already know, and UTC avoids the shifts of daylight saving time: a schedule fires at the same instant all year, and the id and the manifest of each backup carry UTC times. Choose a time of low load, and keep the schedules of a server at different minutes so that none is skipped because another is running. A backup that is still running when the next match comes makes that match skip, so the interval between matches should be longer than a backup takes. ## [backup.schedule] scope Data to back up: all, kv, json, rel, `kv:`, `json:`, `rel:` or `domain:`; `domain:` is the whole domain, kv:, json: and rel: one engine's part of it. - Default: not set - Since: v0.3.0 ### Effect What the schedule backs up. The key is required, and its value is one of: `all` (every engine, all domains), `kv`, `json` or `rel` (one engine's part of all domains), `kv:`, `json:` or `rel:` (one engine's part of one domain), and `domain:` (the whole domain: its keys, documents and tables). A domain name uses the characters `a-z`, `A-Z`, `0-9`, `_` and `-`. The same grammar is used for the `scope` of `POST /store-api/backups`. The syntax is checked at start while `backup.enabled` is `true`; anything else refuses the start with `invalid config: backup.schedule.scope ('everything') is not a valid scope: invalid backup scope 'everything': expected 'all', 'kv', 'json', 'rel', 'kv:', 'json:', 'rel:', or 'domain:' (schedule 'a')`. That a domain exists is not checked at start, but each time the schedule runs. A schedule for a domain that does not exist, or one whose scope needs an engine that is off (`json`, `rel`, `json:…`, `rel:…` with `json.enabled` or `rel.enabled` `false`), starts no backup and logs a warning such as `[Backup Scheduler] schedule 'orders' failed to start: domain_not_found: orders`. The other schedules go on. The scopes `all` and `domain:` back up only the engines that are on. The relational part of a domain is archived with its schema and its rows. A restore with `replace` replaces only the engines that the archive holds and keeps the domain and its permissions, so an archive of `kv:` brings back the keys and leaves the documents and tables of the domain as they are. For the scopes `kv` and `all`, the schedule can also include the accounts (`backup.schedule.include_auth`); other scopes ignore that setting. ### Background A narrow scope gives a small archive that is quick to take and to restore. Use `all` for the safety net of a whole installation, and add a second schedule with a domain scope for a domain that changes faster or matters more, for example `domain:orders` every hour. The archive file name carries the schedule name, not the scope, so the scope is recorded only in the manifest of the archive. ## [backup.schedule] include_auth Also backs up users and permissions (scopes all and kv only). The backup file then contains API key hashes. - Default: not set - Since: v0.3.0 ### Effect With `true`, the backups of this schedule also contain the accounts of the server: for each account its name, role, creation time and the hash of its API key (`auth-user` lines), and for each account the permissions it holds on domains (`auth-perm` lines). Without it (the default), an archive holds data only. In a test of v0.5.1 with an on-demand backup of scope `all` and `include_auth` set, the archive had one `auth-user` line for the admin account, with the fields `name`, `api_key_hash`, `role` and `created_at`. The setting has an effect only for the scopes `all` and `kv`. For every other scope the server leaves the accounts out without a message, and the manifest of the archive says `include_auth: false`. The key is optional. The archive then holds SHA-256 hashes of API keys, never the keys themselves. Treat the file as sensitive: it is only as safe as the directory it lies in (`backup.dir`), the volumes it is copied to and the admins who can download it. When the archive is restored, the accounts come back only if the restore request sets `include_auth` as well; otherwise the lines are ignored. The accounts that `auth.admins.name` lists are recreated at every start in any case. ### Background Without accounts, restoring an archive into a new installation leaves you with data and no users, and you have to create the accounts and their permissions again. With them, a restore rebuilds the access rules together with the data. The price is that the archive holds credentials in the form of hashes. Switch it on for the schedule of your full backup if you restore whole installations, and keep the archives as protected as the system store. ## [backup.schedule] keep_last How many of this schedule's newest backups to keep (at least 1). - Default: not set - Since: v0.3.0 ### Effect How many of the newest backups of this schedule the server keeps. The key is required and must be at least 1; `0` refuses the start with `invalid config: backup.schedule.keep_last (0) must be at least 1 (schedule 'a')`, and a schedule without it fails to parse with an error that says `missing field` and names the key. The check runs only while `backup.enabled` is `true`. After every scheduled backup that finished complete, the server lists the archives in `backup.dir` and deletes the oldest ones of this schedule beyond the number, ordered by creation time. An archive belongs to the schedule if it is complete, was made by this server (not uploaded) and its manifest carries the schedule's name (`backup.schedule.name`). A backup that failed triggers no deletion, so a failing schedule never deletes the good archives it should have replaced. Archives made on request, archives of other schedules and uploaded archives are never touched. In a test of v0.5.1, with a schedule `mins` of `* * * * *` and `keep_last = 2`, the directory held the two newest archives of `mins` after each run, and an archive made on request stayed. ### Background Without retention the directory grows with every run. The number is the length of the history you can go back to: with a nightly schedule and `keep_last = 7` you hold the last seven nightly archives. Retention runs only after the new archive is complete, so the directory holds one archive more than the number for a short time; plan the volume for that. A delete by hand through the API works at any time and is not limited by this key. ## [buffer_pool] pool_size Pages (4 KiB each) the buffer pool keeps in memory. - Since: v0.1.0 - Removed in: v0.7.0 ### Effect The number of pages of 4 KiB that the buffer pool of the page file (`storage.db_path` (removed)) held in memory, over all data shards. The server divided the number evenly among the shards, gave every shard at least one page, and showed the share of each shard in the start log as `buffer pool N pages`. The pool served no data, because no engine read or wrote pages through it, so the key set only how much memory the server reserved; that memory counted toward the fixed memory that `resources.memory_budget` is compared with. The default was `1024`. ### Background Since v0.7.0 the server has no buffer pool and reserves no memory for one; the start log line of each shard no longer names it. The v0.7.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'buffer_pool.pool_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rate_limit] default_max_storage_bytes Stored bytes per domain; 0 means no limit. - Since: v0.1.0 - Removed in: v0.7.0 ### Effect Meant as the largest amount of stored data per domain, in bytes, with `0` for no limit. The value was read from the file and handed to every domain, but nothing enforced it: no code path compared the stored size of a domain with it, and no write was refused because of it. The default was `0`. ### Background Since v0.7.0 the key is gone without a replacement; LuraDB has no size limit per domain. To keep the data from filling a volume, watch the free space with `resources.disk_free_warn` and `resources.disk_free_block`, and cap the size of data in the client or in a proxy in front of the server. The v0.7.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rate_limit.default_max_storage_bytes' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [storage] db_path Page file of the buffer pool. - Since: v0.1.0 - Removed in: v0.7.0 ### Effect The path of the page file that backed the buffer pool of `buffer_pool.pool_size` (removed). Each data shard had a file of its own in a directory `shard_`, which the server created at start. Nothing was stored in the file: no engine read or wrote pages through the buffer pool, and the files stayed at zero bytes while the server wrote data. The path took part in the checks for data paths and in the free-space watch of the data volumes. The default was `luradb.db`. ### Background Since v0.7.0 the server has no buffer pool and creates no `luradb.db` file; the data lives in the write-ahead log, the SSTables and the value log (`storage.wal_path`, `storage.sstable_dir`, `storage.vlog_path`). An empty `luradb.db` that an earlier version left in the data directory or in a `shard_` directory stays where it is and does not hinder the start; it can be deleted. The v0.7.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'storage.db_path' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [backup] scan_batch_size Number of entries that a backup or restore processed before it paused. - Since: v0.3.0 - Removed in: v0.5.1 ### Effect The number of entries that a backup export or a restore processed before it paused for `backup.scan_pause_ms` (removed). A restore also wrote JSON documents in groups of this size. A value of `0` was treated as `1`. The default was `500`. The key applied only with `backup.enabled` set to `true`. ### Background Since v0.5.1 the batch is fixed at 500 entries, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'backup.scan_batch_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [backup] scan_pause_ms Pause in milliseconds after each batch of a backup or restore. - Since: v0.3.0 - Removed in: v0.5.1 ### Effect The pause, in milliseconds, that a backup export or a restore made after each batch of `backup.scan_batch_size` (removed) entries, so that other requests could run in between. `0` meant no pause. The default was `10`. The key applied only with `backup.enabled` set to `true`. ### Background Since v0.5.1 the pause is fixed at 10 milliseconds, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'backup.scan_pause_ms' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [block_cache] capacity_bytes Maximum size in bytes of the block cache of the key-value engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The maximum total size, in bytes, of the block cache of the key-value engine, the cache of SSTable data blocks that sat between the MemTable and the files. Blocks were evicted once the cached blocks together exceeded the value. The default was `67108864` (64 MiB). The server did not check the value. ### Background Since v0.5.1 each engine instance of each data shard has a block cache of its own, and the built-in capacity of 64 MiB is divided by the number of shards (`multicore.shards`); with 8 shards the start log shows `block cache 8192 KiB per engine`. The caches count toward the fixed memory that `resources.memory_budget` is compared with. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'block_cache.capacity_bytes' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [block_cache] ghost_capacity Number of evicted block identifiers that the block cache of the key-value engine remembered. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of identifiers of evicted blocks, without their data, that the block cache of the key-value engine remembered. A block that was requested again while its identifier was still remembered went straight to the main queue. The default was `10000`. The server did not check the value. ### Background Since v0.5.1 the number is fixed at `10000`, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'block_cache.ghost_capacity' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [block_cache] small_ratio Share of the block cache of the key-value engine that the small queue could use. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The share of `block_cache.capacity_bytes` (removed) that the small queue of the block cache of the key-value engine could use, as a number from 0 to 1. The cache works as an S3-FIFO cache: a block that was read for the first time entered the small queue, and a block that was read again moved to the main queue, so one pass over a large range did not push the blocks out that were read often. The default was `0.10`. The server did not check the value. ### Background Since v0.5.1 the ratio is fixed at `0.10`, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'block_cache.small_ratio' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [io_engine] registered_buffer_count Number of buffers that the I/O engine registered with io_uring. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of buffers that the I/O engine allocated and registered with the kernel for io_uring at start. It applied only with `io_engine.enabled` set to `true`; the default of that key was `false`. Its default was `128`. A successful start logged `IoEngine ready: 128 registered buffers x 65536 bytes.` with the configured numbers. The engines did not read or write through the buffers, so the key only decided how much memory the registration pinned: the count times `io_engine.registered_buffer_size` (removed), 8 MiB with the defaults. The server did not check the value. ### Background The buffers were groundwork that no read or write path used. Since v0.5.1 the pool is fixed at 128 buffers of 64 KiB, and `io_engine.enabled` only switches it on. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'io_engine.registered_buffer_count' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [io_engine] registered_buffer_size Size in bytes of each buffer that the I/O engine registered with io_uring. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The size, in bytes, of each of the buffers that the I/O engine registered with the kernel for io_uring at start. It applied only with `io_engine.enabled` set to `true`; the default of that key was `false`. Its default was `65536` (64 KiB). The engines did not read or write through the buffers, so the key only decided how much memory the registration pinned: `io_engine.registered_buffer_count` (removed) times this size, 8 MiB with the defaults. The server did not check the value. ### Background The buffers were groundwork that no read or write path used. Since v0.5.1 the pool is fixed at 128 buffers of 64 KiB, and `io_engine.enabled` only switches it on. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'io_engine.registered_buffer_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [io_engine] request_channel_capacity Length of the request queue in front of the storage thread. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The length of the queue in front of the storage thread: requests for the write-ahead log, the value log and the writing of SSTables went through a bounded channel of this size, and the sender waited while the channel was full. A value of `0` was treated as `1`. It applied only with `io_engine.enabled` set to `true`; the default of that key was `false`. Its default was `1024`. ### Background `storage.wal_queue_capacity` replaces it. The new key has the same default, `1024`, and since v0.5.1 the storage thread always runs, so it always applies. A value set under the old name is not carried over. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'io_engine.request_channel_capacity' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [io_engine] ring_depth Depth of the io_uring ring of the storage thread. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of entries of the submission queue of the io_uring ring that the storage thread built. It applied only with `io_engine.enabled` set to `true`; the default of that key was `false`. Its default was `256`. The server did not check the value. ### Background Since v0.5.1 the depth is fixed at 256. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'io_engine.ring_depth' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [io_engine] sqpoll_enabled Whether the storage thread used an io_uring ring in SQPOLL mode. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect Whether the storage thread built its io_uring ring in SQPOLL mode, in which a kernel thread picks up submissions without a system call for each request. The storage thread is the dedicated thread that wrote the write-ahead log and the value log. It ran only with `io_engine.enabled` set to `true`, so with the default of `false` the key had no effect. The default of the key itself was `true`. When the kernel refused SQPOLL for lack of the capability `CAP_SYS_NICE`, the thread logged `SQPOLL requires CAP_SYS_NICE, falling back to standard mode` and used an ordinary ring. The server did not check the value. ### Background Since v0.5.1 the storage thread always runs and always asks for SQPOLL, with the same fallback; its line in the start log says whether SQPOLL is active. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'io_engine.sqpoll_enabled' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [io_engine] sqpoll_idle_ms Idle time in milliseconds of the SQPOLL kernel thread of the storage thread. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The time, in milliseconds, that the SQPOLL kernel thread of the storage thread's ring kept polling for new submissions before it went to sleep. It applied only with `io_engine.enabled` set to `true` and `io_engine.sqpoll_enabled` (removed) set to `true`. The default was `2000`. The server did not check the value. ### Background Since v0.5.1 the idle time is fixed at 2000 milliseconds. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'io_engine.sqpoll_idle_ms' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [io_engine] storage_thread_cpu CPU core to which the storage thread was pinned. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of the CPU core to which the storage thread pinned itself. The default, `-1`, left the thread unpinned. When the pinning failed, the thread logged `Storage thread CPU pinning to core N failed: …` and went on unpinned. It applied only with `io_engine.enabled` set to `true`; the default of that key was `false`. The server did not check the value. ### Background Since v0.5.1 the storage thread is never pinned. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'io_engine.storage_thread_cpu' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.block_cache] capacity_bytes Maximum size in bytes of the block cache of the JSON engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The maximum total size, in bytes, of the block cache of the JSON engine, the cache of SSTable data blocks that sat between the MemTable and the files. Blocks were evicted once the cached blocks together exceeded the value. The default was `67108864` (64 MiB). The server did not check the value. ### Background Since v0.5.1 each engine instance of each data shard has a block cache of its own, and the built-in capacity of 64 MiB is divided by the number of shards (`multicore.shards`); with 8 shards the start log shows `block cache 8192 KiB per engine`. The caches count toward the fixed memory that `resources.memory_budget` is compared with. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.block_cache.capacity_bytes' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.block_cache] ghost_capacity Number of evicted block identifiers that the block cache of the JSON engine remembered. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of identifiers of evicted blocks, without their data, that the block cache of the JSON engine remembered. A block that was requested again while its identifier was still remembered went straight to the main queue. The default was `10000`. The server did not check the value. ### Background Since v0.5.1 the number is fixed at `10000`, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.block_cache.ghost_capacity' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.block_cache] small_ratio Share of the block cache of the JSON engine that the small queue could use. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The share of `json.block_cache.capacity_bytes` (removed) that the small queue of the block cache of the JSON engine could use, as a number from 0 to 1. The cache works as an S3-FIFO cache: a block that was read for the first time entered the small queue, and a block that was read again moved to the main queue, so one pass over a large range did not push the blocks out that were read often. The default was `0.10`. The server did not check the value. ### Background Since v0.5.1 the ratio is fixed at `0.10`, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.block_cache.small_ratio' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json] bulk_batch_size Number of documents that a JSON bulk import wrote in one batch. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of documents that a bulk import into a JSON domain (`POST /store-api/json/{domain}/bulk`) wrote in one atomic batch. A key that appeared twice in the input started a new batch. A value of `0` was treated as `1`. The default was `100`. ### Background Since v0.5.1 the batch is fixed at 100 documents, the former default. The size of the request is still limited by `json.bulk_body_limit_bytes`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.bulk_batch_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.compaction] l0_threshold Number of level-0 SSTables at which the JSON engine compacted level 0. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of SSTables at level 0 at which the compaction loop of the JSON engine started a compaction of level 0 into level 1. The comparison was "at least", and every flush of a MemTable added one file at level 0. The default was `4`. The server did not check the value. ### Background Since v0.5.1 the JSON engine compacts with the built-in value `4`, the former default, and it cannot be changed. The key-value engine keeps its own setting, `compaction.l0_threshold`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.compaction.l0_threshold' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.compaction] l1_max_size Total size in bytes of level 1 at which the JSON engine compacted it. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The total size, in bytes, of the SSTables at level 1 at which the compaction loop of the JSON engine started a compaction of level 1 into level 2. Deeper levels were limited to this size multiplied by `json.compaction.level_size_ratio` (removed) once for each level below level 1. The default was `104857600` (100 MiB). The server did not check the value. ### Background Since v0.5.1 the JSON engine uses the built-in limit of 100 MiB, the former default, and it cannot be changed. The key-value engine keeps its own setting, `compaction.l1_max_size`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.compaction.l1_max_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.compaction] level_size_ratio Factor by which the size limit of the JSON engine grew from one level to the next. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The factor by which the size limit of a level grew from one level to the next: level 1 was limited by `json.compaction.l1_max_size` (removed), and level n from 2 on to that value times this factor to the power n - 1. The default was `10`. The server did not check the value. ### Background Since v0.5.1 the JSON engine uses the built-in factor `10`, the former default, and it cannot be changed. The key-value engine keeps its own setting, `compaction.level_size_ratio`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.compaction.level_size_ratio' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.compaction] max_sstable_size Size at which a compaction of the JSON engine started a new output file. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The size at which a compaction of the JSON engine closed an output file and started the next one. The size was summed from the lengths of the keys and values, a value in the value log counting as its pointer, and the file was closed at the next boundary between two user keys. The files of a flush were not cut by this key. The default was `67108864` (64 MiB). The server did not check the value. ### Background Since v0.5.1 the JSON engine uses the built-in size of 64 MiB, the former default, and it cannot be changed. The key-value engine keeps its own setting, `compaction.max_sstable_size`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.compaction.max_sstable_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.janitor] check_interval_secs Seconds between two checks of the value log janitor of the JSON engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The pause, in seconds, between two checks of the janitor of the JSON engine, the task that cleans the value log. Each check estimated how much of the log was dead and cleaned it when the estimate reached `json.janitor.dead_bytes_threshold` (removed) and the log had at least `json.janitor.min_vlog_size_bytes` (removed) bytes. The default was `60`. The server did not check the value. ### Background Since v0.5.1 the JSON engine checks every 60 seconds, the former default, and it cannot be changed. The key-value engine keeps its own setting, `janitor.check_interval_secs`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.janitor.check_interval_secs' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.janitor] dead_bytes_threshold Share of dead space in the value log at which the JSON engine cleaned it. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The share of the value log that had to be dead, as a number from 0 to 1, before the janitor of the JSON engine cleaned the log. The janitor estimated the share from the size of the log and the bytes that the pointers in the MemTables and SSTables still referenced. The default was `0.30`. The server did not check the value. ### Background Since v0.5.1 the JSON engine uses the built-in threshold `0.30`, the former default, and it cannot be changed. The key-value engine keeps its own setting, `janitor.dead_bytes_threshold`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.janitor.dead_bytes_threshold' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.janitor] min_vlog_size_bytes Size in bytes that the value log of the JSON engine needed before it was cleaned. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The size, in bytes, that the value log of the JSON engine needed before the janitor could clean it, however much of it was dead. The default was `67108864` (64 MiB). The server did not check the value. ### Background Since v0.5.1 the JSON engine uses the built-in minimum of 64 MiB, the former default, and it cannot be changed. The key-value engine keeps its own setting, `janitor.min_vlog_size_bytes`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.janitor.min_vlog_size_bytes' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.lsm] compaction_check_interval_ms Pause in milliseconds between two turns of the compaction loop of the JSON engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The pause, in milliseconds, between two turns of the compaction loop of the JSON engine. In each turn the loop checked the levels of the SSTables against their limits, ran a compaction if a level was over its limit, and then slept for this long. The default was `1000`. The server did not check the value. ### Background Since v0.5.1 the pause is fixed at 1000 milliseconds, the former default. The key-value engine keeps its own setting, `lsm.compaction_check_interval_ms`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.lsm.compaction_check_interval_ms' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.lsm] flush_check_interval_ms Pause in milliseconds between two turns of the flush loop of the JSON engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The pause, in milliseconds, between two turns of the flush loop of the JSON engine. In each turn the loop wrote a frozen MemTable to an SSTable, if there was one, and then slept for this long. The default was `100`. The server did not check the value. ### Background Since v0.5.1 the pause is fixed at 100 milliseconds, the former default. The key-value engine keeps its own setting, `lsm.flush_check_interval_ms`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.lsm.flush_check_interval_ms' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.lsm] memtable_size_threshold Size in bytes at which a MemTable of the JSON engine was flushed. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The size, in bytes, at which the active MemTable of the JSON engine was frozen and queued to be written to an SSTable at level 0. The size counted the encoded keys and the values kept inline, and a value in the value log counted only with its pointer. The default was `4194304` (4 MiB). The server did not check the value. ### Background Since v0.5.1 the JSON engine uses the built-in size of 4 MiB, the former default, and it cannot be changed. The key-value engine keeps its own setting, `lsm.memtable_size_threshold`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.lsm.memtable_size_threshold' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.lsm] use_mmap Whether the JSON engine memory-mapped its SSTables. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect Whether the JSON engine opened its SSTables as memory-mapped files (`true`, the default) or read each file completely into memory (`false`). The choice applied to every SSTable the engine opened: at start, after a flush, and after a compaction or a cleanup of the value log. The server did not check the value. ### Background Since v0.5.1 the SSTables of every engine are always memory-mapped. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.lsm.use_mmap' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.lsm] vlog_inline_threshold Value size in bytes from which the JSON engine stored values in the value log. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect A value of at least this many bytes was appended to the value log of the JSON engine when it was written; the MemTable and the SSTables then kept only a pointer to it. A shorter value stayed inline. The default was `1024`. The server did not check the value. ### Background Since v0.5.1 the JSON engine uses the built-in value `1024`, the former default, and it cannot be changed. The key-value engine keeps its own setting, `lsm.vlog_inline_threshold`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.lsm.vlog_inline_threshold' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.lsm] wal_event_channel_capacity Capacity of the write-event channel of the JSON engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The capacity of the broadcast channel on which the engine of the JSON engine published its write events. Only the watch of the key-value engine read events from such a channel, so for the JSON engine the key sized a channel that nothing listened to. The default was `256`. The server did not check the value. ### Background Since v0.5.1 the channel has the built-in capacity of 256, the former default. The key-value engine keeps its own setting, `lsm.wal_event_channel_capacity`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.lsm.wal_event_channel_capacity' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json.lsm] watch_replay_buffer_size Size of the watch replay ring of the JSON engine, which the server never used. - Since: v0.4.0 - Removed in: v0.5.1 ### Effect The size of the ring that keeps change events for clients that reconnect to a watch stream. The JSON engine has no watch, and the server set the ring size of its engine to `0` whatever this key said, so the value was read from the file and never used. The default was `1024`. ### Background Watch streams of data changes exist for the key-value engine only; their replay ring is set by `lsm.watch_replay_buffer_size`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.lsm.watch_replay_buffer_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json] max_document_key_length Longest document key of the JSON engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The longest key, in characters, that a client could give a JSON document. A longer key was refused with `400` and `invalid document key: key length N exceeds maximum of M characters`, and a bulk import listed it under `errors`. The limit was the smaller of this value and `json.lsm.max_key_length` minus 21, the prefix with which the engine stores a document. The default was `256`. The server did not check the value. ### Background Since v0.5.1 the cap is fixed at 256. The key length is still limited by `json.lsm.max_key_length`, which leaves 21 bytes less for the document key: with its default of 256 the longest document key is 235 characters. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.max_document_key_length' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json] purger_batch_size Number of keys that one purge step removed from a deleted JSON domain. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of keys that one purge step of the JSON engine removed from a deleted domain. A deleted domain is unreachable at once, and a background task removes its keys in steps of this size: documents first, then index entries; once nothing is left the task removes the domain itself. A value of `0` was treated as `1`. The default was `100`. ### Background Since v0.5.1 the step is fixed at 100 keys, the former default; the purge of the key-value engine is set by `domains.purger_batch_size`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.purger_batch_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json] purger_interval_secs Seconds between two purge steps of the JSON engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of seconds between two purge steps of the JSON engine, the background task that removes the keys of deleted domains in steps of `json.purger_batch_size` (removed). The default was `5`. The server did not check the value. ### Background Since v0.5.1 the pause is fixed at 5 seconds, the former default; the purge of the key-value engine is set by `domains.purger_interval_secs`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.purger_interval_secs' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json] reindex_batch_size Number of documents that an index rebuild processed in one step. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of documents that a rebuild of the indexes of a JSON domain (`POST /store-api/json/{domain}/reindex`) processed in one step. A value of `0` was treated as `1`. The default was `500`. ### Background Since v0.5.1 the batch is fixed at 500 documents, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.reindex_batch_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [json] reindex_pause_ms Pause in milliseconds between two steps of an index rebuild. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The pause, in milliseconds, that an index rebuild of a JSON domain made after each step of `json.reindex_batch_size` (removed) documents, so that other requests could run in between. `0` meant no pause. The default was `10`. ### Background Since v0.5.1 the pause is fixed at 10 milliseconds, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'json.reindex_pause_ms' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [log.modules] domains Log level of the domain registry module of the key-value engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The log level of the module `luradb::engines::lsm::domain`, the domain registry of the key-value engine, in place of `log.level`. The values were `verbose`, `info` and `prod`, the same as for the global level; they set the filter to `debug`, `info` and `warn`. Without the key the module followed the global level. Any other value refused the start with a parse error of the configuration file. ### Background Since v0.5.1 the module has no setting of its own. Its name begins with `luradb::engines`, so `log.modules.engine` sets its level together with that of the other engine modules. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'log.modules.domains' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [lsm] use_mmap Whether the key-value engine memory-mapped its SSTables. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect Whether the key-value engine opened its SSTables as memory-mapped files (`true`, the default) or read each file completely into memory (`false`). The choice applied to every SSTable the engine opened: at start, after a flush, and after a compaction or a cleanup of the value log. The server did not check the value. ### Background Since v0.5.1 the SSTables of every engine are always memory-mapped. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'lsm.use_mmap' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [metrics] ticker_interval_ms Interval in milliseconds at which the metrics windows advance. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect How often, in milliseconds, the background ticker of the metrics store closed the current snapshot of every window and opened the next one. The default was `1000`, one snapshot per second. A window held `metrics.window_secs` (removed) snapshots, so another interval changed the time that the window covered while the answer still reported `window_secs`: with `500` the 60 snapshots covered 30 seconds. The server did not check the value. ### Background Since v0.5.1 the ticker runs once per second. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'metrics.ticker_interval_ms' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [metrics] window_secs Width in seconds of the rolling window of the metrics endpoint. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The width of the rolling window, in seconds, over which `GET /store-api/metrics` counted operations and computed latency percentiles, for each domain and each engine. The window kept this many snapshots, one for each tick of the metrics ticker (`metrics.ticker_interval_ms` (removed)), and added them up; the answer repeats the number as `window_secs`. The default was `60`. The server did not check the value. ### Background Since v0.5.1 the window is always 60 seconds, and the answers report `window_secs` as `60`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'metrics.window_secs' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [multicore] engine_queue_capacity Length of the queue to the single engine thread, in builds before v0.5.0-rc.1. - Removed in: v0.5.1 ### Effect The length of the queue through which the frontend threads handed requests to the engine thread, when the storage engines still ran on a single thread. A full queue held further requests back. The default was `1024`, and the value had to be at least 1: `invalid config: multicore.engine_queue_capacity (0) must be at least 1` otherwise. The key existed only in development builds between v0.4.0 and v0.5.0-rc.1; no tagged release read it. ### Background `multicore.shard_queue_capacity` replaces it. With data shards (`multicore.shards`) every shard has a queue of its own: the key sets how many requests a shard takes at once, running or waiting, and a request that finds the queue full is answered with `503` and `Retry-After: 1` instead of waiting. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'multicore.engine_queue_capacity' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.block_cache] capacity_bytes Maximum size in bytes of the block cache of the relational engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The maximum total size, in bytes, of the block cache of the relational engine, the cache of SSTable data blocks that sat between the MemTable and the files. Blocks were evicted once the cached blocks together exceeded the value. The default was `67108864` (64 MiB). The server did not check the value. ### Background Since v0.5.1 each engine instance of each data shard has a block cache of its own, and the built-in capacity of 64 MiB is divided by the number of shards (`multicore.shards`); with 8 shards the start log shows `block cache 8192 KiB per engine`. The caches count toward the fixed memory that `resources.memory_budget` is compared with. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.block_cache.capacity_bytes' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.block_cache] ghost_capacity Number of evicted block identifiers that the block cache of the relational engine remembered. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of identifiers of evicted blocks, without their data, that the block cache of the relational engine remembered. A block that was requested again while its identifier was still remembered went straight to the main queue. The default was `10000`. The server did not check the value. ### Background Since v0.5.1 the number is fixed at `10000`, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.block_cache.ghost_capacity' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.block_cache] small_ratio Share of the block cache of the relational engine that the small queue could use. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The share of `rel.block_cache.capacity_bytes` (removed) that the small queue of the block cache of the relational engine could use, as a number from 0 to 1. The cache works as an S3-FIFO cache: a block that was read for the first time entered the small queue, and a block that was read again moved to the main queue, so one pass over a large range did not push the blocks out that were read often. The default was `0.10`. The server did not check the value. ### Background Since v0.5.1 the ratio is fixed at `0.10`, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.block_cache.small_ratio' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.compaction] l0_threshold Number of level-0 SSTables at which the relational engine compacted level 0. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of SSTables at level 0 at which the compaction loop of the relational engine started a compaction of level 0 into level 1. The comparison was "at least", and every flush of a MemTable added one file at level 0. The default was `4`. The server did not check the value. ### Background Since v0.5.1 the relational engine compacts with the built-in value `4`, the former default, and it cannot be changed. The key-value engine keeps its own setting, `compaction.l0_threshold`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.compaction.l0_threshold' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.compaction] l1_max_size Total size in bytes of level 1 at which the relational engine compacted it. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The total size, in bytes, of the SSTables at level 1 at which the compaction loop of the relational engine started a compaction of level 1 into level 2. Deeper levels were limited to this size multiplied by `rel.compaction.level_size_ratio` (removed) once for each level below level 1. The default was `104857600` (100 MiB). The server did not check the value. ### Background Since v0.5.1 the relational engine uses the built-in limit of 100 MiB, the former default, and it cannot be changed. The key-value engine keeps its own setting, `compaction.l1_max_size`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.compaction.l1_max_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.compaction] level_size_ratio Factor by which the size limit of the relational engine grew from one level to the next. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The factor by which the size limit of a level grew from one level to the next: level 1 was limited by `rel.compaction.l1_max_size` (removed), and level n from 2 on to that value times this factor to the power n - 1. The default was `10`. The server did not check the value. ### Background Since v0.5.1 the relational engine uses the built-in factor `10`, the former default, and it cannot be changed. The key-value engine keeps its own setting, `compaction.level_size_ratio`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.compaction.level_size_ratio' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.compaction] max_sstable_size Size at which a compaction of the relational engine started a new output file. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The size at which a compaction of the relational engine closed an output file and started the next one. The size was summed from the lengths of the keys and values, a value in the value log counting as its pointer, and the file was closed at the next boundary between two user keys. The files of a flush were not cut by this key. The default was `67108864` (64 MiB). The server did not check the value. ### Background Since v0.5.1 the relational engine uses the built-in size of 64 MiB, the former default, and it cannot be changed. The key-value engine keeps its own setting, `compaction.max_sstable_size`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.compaction.max_sstable_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] cross_engine_sweep_batch_size Number of cells that the sweeper for links nulled per run. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The largest number of cells that the sweeper of `rel.cross_engine_sweep_interval_secs` (removed) set to `NULL` in one run for one link column of one domain; a larger backlog took several runs. A value of `0` was treated as `1`. The default was `100`. ### Background In v0.5.1 the batch was fixed at 100 cells, the former default, and v0.7.0 removed the sweeper; see `rel.cross_engine_sweep_interval_secs` (removed) for how links behave without it. The v0.7.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.cross_engine_sweep_batch_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] cross_engine_sweep_interval_secs Seconds between two runs of the sweeper for links to deleted domains. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The pause, in seconds, between two runs of the sweeper that cleaned up links from the relational engine to the other engines. When the key-value or JSON domain that a `KVREF` or `JSONREF` column points to is deleted, reads show the cell as `NULL`; the sweeper then set such cells to `NULL` in the stored rows. It ran only when at least one engine that rows could link to was running. A value of `0` was treated as `1`. The default was `10`. ### Background In v0.5.1 the sweeper ran every 10 seconds, the former default, and v0.7.0 removed the sweeper. A domain now holds its keys, documents and tables together, so deleting it removes the rows along with the targets of their links. A link to a key-value or JSON part that is being purged still reads as `NULL`, and the row keeps the stored value of the link; nothing rewrites it. The v0.7.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.cross_engine_sweep_interval_secs' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] default_limit Number of rows returned when a query has no LIMIT. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of rows that a `SELECT` without `LIMIT`, and the row endpoint of a table without a `limit` parameter, returned at most; `rel.max_limit` capped it. When more rows existed, the answer said so with `"limit_applied": true`. The default was `1000`. The server did not check the value. ### Background Since v0.5.1 a query without a limit returns at most 1,000 rows, the former default, or `rel.max_limit` if that is smaller. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.default_limit' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.janitor] check_interval_secs Seconds between two checks of the value log janitor of the relational engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The pause, in seconds, between two checks of the janitor of the relational engine, the task that cleans the value log. Each check estimated how much of the log was dead and cleaned it when the estimate reached `rel.janitor.dead_bytes_threshold` (removed) and the log had at least `rel.janitor.min_vlog_size_bytes` (removed) bytes. The default was `60`. The server did not check the value. ### Background Since v0.5.1 the relational engine checks every 60 seconds, the former default, and it cannot be changed. The key-value engine keeps its own setting, `janitor.check_interval_secs`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.janitor.check_interval_secs' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.janitor] dead_bytes_threshold Share of dead space in the value log at which the relational engine cleaned it. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The share of the value log that had to be dead, as a number from 0 to 1, before the janitor of the relational engine cleaned the log. The janitor estimated the share from the size of the log and the bytes that the pointers in the MemTables and SSTables still referenced. The default was `0.30`. The server did not check the value. ### Background Since v0.5.1 the relational engine uses the built-in threshold `0.30`, the former default, and it cannot be changed. The key-value engine keeps its own setting, `janitor.dead_bytes_threshold`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.janitor.dead_bytes_threshold' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.janitor] min_vlog_size_bytes Size in bytes that the value log of the relational engine needed before it was cleaned. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The size, in bytes, that the value log of the relational engine needed before the janitor could clean it, however much of it was dead. The default was `67108864` (64 MiB). The server did not check the value. ### Background Since v0.5.1 the relational engine uses the built-in minimum of 64 MiB, the former default, and it cannot be changed. The key-value engine keeps its own setting, `janitor.min_vlog_size_bytes`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.janitor.min_vlog_size_bytes' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.lsm] compaction_check_interval_ms Pause in milliseconds between two turns of the compaction loop of the relational engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The pause, in milliseconds, between two turns of the compaction loop of the relational engine. In each turn the loop checked the levels of the SSTables against their limits, ran a compaction if a level was over its limit, and then slept for this long. The default was `1000`. The server did not check the value. ### Background Since v0.5.1 the pause is fixed at 1000 milliseconds, the former default. The key-value engine keeps its own setting, `lsm.compaction_check_interval_ms`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.lsm.compaction_check_interval_ms' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.lsm] flush_check_interval_ms Pause in milliseconds between two turns of the flush loop of the relational engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The pause, in milliseconds, between two turns of the flush loop of the relational engine. In each turn the loop wrote a frozen MemTable to an SSTable, if there was one, and then slept for this long. The default was `100`. The server did not check the value. ### Background Since v0.5.1 the pause is fixed at 100 milliseconds, the former default. The key-value engine keeps its own setting, `lsm.flush_check_interval_ms`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.lsm.flush_check_interval_ms' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.lsm] max_value_size Largest value in bytes that the storage of the relational engine accepted. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The largest value, in bytes, that the storage of the relational engine accepted. A write of a value above it, such as a row, was refused by the engine with `Value length N exceeds maximum of M bytes`; `rel.max_row_size` limited the encoded row separately. The default was `524288` (512 KiB). The value must not exceed 100663296 bytes (96 MiB), the largest field that the recovery of the write-ahead log reads; the start was refused with `invalid config: rel.lsm.max_value_size (…) exceeds the WAL recovery field cap (100663296 bytes) — writes this large could never be recovered` otherwise. ### Background `rel.max_row_size` replaces it. Since v0.5.1 the storage limit of the relational engine follows that key: it is the larger of 512 KiB and `rel.max_row_size`, so one key sets the size of rows. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.lsm.max_value_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.lsm] memtable_size_threshold Size in bytes at which a MemTable of the relational engine was flushed. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The size, in bytes, at which the active MemTable of the relational engine was frozen and queued to be written to an SSTable at level 0. The size counted the encoded keys and the values kept inline, and a value in the value log counted only with its pointer. The default was `4194304` (4 MiB). The server did not check the value. ### Background Since v0.5.1 the relational engine uses the built-in size of 4 MiB, the former default, and it cannot be changed. The key-value engine keeps its own setting, `lsm.memtable_size_threshold`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.lsm.memtable_size_threshold' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.lsm] use_mmap Whether the relational engine memory-mapped its SSTables. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect Whether the relational engine opened its SSTables as memory-mapped files (`true`, the default) or read each file completely into memory (`false`). The choice applied to every SSTable the engine opened: at start, after a flush, and after a compaction or a cleanup of the value log. The server did not check the value. ### Background Since v0.5.1 the SSTables of every engine are always memory-mapped. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.lsm.use_mmap' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.lsm] vlog_inline_threshold Value size in bytes from which the relational engine stored values in the value log. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect A value of at least this many bytes was appended to the value log of the relational engine when it was written; the MemTable and the SSTables then kept only a pointer to it. A shorter value stayed inline. The default was `1024`. The server did not check the value. ### Background Since v0.5.1 the relational engine uses the built-in value `1024`, the former default, and it cannot be changed. The key-value engine keeps its own setting, `lsm.vlog_inline_threshold`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.lsm.vlog_inline_threshold' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.lsm] wal_event_channel_capacity Capacity of the write-event channel of the relational engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The capacity of the broadcast channel on which the engine of the relational engine published its write events. Only the watch of the key-value engine read events from such a channel, so for the relational engine the key sized a channel that nothing listened to. The default was `256`. The server did not check the value. ### Background Since v0.5.1 the channel has the built-in capacity of 256, the former default. The key-value engine keeps its own setting, `lsm.wal_event_channel_capacity`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.lsm.wal_event_channel_capacity' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel.lsm] watch_replay_buffer_size Size of the watch replay ring of the relational engine, which the server never used. - Since: v0.4.0 - Removed in: v0.5.1 ### Effect The size of the ring that keeps change events for clients that reconnect to a watch stream. The relational engine has no watch, and the server set the ring size of its engine to `0` whatever this key said, so the value was read from the file and never used. The default was `1024`. ### Background Watch streams of data changes exist for the key-value engine only; their replay ring is set by `lsm.watch_replay_buffer_size`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.lsm.watch_replay_buffer_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] max_columns Largest number of columns of a table. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The largest number of columns a table could have. `CREATE TABLE` with more columns, `ALTER TABLE … ADD COLUMN` on a table that already had this many, and the creation of a table from a file with more columns were refused with `limit exceeded: max_columns (max N)`; the REST API answered `400`. The default was `128`. The server did not check the value. ### Background Since v0.5.1 the limit is fixed at 128, the former default. `rel.max_tables_per_domain` still limits the tables of a domain. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.max_columns' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] max_indexes_per_table Largest number of indexes of a table. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The largest number of indexes a table could have. `CREATE TABLE` with more `UNIQUE` columns than this (the primary key does not count), and `CREATE INDEX` on a table that already had this many indexes, were refused with `limit exceeded: max_indexes_per_table (max N)`; the REST API answered `400`. The default was `16`. The server did not check the value. ### Background Since v0.5.1 the limit is fixed at 16, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.max_indexes_per_table' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] max_join_depth Largest number of join stages of a statement. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The largest number of join stages that one statement could use. Each `LEFT JOIN` counted as one, and so did each expanded link column; a statement over the limit was refused with `400` and `join depth N exceeds the maximum of M`. A view was checked when it was created. The default was `8`. The server did not check the value. ### Background Since v0.5.1 the limit is fixed at 8, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.max_join_depth' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] max_response_bytes Largest serialized response of a SQL statement or row listing in bytes. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The largest serialized response, in bytes, of a `POST /store-api/rel/{domain}/sql` statement or of the row endpoint of a table, expanded links included. A larger response was refused with `413` and `Payload Too Large: response exceeds max_response_bytes; reduce LIMIT`. The default was `33554432` (32 MiB). The server did not check the value. ### Background Since v0.5.1 the limit is fixed at 32 MiB, the former default. Keep the result below it with `LIMIT`; `rel.max_limit` caps the number of rows. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.max_response_bytes' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] max_statement_len Longest SQL statement in bytes. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The longest SQL statement, in bytes, that the relational engine accepted. A longer statement was refused before it was parsed, with `400` and `statement length N exceeds maximum of M bytes`. The default was `65536` (64 KiB). The server did not check the value. ### Background Since v0.5.1 the limit is fixed at 64 KiB, the former default. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.max_statement_len' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] max_text_len Longest TEXT value in bytes. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The longest value, in bytes, of a `TEXT` column, including the link columns `KVREF` and `JSONREF`, that an `INSERT` or `UPDATE` could write. A longer value was refused with `400` and `text length N exceeds maximum of M bytes`. The default was `65536` (64 KiB). The server did not check the value. ### Background Since v0.5.1 the limit is fixed at 64 KiB, the former default. `rel.max_row_size` still limits the whole row. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.max_text_len' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] purger_batch_size Number of keys that one purge step removed from a deleted relational domain. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of keys that one purge step of the relational engine removed from a deleted domain. A deleted domain is unreachable at once, and a background task removes its keys in steps of this size: rows, index entries and AUTOINCREMENT counters; once nothing is left the task removes the domain itself. The same task also reaped the data of dropped tables and indexes, with the same step size. A value of `0` was treated as `1`. The default was `100`. ### Background Since v0.5.1 the step is fixed at 100 keys, the former default; the purge of the key-value engine is set by `domains.purger_batch_size`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.purger_batch_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [rel] purger_interval_secs Seconds between two purge steps of the relational engine. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The number of seconds between two purge steps of the relational engine, the background task that removes the keys of deleted domains in steps of `rel.purger_batch_size` (removed). The default was `5`. The server did not check the value. ### Background Since v0.5.1 the pause is fixed at 5 seconds, the former default; the purge of the key-value engine is set by `domains.purger_interval_secs`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'rel.purger_interval_secs' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [server] unix_socket_mode File mode of the Unix socket. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The file mode that the server gave the socket named by `server.unix_socket_path` once it had bound it. The value was a whole number, written in decimal in TOML: `432` is `0o660`. Without the key the mode was `0o660`, which lets the owner and the group of the socket read and write it. The key had no effect while no socket path was set. The server did not check the value. ### Background Who may connect to the socket was decided by this mode together with the owner and the group of the socket and the permissions of its directory. Since v0.5.1 the mode is always `0o660`; give clients access through the owner or the group of the socket. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'server.unix_socket_mode' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [shm] command_buffer_size Size in bytes of the command and response rings of each shared-memory client. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The size, in bytes, of the ring buffers that each client of the shared-memory interface received when it registered, for commands to the server and for responses. It applied only with `shm.enabled` set to `true`. The default was `4194304` (4 MiB). The value had to be a power of two and at least 4096; otherwise the start was refused with `shm.command_buffer_size must be a power of two, got N` or `shm.command_buffer_size must be at least 4096 bytes, got N`. ### Background Since v0.5.1 the rings have the fixed size of 4 MiB. The size of the snapshot buffers is still set by `shm.data_buffer_size`. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'shm.command_buffer_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [shm] segment_mode File mode of the shared-memory segments. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The file mode that the server gave the shared-memory segments it created, the state and data segments and the rings of each client. The value was a whole number, written in decimal in TOML: `432` is `0o660`. It applied only with `shm.enabled` set to `true`. The default was `0o660` (`432`). The server did not check the value. ### Background Since v0.5.1 the mode is always `0o660`, so the segments cannot be opened up to other users through the configuration. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'shm.segment_mode' is ignored` as a warning, once, at startup. Remove the line to silence the warning. ## [shm] state_size Size in bytes of the state segment of the shared-memory interface. - Since: v0.1.0 - Removed in: v0.5.1 ### Effect The size, in bytes, of the shared-memory segment `state`, which holds the state header of the shared-memory interface. It applied only with `shm.enabled` set to `true`. The default was `4096`. The value had to be at least the size of the state header; otherwise the start was refused with `shm.state_size must be at least N bytes, got M`. ### Background Since v0.5.1 the segment has the fixed size of 4096 bytes. The v0.5.1 server accepts a `luradb.toml` that still sets the key: it starts normally, ignores the value and logs `unknown config key 'shm.state_size' is ignored` as a warning, once, at startup. Remove the line to silence the warning. # Security Source: https://docs.luradb.org/operating/security/ API keys, permissions, trusted Unix users, TLS and CORS. With authentication on, which is the packaged default, LuraDB checks an API key on every request; `GET /health` is the exception. This page covers API keys, admin accounts, permissions per domain, key rotation, trusted Unix users, TLS and CORS. ## Every request carries an API key A client sends its key as a Bearer token in the `Authorization` header. The scheme is written `Bearer`, followed by one space. A request without a valid key answers `401`; a valid key without the right for the request answers `403`. ```sh curl -si http://127.0.0.1:3000/store-api/kv/default/keys/hello curl -s http://127.0.0.1:3000/store-api/auth/whoami -H "Authorization: Bearer $KEY" ``` ```text HTTP/1.1 401 Unauthorized content-type: text/plain; charset=utf-8 Unauthorized ``` ```json { "name": "admin", "role": "Admin" } ``` A removed, rotated or never issued key is the same as no key: `401`. There are two kinds of accounts. An **admin** passes every check and is the only kind that can create domains and users, read metrics and the effective configuration, and manage backups. A **user** reaches only the domains it has a permission on, see [Users and permissions](#users-and-permissions). | Request | What it needs | Without it | |---|---|---| | `GET /health` | Nothing. | | | `GET /` | Nothing. The route exists only while `server.hello_enabled` is on; the packaged file turns it off, the built-in default turns it on. | | | `GET /version`, `GET /store-api/auth/whoami` | Any valid key. | `401` | | The Swagger UI and `/api-docs/openapi.json`, when `server.swagger_enabled` is on | Nothing. The calls made from the UI need a key like any other request. | | | `GET /store-api/domains` | Any valid key. A user sees only the domains it has a permission on. | `401` | | `GET /store-api/domains/{name}` | A permission on the domain, in any engine. | `403` | | Requests under `/store-api/kv/{domain}`, `/json/{domain}`, `/rel/{domain}` | A permission on the domain, or on that engine of it. | `403` | | Everything else under `/store-api`: creating and deleting domains, users, backups, metrics, configuration, events, logs | An admin key. | `403` | The packaged file sets `auth.enabled` to `true`. The built-in default is `false`, which is accepted only on a loopback address: with another bind address the start is refused. With authentication off, every request is accepted and `whoami` answers `{"name":null,"role":"Disabled"}`. LuraDB stores only the SHA-256 hash of a user key. A user key looks like `lura_` followed by 64 hexadecimal digits, and the server shows it once, in the response that creates or rotates it. ## Admin accounts live in luradb.toml Admins are not created through the API. Each `[[auth.admins]]` block of `luradb.toml` is one admin account: ```toml [[auth.admins]] name = "admin" api_key = "lura_…" ``` At every start the server makes the stored admins equal to this list: it creates or updates each listed admin from its key and removes every stored admin that is not listed. The log says what happened: ```text INFO luradb::auth: Auth: removed stale admin 'deploy' INFO luradb::auth: Auth: admin 'admin' reconciled ``` The configuration is read once at start, so a change of an admin key or a new admin takes effect with a restart. After the restart with a new `auth.admins.api_key`, the old key answers `401` and the new one is accepted: ```sh curl -si http://127.0.0.1:3000/store-api/auth/whoami -H "Authorization: Bearer $OLD_KEY" curl -s http://127.0.0.1:3000/store-api/auth/whoami -H "Authorization: Bearer $NEW_KEY" ``` ```text HTTP/1.1 401 Unauthorized ``` ```json { "name": "admin", "role": "Admin" } ``` A second block with another `auth.admins.name` adds a second admin. It appears in `GET /store-api/auth/users` with `"role": "Admin"`, and removing the block removes the account and its key at the next start. The key is stored in clear text in the configuration file, which is why the package installs it with mode `640` and the owner `root:luradb`. `GET /store-api/config` shows the name of each admin and leaves the key out. With authentication on and no admin listed, the server starts and logs `Auth is enabled but no admins are configured in luradb.toml`. Nobody can then act as admin: only users created earlier and trusted Unix users get through. ## Users and permissions Users are created through the API and carry the permissions an admin gives them. A user name is 1 to 50 characters of `a-z`, `A-Z`, `0-9`, `_` and `-`. ```sh curl -s -X POST http://127.0.0.1:3000/store-api/auth/users \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"name": "reporter"}' ``` ```json { "name": "reporter", "role": "User", "api_key": "lura_a7d8bfb8…" } ``` A name that exists answers `409 Conflict: user already exists`, a name outside the rule answers `400`. A new user has no permissions: its requests to a domain answer `403`. A permission names a **domain** and a **level**, and optionally an **engine**: `kv`, `json` or `rel`. Without an engine it covers the whole domain, its keys, documents and tables; with one, only that part of it. ```sh curl -s -X POST http://127.0.0.1:3000/store-api/auth/users/reporter/permissions \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"domain": "sessions", "access": "read"}' curl -s -X POST http://127.0.0.1:3000/store-api/auth/users/reporter/permissions \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"domain": "orders", "access": "write", "engine": "json"}' ``` Both calls answer `200` with an empty body. Setting a permission again replaces the level. The levels build on each other: | Level | Allows | |---|---| | `read` | Reading: `GET`, JSON `search`, SQL `SELECT`. | | `write` | Also writing: `PUT`, `POST`, `PATCH` and `DELETE` on keys, documents, rows, bulk loads and indexes, and the SQL statements `INSERT`, `UPDATE` and `DELETE`. | | `ddl` | Also the SQL statements `CREATE`, `ALTER` and `DROP`. For keys and documents it is the same as `write`. | A user holds either one permission on the whole domain or permissions on its engines, never both. A permission on the whole domain replaces the user's engine permissions on it. A permission on one engine first turns a permission on the whole domain into one of the same level for each engine, and then sets the named engine. The domain must exist and be active, or the call answers `404 Not Found: domain not found`. With `?allow_missing=true` the check is skipped, which lets you grant a permission before the domain is created. An `access` outside the three levels or an unknown `engine` answers `400`, and so does the field `store_type`, which earlier versions used for the engine. `GET /store-api/auth/users` lists every account, admins included, with the permissions of each. API keys are never in the list. ```sh curl -s http://127.0.0.1:3000/store-api/auth/users -H "Authorization: Bearer $KEY" ``` ```json [ { "name": "reporter", "role": "User", "created_at": 1794251616, "permissions": [ { "domain": "sessions", "access": "read" }, { "domain": "orders", "engine": "json", "access": "write" } ] }, { "name": "admin", "role": "Admin", "created_at": 1794251615, "permissions": [] } ] ``` `engine` is missing for a permission on the whole domain. The permissions of an admin do not restrict it; an admin passes every check, whatever its list says. With the key of `reporter`, requests end like this: | Request | Answer | |---|---| | `GET /store-api/kv/sessions/keys/s-4f2a` | `200` | | `PUT /store-api/kv/sessions/keys/s-4f2a` | `403`: the level is `read`. | | `GET /store-api/kv/default/keys/hello` | `403`: no permission on `default`. | | `POST /store-api/json/orders/documents` | `201` | | `POST /store-api/rel/orders/sql` with a `SELECT` | `403`: the permission on `orders` covers the JSON engine only. | | `GET /store-api/domains` | `200`, listing `orders` and `sessions`. | | `GET /store-api/auth/users`, `GET /store-api/metrics` | `403`: admin only. | | `POST /store-api/domains` | `403`: creating a domain is admin only. | | `GET /version` | `200` | A relational link to a key or document needs read permission on the keys or documents too, see [Domains and engines](https://docs.luradb.org/how-it-works/domains-and-engines/#a-row-can-point-at-a-key-or-a-document). To take permissions away, delete them. Without `engine` in the query, every permission of the user on the domain goes; with `?engine=`, only the one on that engine, and a permission on the whole domain becomes one of the same level on each of the other two engines. The next request of the user answers `403`: ```sh curl -si -X DELETE http://127.0.0.1:3000/store-api/auth/users/reporter/permissions/sessions \ -H "Authorization: Bearer $KEY" curl -si -X DELETE "http://127.0.0.1:3000/store-api/auth/users/reporter/permissions/orders?engine=json" \ -H "Authorization: Bearer $KEY" ``` ```text HTTP/1.1 204 No Content ``` A permission that does not exist answers `404 Not Found: permission not found`. Deleting a user with `DELETE /store-api/auth/users/{name}` removes the account and all its permissions, and its key stops working at once. Deleting a domain deletes the permissions on it; a domain created later under the same name starts without any. ## Rotating a key A user key is rotated through the API. The new key is returned once, and the old key stops working in the same moment: ```sh curl -s -X POST http://127.0.0.1:3000/store-api/auth/users/reporter/rotate-key \ -H "Authorization: Bearer $KEY" ``` ```json { "name": "reporter", "api_key": "lura_c8a7d87f…" } ``` ```text HTTP/1.1 401 Unauthorized ``` The last block is the answer to the next request with the old key: `401`. An admin key is rotated in `luradb.toml`, as described above, and takes effect with a restart. If you suspect that a key leaked, rotate it first and look for what it did afterwards. Clients that signed in to the MCP listener with OAuth hold tokens that are tied to the key they signed in with. When that key is rotated, their tokens stop working and they have to sign in again, see [MCP server](https://docs.luradb.org/using/mcp-server/). ## Unix socket and trusted users A local client can reach LuraDB over a Unix domain socket instead of TCP. The socket is off until `server.unix_socket_path` is set; the packaged file sets it to `/run/luradb/luradb.sock`, a directory that systemd creates for the service, see [systemd and Docker](https://docs.luradb.org/operating/systemd-and-docker/). The socket file has the fixed mode `0660`, so only its owner and the members of its group can connect. The service runs as `luradb`, and a local user joins the group with: ```sh sudo usermod -aG luradb ``` The user has to log in again for the membership to take effect. Connecting is not authenticating: a client on the socket still sends a key, and without one it gets `401`. ```sh curl -si --unix-socket /run/luradb/luradb.sock http://localhost/store-api/auth/whoami ``` ```text HTTP/1.1 401 Unauthorized content-type: text/plain; charset=utf-8 Unauthorized ``` `auth.trusted_uids` lists Unix user IDs that need no key. The kernel tells the server the user ID of the process at the other end of the socket, and a process whose ID is on the list is an admin for as long as the connection lasts: ```toml [auth] trusted_uids = [1000] ``` ```sh curl -s --unix-socket /run/luradb/luradb.sock http://localhost/store-api/auth/whoami curl -s --unix-socket /run/luradb/luradb.sock -X PUT http://localhost/store-api/kv/default/keys/from-socket -d hello curl -si http://127.0.0.1:3000/store-api/kv/default/keys/from-socket ``` ```json { "name": null, "role": "TrustedPeer" } ``` The `PUT` answers `200` without a key. The same read over TCP, the last request, still answers `401`: trust applies to the socket only. The list is empty by default. Put only the users there whose processes you would give the admin key anyway, because a trusted process can create users, delete domains and read every key. The setting has no effect with `auth.enabled` off. The shared-memory read path (`shm.enabled`) registers its clients on a Unix socket of its own and applies the same list. ## HTTPS LuraDB can end TLS itself on a port of its own, next to the plain HTTP port. This is the quickstart of the package with a self-signed certificate. Create the certificate in the directory the package prepared, which only root and the group `luradb` can enter: ```sh sudo openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 \ -keyout /etc/luradb/tls/server.key -out /etc/luradb/tls/server.crt \ -days 365 -nodes -subj "/CN=localhost" \ -addext "subjectAltName=DNS:localhost,IP:127.0.0.1" \ -addext "basicConstraints=critical,CA:FALSE" sudo chown root:luradb /etc/luradb/tls/server.key sudo chmod 640 /etc/luradb/tls/server.key ``` LuraDB does not check the permissions of the key file; keeping it private is up to you. Turn the listener on in `luradb.toml` and restart: ```toml [server] tls_enabled = true ``` ```sh sudo systemctl restart luradb curl --cacert /etc/luradb/tls/server.crt https://127.0.0.1:3443/health curl -k https://127.0.0.1:3443/health ``` The log names the new listener next to the plain one: ```text INFO luradb::server: Listening on https://127.0.0.1:3443 INFO luradb::server: Listening on http://127.0.0.1:3000 ``` The first `curl` pins the certificate and answers like the plain port. Without `--cacert` a self-signed certificate is not trusted and `curl` ends with exit code 60; `-k` skips the check, which is acceptable for a test and nothing else. The request over TLS is served by the same router, so keys, permissions and CORS behave as on the plain port, and `curl --http2` negotiates HTTP/2. - **Ports.** The HTTPS port is `server.tls_port` (`3443`) and must differ from `server.port`. To serve only HTTPS, set `server.http_enabled` to `false`; at least one of the two must stay on. - **Files.** `server.tls_cert_path` is a PEM file with the certificate and, if you have it, the chain after it. `server.tls_key_path` is a PEM private key in PKCS#8, RSA or EC form. A file that cannot be opened or parsed stops the start and the message names the key and the path. - **Protocol.** The listener offers `h2` and `http/1.1` through ALPN and asks for no client certificate. A connection that has not finished the handshake after 10 seconds is dropped. - **Renewal.** Certificate and key are read at start. A renewed certificate takes effect with a restart; there is no reload. - **MCP.** With TLS on, the MCP listener serves HTTPS with the same certificate. - **Public certificates.** For a certificate from a public or internal CA, for example one issued by `certbot`, point the two path keys at those files. TLS can also end at a reverse proxy in front of LuraDB, which then keeps its default loopback address. ## CORS for browser clients A browser blocks the answer to a request that goes to another origin unless the response carries `Access-Control-*` headers. CORS is off. Turn it on with the exact origins your pages are served from: ```toml [cors] enabled = true allowed_origins = ["https://console.example.com", "http://localhost:5173"] ``` Each entry is `scheme://host[:port]`, in lower case, without path, query or user information. The single entry `"*"` allows every origin; mixing it with other entries is refused at start, as is `cors.enabled` at `true` with an empty list. The start log warns about `"*"`. It does not weaken authentication: every request still needs a valid key, it only drops the origin check as an extra line of defence. Methods, headers and cache time are fixed by the server and not configurable. The CORS layer runs before authentication, so a preflight request needs no key. A preflight from an allowed origin gets the allow headers; from any other origin the same headers come back without `access-control-allow-origin`, and the browser refuses the real request: ```sh curl -si -X OPTIONS http://127.0.0.1:3000/store-api/kv/default/keys/hello \ -H "Origin: https://console.example.com" \ -H "Access-Control-Request-Method: PUT" \ -H "Access-Control-Request-Headers: authorization,if-match" ``` ```text HTTP/1.1 200 OK access-control-allow-origin: https://console.example.com vary: origin, access-control-request-method, access-control-request-headers access-control-allow-methods: GET,HEAD,POST,PUT,PATCH,DELETE access-control-allow-headers: authorization,content-type,if-match,if-none-match,last-event-id access-control-max-age: 3600 content-length: 0 ``` A request from an allowed origin gets `access-control-allow-origin` on its answer, and the answer exposes `etag` and `x-expires-at` to the page, which a browser hides from scripts otherwise: ```sh curl -si http://127.0.0.1:3000/store-api/kv/default/keys/hello \ -H "Origin: https://console.example.com" -H "Authorization: Bearer $KEY" ``` ```text HTTP/1.1 404 Not Found vary: origin, access-control-request-method, access-control-request-headers access-control-allow-origin: https://console.example.com access-control-expose-headers: etag,x-expires-at ``` ## Behind a reverse proxy When a proxy sits in front of LuraDB, every connection comes from the proxy's address. `proxy.trusted_proxies` lists the proxies, as addresses or CIDR ranges, whose forwarded-address headers LuraDB believes. For a request from a listed address, the server takes the client address from `X-Real-IP`, and failing that from the rightmost public address of `X-Forwarded-For`; private, loopback and link-local addresses in that header are skipped. For any other peer the headers are ignored and the connection address counts. The packaged file lists `127.0.0.1` and `::1`; the built-in default is an empty list. At the debug level, with `log.level` set to `"verbose"`, each request logs both addresses: ```text DEBUG luradb::api::middleware: request client_ip=203.0.113.9 peer_ip=127.0.0.1 DEBUG luradb::api::middleware: request client_ip=198.51.100.4 peer_ip=127.0.0.1 ``` These lines come from a request with `X-Forwarded-For: 203.0.113.9` and one with `X-Real-IP: 198.51.100.4`. In v0.7.1 the resolved address is used for the counters of the MCP sign-in page, failed sign-ins and client registrations per address, and for this log line. The rate limits of the REST API count per domain and not per client, see [Troubleshooting](https://docs.luradb.org/operating/troubleshooting/#429-a-domain-used-up-its-budget). Related settings: `auth.enabled`, `auth.admins.name`, `auth.admins.api_key`, `auth.trusted_uids`, `server.unix_socket_path`, `server.bind_address`, `server.hello_enabled`, `server.swagger_enabled`, `server.tls_enabled`, `server.tls_port`, `server.tls_cert_path`, `server.tls_key_path`, `server.http_enabled`, `cors.enabled`, `cors.allowed_origins`, `proxy.trusted_proxies` # Monitoring Source: https://docs.luradb.org/operating/monitoring/ Health, metrics, the event stream and logs. `GET /health` needs no key and reports `ok` or `degraded`, with the state of every data shard, of disk space and of memory. With an admin API key, `GET /store-api/metrics` adds the numbers behind it, and `GET /store-api/events` streams lifecycle and DDL changes. The service logs to journald. ## /health says whether to look closer `GET /health` is for load balancers, container health checks and a first look. It needs no key, names no path and gives no size. ```sh curl -s http://127.0.0.1:3000/health ``` ```json { "domain_count": 1, "estimated_memtable_keys": 1, "l0_sstable_count": 0, "resources": { "disk_state": "ok", "memory_state": "ok", "state": "ok" }, "shards": [{ "id": 0, "status": "ok" }, { "id": 1, "status": "ok" }, …, { "id": 7, "status": "ok" }], "status": "ok", "uptime_secs": 2, "version": "0.7.1", "vlog_size_bytes": 0 } ``` | Field | Meaning | |---|---| | `status` | `ok`, or `degraded` while a data shard does not answer, disk space or memory runs short, or writes of a data file fail. | | `shards` | One entry per data shard, `ok` once it answered its ping and `timeout` when it did not answer within 250 ms. | | `resources` | The state of disk space (the worst of all watched volumes) and of memory: `ok`, `warning` or `blocked`, and `state` for the worse of the two. See [Resource guard](https://docs.luradb.org/how-it-works/resource-guard/). | | `io` | Present only while writes of a data file fail: `failures`, the most failures in a row of one file. The third failure stops the server with exit code 3. | | `uptime_secs`, `version` | Seconds since the start, and the server version. | | `domain_count` | Active domains. | | `estimated_memtable_keys`, `vlog_size_bytes`, `l0_sstable_count` | Keys in the key-value MemTables, bytes of the key-value value logs, and key-value SSTables on level 0 that wait for compaction, summed over the data shards. | The HTTP status is `200` as long as every shard answered, also with `"status": "degraded"` for a short disk or memory, because the server still serves reads. When a shard does not answer within 250 ms, the answer is `503` with the full report, and the entry of that shard says `"status": "timeout"`. A health check that treats only `5xx` as a failure, such as `curl -f`, therefore notices a stuck shard but not a volume that is filling up; poll the body and alert on `degraded` to get the early notice. ## The metrics endpoint has the numbers `GET /store-api/metrics` needs an admin key. It answers one JSON object of blocks: ```sh curl -s http://127.0.0.1:3000/store-api/metrics -H "Authorization: Bearer $KEY" ``` ```json { "system": { "total_reads": 5, "total_writes": 5, "compaction_runs": 0, "janitor_runs": 0, "memtable_size_bytes": 352 }, "domains": [ { "domain": "default", "read_ops": 5, "write_ops": 5, "read_latency_us_p50": 5, "read_latency_us_p99": 50, "cache_hit_rate": 1.0, "rate_limit_rejections": 0, "window_secs": 60 } ], "engines": { "kv": { "read_ops": 5, "write_ops": 5, "read_latency_us_p50": 5, "read_latency_us_p95": 50, "read_latency_us_p99": 50, "write_latency_us_p50": 5000, "write_latency_us_p95": 5000, "write_latency_us_p99": 5000, "window_secs": 60 }, "json": { "read_ops": 0, "write_ops": 1, "read_latency_us_p50": 0, "read_latency_us_p95": 0, "read_latency_us_p99": 0, "write_latency_us_p50": 5000, "write_latency_us_p95": 5000, "write_latency_us_p99": 5000, "window_secs": 60 }, "rel": { "read_ops": 0, "write_ops": 0, "read_latency_us_p50": 0, "read_latency_us_p95": 0, "read_latency_us_p99": 0, "write_latency_us_p50": 0, "write_latency_us_p95": 0, "write_latency_us_p99": 0, "window_secs": 60 } }, "block_cache": { "hits": 0, "misses": 0, "small_hits": 0, "main_hits": 0, "small_evictions": 0, "main_evictions": 0, "current_bytes": 0 }, "backup": null, "shm": { "snapshot_publishes_total": 0, "snapshot_publish_skips_total": 0, "snapshot_consecutive_skips": 0, "clients_kicked_total": 0 }, "resources": { "disk": [{ "path": "/var/lib/luradb/sstables", "size_bytes": 1081101176832, "free_bytes": 903771607040, "state": "ok" }], "memory": { "rss_anon_bytes": 6832128, "budget_bytes": 12259857408, "state": "ok" }, "state": "ok" } } ``` | Block | What it counts | |---|---| | `system` | `total_reads` and `total_writes` summed over the data shards; `compaction_runs`, `janitor_runs` and `memtable_size_bytes` of the key-value engines. | | `domains` | One entry per domain over the last 60 seconds, for its keys: operations, read latency, `cache_hit_rate`, and `rate_limit_rejections`, the requests that answered `429`. Requests to documents and tables are counted in `engines`. | | `engines` | `kv`, `json` and `rel`, each with the same nine fields over the window: reads and writes, and the latency percentiles. A disabled engine still has its block, all zero. | | `block_cache` | Hits, misses, evictions and size of the key-value block cache. | | `backup` | `null` while `backup.enabled` is off. Otherwise `last_success_at`, `last_success_at_by_schedule`, `last_duration_ms`, `last_size_bytes`, `running` (the job in progress, if any) and `failed_total`. | | `shm` | Counters of the shared-memory snapshot publisher; all zero while `shm.enabled` is off. | | `resources` | The numbers behind `/health`: per watched volume `path`, `size_bytes`, `free_bytes` and `state`, and the server's anonymous memory against its budget. | | `io` | Present only while writes of a data file fail: the `path` of the file with the most failures in a row, and `failures`. | Three things help in reading it: - **The window is 60 seconds.** The counters are refreshed every second and cover the last 60 full seconds, so `read_ops / window_secs` is an average rate. `total_reads` and `total_writes` in `system` count since the start. - **Latencies are bucket values.** Each operation falls into one of seven buckets, below 10 µs, 100 µs, 1 ms, 10 ms, 100 ms, 1 s, and above. A percentile reports the middle of its bucket: 5, 50, 500, 5000, 50000, 500000 or 2000000 microseconds. `5000` means between 1 and 10 ms, and `0` means that no operation fell into the window. - **There is no Prometheus endpoint.** The answer is JSON; a collector polls it. While a data shard is not running, the endpoint answers `503`. `GET /store-api/metrics/domains/{name}` returns the entry of one domain, and a user with a permission on that domain may call it; it answers `404` for an unknown domain. ## The event stream reports lifecycle changes `GET /store-api/events` is a server-sent-events stream of what happens to domains and schemas. It is for tools that follow the structure of the database, such as an admin console or a cache of domain names. It carries no keys or values; for those, the keys of a domain have their own watch stream, see [Key-value](https://docs.luradb.org/using/key-value/). The stream needs an admin key, and `curl -N` switches off buffering: ```sh curl -N http://127.0.0.1:3000/store-api/events -H "Authorization: Bearer $KEY" ``` ```text id: g-aec51a22fab4ffff-1 event: domain_created data: {"type":"domain_created","domain":"sessions","ts":1794252371} id: g-aec51a22fab4ffff-2 event: domain_created data: {"type":"domain_created","domain":"orders","ts":1794252371} id: g-aec51a22fab4ffff-3 event: index_created data: {"engine":"json","type":"index_created","domain":"orders","object":"status","ts":1794252371} id: g-aec51a22fab4ffff-4 event: table_created data: {"engine":"rel","type":"table_created","domain":"orders","object":"customers","ts":1794252371} id: g-aec51a22fab4ffff-5 event: view_created data: {"engine":"rel","type":"view_created","domain":"orders","object":"lisbon","ts":1794252371} id: g-aec51a22fab4ffff-6 event: domain_deleted data: {"type":"domain_deleted","domain":"sessions","ts":1794252371} id: g-aec51a22fab4ffff-7 event: domain_purged data: {"type":"domain_purged","domain":"sessions","ts":1794252371} ``` These events came from creating the domains `sessions` and `orders`, an index on `status`, a table `customers` and a view `lisbon`, and then deleting `sessions`, which had no data to purge. The `data` field is JSON with the type, the domain, the engine and the name of the table, view or index as `object` where there is one, and the Unix time `ts`. The event types are: | Engine | Types | |---|---| | None, once per domain | `domain_created`, `domain_deleted` (the domain is gone for clients), `domain_purged` (the background purge has removed its data). A restore with `replace` sends none of them. | | JSON | `index_created`, `index_dropped` | | Relational | `table_created`, `table_altered`, `table_dropped`, `index_created`, `index_dropped`, `view_created`, `view_dropped` | Every event has an `id`. After a dropped connection, a client sends the last id it saw as the `Last-Event-ID` header, or as `?last_event_id=` where it cannot set headers, and the server replays what the client missed from a ring in memory. When it cannot replay without a gap, it sends `event: reset` with a reason, and the client should re-read the domain list before it follows the stream again. The reasons are `restart` (the server restarted, so the ring is gone), `lagged` (the client fell more than `events.channel_capacity` events behind) and `unknown_id` (the id is not in the ring). The ring holds `events.replay_buffer_size` events; with `0` every reconnect gets a `reset`. ## Logs go to journald or to files By default LuraDB writes its log to standard output, which systemd hands to the journal: ```sh journalctl -u luradb journalctl -u luradb -f ``` The text format is one line per message, with the time, the level, the module and the message. It carries ANSI colour codes, written to standard output and to files alike. For a log shipper, set `log.format` to `json`, which writes one JSON object per line without colour codes: ```json {"timestamp":"2026-11-03T21:58:18.244543Z","level":"INFO","fields":{"message":"Auth: admin 'admin' reconciled"},"target":"luradb::auth"} ``` `log.level` picks the amount: `verbose` (debug), `info` and `prod`, which logs warnings and errors only. The environment variable `RUST_LOG` overrides the configured levels when it is set. A level per module goes into `[log.modules]`; a module without a level uses the global one, and the modules are `log.modules.auth`, `log.modules.api`, `log.modules.engine` and `log.modules.storage`. With `log.path` set, the log goes to files in that directory instead of standard output, and the directory is created if it is missing. A path the server cannot create or write stops the start with a message, see [Troubleshooting](https://docs.luradb.org/operating/troubleshooting/#a-log-directory-that-cannot-be-created). `log.rotation` names the file; any other value stops the start: | Rotation | File name | |---|---| | `daily` | `luradb.log.2026-11-09` | | `hourly` | `luradb.log.2026-11-09-19` | | `none` | `luradb.log` | `log.retention_days` deletes rotated files older than that many days, judged by their modification time, with `0` keeping them forever. The cleanup runs once for every 24 hours the server is up, counted from its start, so a server that is restarted more often than that never cleans up. Lines worth searching for: | In the log | Means | |---|---| | `Resources running short: disk … Nothing is refused yet` | A volume is below its warn threshold. | | `Writes refused: …` | A volume or the memory is below its block threshold; writes answer `507`. | | `Writes are accepted again: …` | The shortage is over. | | `data sync failed on `, `data write failed on ` | The disk failed; the server stops with exit code 3. | | `[Backup] job '…' completed`, `[Backup Scheduler] …` | A backup finished, or a scheduled one was skipped. | | `unknown config key '…' is ignored` | The configuration names a key that does not exist or was removed. | ## Reading the log over HTTP With `log.http_access` on, an admin reads the log files through the API. It needs `log.path`, because standard output cannot be read back. `GET /store-api/logs/files` lists the files, newest first, and `GET /store-api/logs` returns the end of one: ```sh curl -s http://127.0.0.1:3000/store-api/logs/files -H "Authorization: Bearer $KEY" curl -s "http://127.0.0.1:3000/store-api/logs?lines=2&q=Shard" -H "Authorization: Bearer $KEY" ``` ```json { "files": [{ "file": "luradb.log.2026-11-09", "size": 3923, "modified": 1794252383 }] } ``` ```json { "file": "luradb.log.2026-11-09", "format": "text", "lines": [ "… INFO luradb::server::control: Shard 6: block cache 8192 KiB per engine; MemTable threshold 4194304 bytes per engine; registered I/O buffers off.", "… INFO luradb::server::control: Shard 7: block cache 8192 KiB per engine; MemTable threshold 4194304 bytes per engine; registered I/O buffers off." ], "truncated": false } ``` | Parameter | Effect | |---|---| | `lines` | The number of lines from the end of the file: 100 by default, at most 1000. `0` answers `400`. | | `q` | Only lines that contain this text, case-sensitive; only matching lines count towards `lines`. | | `file` | A name from the file list, which must start with `luradb.log`. A name with a path answers `400`, an unknown file `404`. Without it, the newest file. | The lines come back oldest first. The server reads backwards through at most 4 MiB of the file; when it stops there before it has `lines` matches, `truncated` is `true`. Without `log.http_access`, both endpoints answer `503 Service Unavailable: log access is disabled (log.http_access = false)`. With `auth.enabled` off, anyone who reaches the port can read the log, and the start log warns about it. ## What to alert on | Signal | Where | What to do | |---|---|---| | `"status": "degraded"` and `resources.state` | `/health` | Free space or memory is short, see [Resource guard](https://docs.luradb.org/how-it-works/resource-guard/). | | HTTP `503` and a shard with `"timeout"` | `/health` | A data shard does not answer within 250 ms. Look in the log of the same minute. | | `io.failures` above 0 | `/health`, `/store-api/metrics` | Writes of a data file fail. The file is named in the metrics. | | `backup.last_success_at` older than the schedule allows, `backup.failed_total` growing | `/store-api/metrics` | Backups do not complete, see [Backup and restore](https://docs.luradb.org/operating/backup-and-restore/). | | `rate_limit_rejections` above 0 for a domain | `/store-api/metrics` | The domain uses up its budget, see [Troubleshooting](https://docs.luradb.org/operating/troubleshooting/#429-a-domain-used-up-its-budget). | | `l0_sstable_count` keeps growing | `/health` | Level-0 SSTables appear faster than compaction merges them. Compaction starts at `compaction.l0_threshold` files. | Related settings: `log.level`, `log.format`, `log.path`, `log.rotation`, `log.retention_days`, `log.http_access`, `log.modules.auth`, `log.modules.api`, `log.modules.engine`, `log.modules.storage`, `events.channel_capacity`, `events.replay_buffer_size`, `resources.disk_free_warn`, `resources.memory_budget` # Backup and restore Source: https://docs.luradb.org/operating/backup-and-restore/ Logical backups on demand and by schedule, and how to restore them. A backup, started with `POST /store-api/backups` or by a schedule in `[backup]`, is a logical NDJSON archive of domains: their keys, documents and tables. The scope picks what goes in: everything, one engine of every domain, one whole domain, or one engine of one domain. An archive does not copy files. It lists what the domains hold, so it restores into any shard count, and it can move data to another server. The server writes format version 3 and restores archives of format version 1 to 3. Backups and restores are admin-only. ## Turn backups on Backups are off. While `backup.enabled` is `false`, every backup endpoint answers `503 Service Unavailable: backup is disabled (backup.enabled = false)`. ```toml [backup] enabled = true dir = "/var/lib/luradb/backups" ``` `backup.dir` is where the archives are kept, one file `bk_