Skip to content

PostgreSQL Backend — Durable State and Workers for Production Xferity

Postgres-backed deployment is the reference mode for production Xferity installations. It adds durable shared state, worker-based job execution, authenticated sessions, certificate inventory, and posture snapshots.

This page covers what Postgres adds to the deployment, how to set it up, and what you need to operate it.

Compared to file-backed mode, Postgres-backed deployment adds:

FeatureFile backendPostgres backend
Flow history and run recordslocal filesdatabase
Auth and session persistencenonefull
Certificate and PGP Key inventorynonefull
AS2 message persistencenonefull
Posture snapshotsnonehourly
Regression alertsnonesupported
Suppression managementnonesupported
Local encrypted vault secretsnonesupported
Durable job queue for workersnonesupported
  • PostgreSQL 13 or later
  • A database and user with CREATE TABLE, INSERT, UPDATE, DELETE, SELECT permissions
  • Network connectivity from the Xferity host to the Postgres instance
  • sslmode=require or stronger (default) unless using a private trusted network

Set state.backend=postgres and provide the connection details:

state:
backend: postgres
postgres:
host: postgres.internal
port: 5432
user: xferity
password: env:POSTGRES_PASSWORD
dbname: xferity
sslmode: require

Or use a DSN:

state:
backend: postgres
postgres:
dsn: postgres://xferity:password@postgres.internal:5432/xferity?sslmode=require

The DSN or password should reference a secret, not use a plaintext value.

On startup, Xferity applies migrations from the embedded migration set. The process:

  1. connects to Postgres
  2. verifies or creates a migration tracking table
  3. applies any pending migrations in order

Migration failures abort startup. Check logs if startup fails at the database phase.

The database user must have CREATE TABLE and DDL permissions for initial migration. After setup, you can optionally reduce to DML-only permissions.

Enable workers in the global configuration:

worker:
enabled: true
poll_interval: 5s
job_execution_timeout: 300s
max_concurrent_jobs: 4
max_attempts: 3
retry_backoff_base: 5s
retry_backoff_cap: 60s
FieldDefaultDescription
enabledfalseEnable the Postgres worker polling loop.
poll_interval5sHow often workers poll for new jobs.
job_execution_timeout300sMaximum time a single job may run before timeout.
max_concurrent_jobsMaximum jobs a single worker process runs in parallel.
max_attempts3Maximum retry attempts per job before marking it failed.
retry_backoff_base5sInitial retry backoff.
retry_backoff_cap60sMaximum retry backoff cap.

In Postgres-backed mode, the shared job queue supports multiple worker processes:

  • each worker polls the same queue independently
  • jobs are claimed with a select-for-update mechanism to prevent double-execution
  • workers can run on separate hosts as long as they share the same Postgres database and configuration

This is not clustering or HA. It is shared-queue workers. Each worker still needs access to the same filesystem paths (config, flow definitions, partner definitions, key material) unless you replicate those explicitly.

GET /health/worker returns worker readiness without authentication. It checks:

  • whether the worker polling loop is active
  • whether the database connection is reachable

Use this endpoint for container or load balancer health probes.

  • monitor queue depth — a growing queue that doesn’t drain usually means a worker problem or database connectivity problem
  • back up the Postgres database regularly
  • plan for schema migration during upgrades — Xferity applies migrations automatically at startup
  • use least-privilege database credentials for the application user
  • test that the application user can apply migrations and that migrations do not fail on version upgrades

For initial deployment (migration phase):

  • CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT on the target database

For ongoing operation (post-migration), a reduced permission set is acceptable:

  • INSERT, UPDATE, DELETE, SELECT on all Xferity tables
  • USAGE on sequences

The exact minimum depends on which features are enabled.

  • Postgres workers do not implement automatic HA or failover
  • workers do not replicate filesystem state — each worker must access the same config, flow, and key files
  • stopping all workers does not drain the queue — pending jobs remain and resume when workers restart