hazine
hazine runs a DuckDB server that speaks the Quack protocol, for a DuckLake catalog, on localhost only. Clients reach it through an SSH tunnel.
It follows the pattern of DuckDB's own Quack deployment
(duckdb-quack-infra): the
DuckDB CLI runs an init file that ends in quack_serve, and keeps serving for
as long as its stdin stays open. hazine replaces sleep infinity | duckdb -init init.sql with a supervisor that:
- refuses any non-loopback listen address,
- checks that the CLI is DuckDB 2.0 or later,
- holds DuckDB's stdin open, and closes it to stop DuckDB cleanly on SIGTERM
(killing it after
--stop-timeout), - forwards DuckDB's output to its log (text or JSON), with the token and other secrets redacted,
- restarts DuckDB with backoff, and exits non-zero after
--max-failuresfailed starts in a row, so systemd sees the failure.
nginx and TLS are not needed: the SSH tunnel provides authentication and encryption, and Quack checks a token on top.
The DuckLake catalog lives in a Postgres server and the data in
S3-compatible object storage, both elsewhere. The catalog is DuckDB's main
database, so every Quack session uses it without USE or qualified names.
Requirements
- Linux with systemd, for
hazine setup - A Postgres database for the catalog, and an S3 bucket for the data
- Rust ≥ 1.85 to build (
cargo install hazine)
Server setup
hazine setup does everything as root:
- installs hazine as
/usr/local/bin/hazine - downloads the DuckDB CLI (2.0.1 by default) as
/usr/local/bin/duckdb - creates the
hazinesystem user, home/var/lib/hazine - installs the
quack,ducklake,postgresandhttpfsextensions for it - attaches the lake once, to check the settings, creating the DuckLake catalog with its data path the first time
- writes
/etc/hazine/init.sql,/etc/hazine/hazine.env(secrets,0640 root:hazine) and/etc/systemd/system/hazine.service, sized to the machine's CPUs and RAM - enables and starts the service
Setup asks for anything it needs that isn't given as a flag:
- the Postgres host
- the data path
- the S3 endpoint, region and URL style
- the Postgres password and the S3 keys, without echoing them
It offers the values from the last run as defaults. For Hetzner Object
Storage, the endpoint is <location>.your-objectstorage.com; setup then
suggests the location as the region (e.g. fsn1) and path as the URL style.
For unattended runs, pass the secrets as HAZINE_PG_PASSWORD,
HAZINE_S3_KEY_ID and HAZINE_S3_SECRET in the environment. Flags work too,
but other users can see them in the process list.
Add --dry-run to see the plan and the files first (secrets redacted, no root
needed). Rerun setup to change settings. Secrets and the Quack token are kept
from the existing hazine.env unless you give new ones. A changed file is
kept as <file>.bak. If the lake check fails, nothing is written. The
service restarts only if something changed.
Postgres connections use --pg-sslmode require by default. The data path is
stored in the catalog the first time and cannot be changed by rerunning
setup.
Connecting
LOAD quack;
FROM quack_query('quack:127.0.0.1:1294', 'SELECT count(*) FROM my_table',
token = '<QUACK_TOKEN>', disable_ssl = true);
Get the token on the server with
sudo sed -n 's/^QUACK_TOKEN=//p' /etc/hazine/hazine.env.
In the DuckDB UI
On your own machine (macOS or Linux, with the DuckDB 2.0 CLI and cargo install hazine):
This opens the SSH tunnel and starts the DuckDB UI
in your browser, with the server attached as a database named after the host
(hermione). Browse its tables in the UI, or query them as
hermione.my_table. Quit DuckDB in the terminal (.exit or Ctrl-D) to close
the tunnel; Ctrl-C cancels a running query.
The token is read from the server's /etc/hazine/hazine.env over SSH, which
needs sudo without a password there; otherwise set HAZINE_TOKEN. Options:
--name, --local-port (tunnel, default 1294), --ui-port (default 4213;
use another if a DuckDB UI is already open), --database (a local file to
open alongside), --no-open (print the UI's URL instead of opening it).
OpenAlex
hazine can import the OpenAlex snapshot (CC0), which
OpenAlex publishes quarterly as Parquet in the public bucket
s3://openalex/data/parquet/. Each release replaces the previous one there,
so import a release to keep it. On the server, as root, in tmux (the full
release is about 800 GB and takes hours):
import reads exactly the files in the release's manifest into the schema
openalex_<release date> (e.g. openalex_2026_10_14), one table per entity,
and checks each table's row count against the manifest. It resumes: rerun it
after an interruption, and complete tables are skipped. It stops if OpenAlex
publishes a new release meanwhile. --entities works,authors imports only
some; --threads and --memory-limit (default: half the CPUs, a fifth of
RAM) keep room for hazine serve.
setup creates views in the openalex schema on the newest imported release
(or --release 2026-10-14), so queries don't name a release:
FROM openalex.release; -- which release the views show
SELECT publication_year, count(*) FROM openalex.works GROUP BY ALL ORDER BY 1;
After importing the next release, run setup again to switch; drop old
release schemas when you no longer need them.
Configuration
Precedence: flags > environment > defaults. See hazine setup --help and
hazine serve --help. These are the serve settings; setup writes them to
hazine.env and the unit.
| Flag | Environment | Default |
|---|---|---|
--duckdb |
HAZINE_DUCKDB |
duckdb (from PATH) |
--init |
HAZINE_INIT |
/etc/hazine/init.sql |
--database |
HAZINE_DATABASE |
in memory; setup: ducklake:postgres: |
--quack-addr |
HAZINE_QUACK_ADDR |
127.0.0.1:1294 |
--ready-timeout |
HAZINE_READY_TIMEOUT |
60 seconds |
--stop-timeout |
HAZINE_STOP_TIMEOUT |
30 seconds |
--max-failures |
HAZINE_MAX_FAILURES |
5 |
--log-format |
HAZINE_LOG_FORMAT |
text (or json) |
The log level comes from RUST_LOG (default info).
License
MIT