Skip to content

fix: bootstrap PostgreSQL without a working service manager (#823) - #824

Open
GG-O-BP wants to merge 1 commit into
mendixlabs:mainfrom
GG-O-BP:fix/823-ensure-db-initdb-fallback
Open

fix: bootstrap PostgreSQL without a working service manager (#823)#824
GG-O-BP wants to merge 1 commit into
mendixlabs:mainfrom
GG-O-BP:fix/823-ensure-db-initdb-fallback

Conversation

@GG-O-BP

@GG-O-BP GG-O-BP commented Aug 3, 2026

Copy link
Copy Markdown

What & why

Closes #823.

mxcli run --ensure-db only tried service and Debian's pg_ctlcluster to
start local PostgreSQL. On Arch neither command exists, so bootstrap failed even
though initdb, pg_ctl, and psql were available.

Minimal fix

  • Keep the existing service / pg_ctlcluster attempts.
  • Confirm that an attempted service actually becomes ready; if no service does,
    fall back to a user-owned cluster under ~/.mxcli/postgres using
    initdb / pg_ctl.
  • Reuse an initialized data directory and skip pg_ctl start when that cluster
    is already running, making repeated --ensure-db calls safe.
  • Provision the role/database through the user-owned cluster's direct
    postgres connection, without requiring a postgres OS account or
    passwordless sudo. Keep the original sudo -u postgres psql path for system
    clusters.

Tests

Focused command-stub tests cover:

  • a ready service path (including a non-zero service command exit)
  • an ineffective service falling back to initdb / pg_ctl
  • missing portable tools
  • first initialization
  • repeated invocation on an initialized/stopped cluster
  • an already-running cluster
  • pg_ctl start failure
  • direct and sudo superuser selection

Validation:

  • go build ./...
  • make vet
  • go test ./cmd/mxcli/docker -count=1
  • real PostgreSQL 18.4 bootstrap and repeated EnsureDatabase invocation on the
    reported Arch-shaped environment

Docs

Updated the run-local skill, docs-site page, CHANGELOG, and fix-issue symptom
entry.

@GG-O-BP GG-O-BP changed the title fix: start PostgreSQL via initdb/pg_ctl when no service manager exists (#823) fix: fall back to initdb/pg_ctl when PostgreSQL service is unavailable (#823) Aug 3, 2026
@GG-O-BP
GG-O-BP force-pushed the fix/823-ensure-db-initdb-fallback branch from b3c8c3f to 1b66266 Compare August 3, 2026 20:45
@GG-O-BP GG-O-BP changed the title fix: fall back to initdb/pg_ctl when PostgreSQL service is unavailable (#823) fix: start PostgreSQL via initdb/pg_ctl when no service manager exists (#823) Aug 3, 2026
…endixlabs#823)

`mxcli run --ensure-db` only tried `service` and `pg_ctlcluster` to start
a local PostgreSQL server. On Arch neither exists, so bootstrap failed
even though `initdb`, `pg_ctl`, and `psql` were available.

Keep the existing service-manager attempts and verify that they actually
make PostgreSQL ready. If none does, start a user-owned cluster under
`~/.mxcli/postgres` with `initdb`/`pg_ctl`. Reuse initialized state and
skip starting an already-running cluster so repeated runs are safe.

Provision the application role/database through the cluster's direct
`postgres` superuser connection, without requiring a `postgres` OS
account or passwordless sudo. Retain the existing `sudo -u postgres psql`
path for system clusters.

Add focused command-stub tests for ready/ineffective services, missing
tools, first initialization, repeated and already-running invocations,
startup failures, and direct/sudo superuser selection. Update the related
docs, changelog, and fix-issue symptom entry.
@GG-O-BP
GG-O-BP force-pushed the fix/823-ensure-db-initdb-fallback branch from 1b66266 to e2ea586 Compare August 3, 2026 21:12
@GG-O-BP GG-O-BP changed the title fix: start PostgreSQL via initdb/pg_ctl when no service manager exists (#823) fix: bootstrap PostgreSQL without a working service manager (#823) Aug 3, 2026
@github-actions github-actions Bot mentioned this pull request Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mxcli run --ensure-db can't start PostgreSQL on Arch Linux

1 participant