Developer beta 0.1.0-beta.1 documentation. The build is not available for download yet; these pages describe the beta as built and tested on Linux x86-64.
Server deployment
One server process serves one database directory. There is no clustering, replication or cloud integration in this version; run HolaDB where the data lives.
Installing and running as a service
The release bundle installs everything a service needs
(Installation): the binaries, the holadb system
user, the data directory /var/lib/holadb (0750, owned by that user),
/etc/holadb/holadb.env and the unit /etc/systemd/system/holadb.service.
The unit runs holadb-server as holadb with the settings of the
environment file:
sudo ./install.sh # from the bundle
sudo -e /etc/holadb/holadb.env # endpoints, TLS, archiving, limits
sudo -u holadb holadb init /var/lib/holadb/db
sudo -u holadb holadb users /var/lib/holadb/db create admin --password-stdin
sudo systemctl enable --now holadb
curl http://127.0.0.1:9433/ready # {"ok":true} when serving
journalctl -u holadb -f # JSON log lines
holadb.env holds HOLADB_DATA_DIR, HOLADB_LISTEN, HOLADB_PG,
HOLADB_METRICS and HOLADB_EXTRA_ARGS (any further holadb-server
flags, for example --tls-cert … --tls-key … --require-tls --archive /var/lib/holadb/archive); every value is a flag of
Configuration. The unit sets KillSignal=SIGTERM,
TimeoutStopSec=30 (above --drain-timeout-ms, default 10 s, plus the
time to close), Restart=on-failure, UMask=0027, NoNewPrivileges,
ProtectSystem=full, ProtectHome and PrivateTmp, and writes only
under the data directory. stderr goes to the journal.
Ownership. The database directory and everything in it belong to the
service user and are private to it (holadb init creates files 0600 in a
0700 directory; the installer creates /var/lib/holadb 0750). Run every
offline command (holadb init, users, backup, restore, upgrade,
verify, doctor) as that user (sudo -u holadb …); a database touched
as root ends up with files the service cannot open. The server refuses
to start on a directory another process holds (the lock file names the
holder).
Without the bundle, the equivalent hand-written unit:
[Unit]
Description=HolaDB shop database
After=network.target
[Service]
User=holadb
Group=holadb
ExecStart=/usr/local/bin/holadb serve /srv/holadb/shop \
--listen 127.0.0.1:7433 --pg 127.0.0.1:5433 --metrics 127.0.0.1:9433 \
--log json --audit-log /var/log/holadb/shop-audit.jsonl
Restart=on-failure
KillSignal=SIGTERM
# above --drain-timeout-ms (default 10 s) plus the time to close
TimeoutStopSec=30
# stderr (logs) goes to the journal
[Install]
WantedBy=multi-user.target
Stopping
SIGTERM or SIGINT (Ctrl-C), or an administrator’s Client::shutdown,
runs the stop sequence: new connections are refused, idle connections on
both protocols are closed at once, a statement in progress finishes and
is answered (up to --drain-timeout-ms, default 10 s), the database is
closed and the process lock released, and a stopped event is logged
with reason, clean and exit_status. With idle clients this takes
milliseconds. A second signal ends the process immediately (status
143 / 130; the next start recovers from the WAL).
Exit statuses: 0 clean stop; 1 cannot bind or open; 2 usage error
(nothing opened); 3 fail-stop after an internal panic under the store
lock (the database is not closed; the next start recovers; the
supervisor should restart); 4 the drain timed out with a statement
still holding the database (not closed; the next start recovers).
Restart=on-failure restarts on 3 and 4 and leaves a clean stop alone.
Every acknowledged write is durable before it is acknowledged, so a
non-clean exit never loses one.
Management endpoint
--metrics ADDR serves /health (liveness, never waits for the
database), /ready (readiness: 503 while the database is poisoned,
stopping or unusable), /metrics and /metrics.json. It answers
loopback peers only; to scrape from another host bind it to a private
interface and add --metrics-allow-remote (there is no authentication on
this endpoint: keep it off the public network). Point the supervisor’s
or load balancer’s checks at /ready, and alert on /health failing.
Checklist
- Create the database (
holadb init) as the service user; the directory and its files should be readable only by that user. - Create the first user before exposing any endpoint beyond localhost
(
holadb users /srv/holadb/shop create admin --password-stdin; passwords are never taken on the command line). - Bind endpoints to
127.0.0.1unless clients are on a trusted network; for anything else serve TLS (--tls-cert,--tls-key, and--require-tlsso no client can connect in clear) and give clients the CA certificate (see Security). Size--max-connectionsand--statement-timeout-msfor the workload. - Point Prometheus at
--metricsand alert onholadb_up,holadb_ready,holadb_errors_totalandholadb_slow_statements_total. - Schedule backups: online snapshots from the running
server (
holadb snapshot), or offlineholadb backupwith the server stopped; archive the write-ahead logs (--archive) for point-in-time restore; verify every backup (holadb verify-backup) and rehearse a restore. - Keep
holadb doctorin your runbook. - Before any upgrade take a backup that you have verified (the
rollback), and know the bundle you are upgrading from (
holadb versionprints the commit) so you can reinstall it.
Upgrading
- Stop the server and take a backup (
holadb backup). - Replace the binary and start it: a newer HolaDB opens every database
format a released HolaDB wrote (the database keeps its old per-file
formats; nothing is rewritten by a plain open except the small
FORMATrecord, which older binaries ignore). - When you are done validating, bring the database to the current format
with the server stopped:
holadb upgrade /srv/holadb/shop --backup /backups/shop-pre-upgrade(the backup is required and verified; it is the rollback). The upgrade is journaled: interrupted anywhere, it is refused by the normal open until you runholadb upgradeagain (it resumes) or restore the backup.
Rolling back: before step 3, install the previous bundle again (or put
the previous binaries back) and start them. After an
upgrade, a binary that reads the per-file formats the upgrade wrote still
opens the database; an older one cannot, and there is no downgrade
command: restore the pre-upgrade backup. A binary that meets a database
written by a newer HolaDB refuses it with database format N was written by a newer HolaDB and touches nothing.
Uninstalling
./uninstall.sh from the bundle stops and removes the service, the
binaries, the documentation and /etc/holadb; the data directory stays
unless --purge-data is given. Take and verify a backup first.
Resource use
Memory: the materialised state of every table (its current rows and indexes) is held in memory; disk holds the append-only history and sealed segments. Plan memory for the live data set. CPU: one thread per connection, one writer at a time.
Measured on one machine (4 cores, one SSD, rows of about 100 bytes) with an earlier build of this code line; treat the figures as orders of magnitude for planning, not as guarantees:
- Memory per live row: about 740 bytes (13 MB for 10 000 rows,
83 MB for 100 000, 743 MB for 1 000 000, right after open), plus the
unsealed write-ahead tail at about 320 bytes per event until it is
sealed (
--checkpoint-events, default 50 000, so about 16 MB per table at most), plus 3–4 MB per 64 connections. Sealed segments are read from disk when history is needed and are not kept resident. Connections, threads and descriptors return to the baseline when clients disconnect. - Open time: about 1.3 s per million rows (the persisted record index is decoded, not replayed), plus the index deltas the seals since the last compaction wrote (one entry per row changed since then; the default policy compacts them, off the store lock, before they reach the size of the table, so an open does at most about twice that work); recovery after a crash adds the replay of the unsealed tail, which the checkpoint policy keeps short (0.8 s with 8 480 records in the stress run).
- A seal (checkpoint) stalls statements for 150–280 ms, whatever
the table size. The cost that remains is the sealed
tail’s own: encoding and writing its segment and the delta of the rows
it changed.
holadb_checkpoint_duration_secondsand thestore_lock_wait_seconds{class="read"}maximum show it. - Writes: 3 000–6 500 single-row writes per second with the default
sync on every write, whatever the number of clients (the day-to-day
variation of one machine was 20–25 %; the default checkpoint policy
costs 7–16 % against a server that never seals); latency grows with
concurrency because statements serialise on the store. A
200-row transaction commits in about 370 ms (200 syncs) and holds the
store meanwhile.
--no-syncremoves the per-write sync and its guarantee (see Configuration). - Reads: about 20 000 point reads per second on one client, about 50 000 with 8, the same over both protocols; 7 000 100-row range pages per second, 1 100 1000-row pages.
- Checkpoints (the server’s own or
holadb checkpoint) hold the store, and every statement waits, for a time proportional to the table’s live rows because the record index is persisted with each seal: about 200 ms at 100 000 rows, 1.4 s at 1 M, 3.5 s (up to 4.6 s) at 2.1 M rows in the 24-hour soak, where a seal every ~2 minutes stalled about 1.5 % of the time. Watchholadb_checkpoint_duration_seconds; on large tables a higher--checkpoint-eventsmakes seals rarer at ~320 bytes of memory per unsealed event. - Disk: about 70–100 bytes of history per write; the write-ahead log stays small (under 2 MB in the stress run) because every seal resets it; segments accumulate with the history.
First start of the container image
The image’s default command listens on all interfaces, and a database without users is not served there (see “Listening on a network address” in CONFIGURATION.md). Create the first user before the first start:
docker run --rm -i -v holadb-data:/var/lib/holadb --entrypoint /usr/local/bin/holadb IMAGE \
users /var/lib/holadb/db create admin --password-stdin --role admin
then start the container with the same volume. Appending --allow-open-remote to the command serves without users; use it only on an isolated network.