Skip to content

Storage backends and profiles

Two independent settings decide how the control plane stores state: the backend, which is the database engine, and the profile, which is the durability posture. Both are latched on first start, so this page is the decision you make before you deploy rather than one you revisit.

The backend

XRATU_CP_DB_BACKEND   sqlite | postgres     (default: sqlite)

An unrecognised value falls back to sqlite rather than failing, so a typo produces a file-backed control plane rather than an error.

sqlite stores state in a single file named by XRATU_CP_DB_PATH, which the shipped manifest sets to /data/control_plane.db on the mounted volume. It is the bootstrap shape: enough to stand a control plane up and work through day 0.

postgres uses a connection string in XRATU_CP_DB_DSN and is what a finalized deployment requires. Once the control plane is finalized, a startup or readiness check that observes any backend other than postgres fails with 503, naming the backend it observed.

That last point is the one to plan around: a deployment that finalizes on sqlite will not pass its own health checks. Choose postgres before first start for anything you intend to keep.

The bootstrap profile carries the connection shape rather than a raw string:

db_profile:
  name: default
  active: true
  document:
    engine: postgres
    host: postgres.internal
    port: 5432
    db_name: xratu
    ssl_mode: require
    auth_mode: workload_identity

auth_mode selects between a password reference and workload identity. A password is referenced rather than inlined, as password_secret_ref.

The profile

XRATU_CP_STORE_PROFILE   lightweight | standard | durable     (default: lightweight)

The profile sets how much the store is willing to lose on an abrupt stop. On SQLite it maps directly onto synchronous behaviour:

Profile Synchronous setting Use
lightweight normal Development and bootstrap
standard normal Ordinary operation
durable full Every commit flushed before acknowledgement

An unrecognised value falls back to lightweight, which is the least durable setting, so this is worth asserting explicitly rather than leaving unset.

SQLite tuning

Four further settings apply to the file-backed backend:

XRATU_CP_SQLITE_JOURNAL_MODE            default: wal
XRATU_CP_SQLITE_JOURNAL_FALLBACK_MODE   default: delete
XRATU_CP_BUSY_TIMEOUT_MS                default: 5000
XRATU_CP_CACHE_SIZE_PAGES               default: 20000

Both journal settings accept delete, truncate, persist, memory, wal and off. The fallback exists because some filesystems refuse write-ahead logging: the store requests the primary mode, and on refusal retries with the fallback. If the fallback is the same as the primary, the original error is raised rather than retried.

The shipped manifest sets wal with a delete fallback and a shorter busy timeout of 1500 ms.

Why both are latched

When the control plane is finalized, the backend and profile observed at runtime must match the values recorded at latch time. Drift in either produces a 503 naming both values:

finalized control-plane runtime backend drift detected; latched=postgres observed=sqlite
finalized control-plane runtime store profile drift detected; latched=durable observed=standard

The two settings govern where every record lives and how much of it survives a crash. Changing either on a restart without the latch refusing would move state with no record of the move. See The identity latch.

Only a supported value can be latched at all: activation refuses a backend outside sqlite and postgres, or a profile outside lightweight, standard and durable, with 409.

Checking what is in force

The readiness endpoint reports the observed values alongside the finalization state, which is the quickest way to confirm a deployment is running what you intended:

curl -fsS "${CP_CLI_ENDPOINT}/v1/system/health/readiness" | jq '{db_backend, store_profile, finalization}'

The response carries db_backend, store_profile, db_path, db_dsn_configured and the finalization block containing the latched values. Comparing the observed pair against finalization.locked_db_backend and finalization.locked_store_profile is exactly the check the control plane runs on itself.

Choosing

For anything beyond a throwaway deployment, set postgres and pick a profile that matches your tolerance for loss, then confirm both before the first start. Everything else on this page has a working default; these two do not have a safe one, because the defaults are the bootstrap shape and the finalized runtime rejects one of them.

What else becomes fixed at that moment is in Post-finalization limits.