fix: bootstrap PostgreSQL without a working service manager (#823) - #824
fix: bootstrap PostgreSQL without a working service manager (#823)#824GG-O-BP wants to merge 1 commit into
Conversation
b3c8c3f to
1b66266
Compare
…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.
1b66266 to
e2ea586
Compare
ReviewSound fix, no blockers. Three things I'd want changed before merge, all localized to What I verified — applied the two Go files to current
Moderate1. The fallback multiplies the timeout by the number of service attempts — confirmed, not theoretical. Moving Worst case is now 20 + 20 (services) + 30 ( Fix: drop the 2. Confirmed via the initdb args: Fix: the socket directory is already 3. The The hunk inserts at line ~322; on current Fix: rebase and move the row to the end of the table. Minor
ChecklistBug-fix requirements met: symptom row added, tests accompany the fix, The Thanks for the thorough stub-test coverage — the ready/non-ready service split and the idempotency cases are exactly the right seams to pin down. 🤖 Generated with Claude Code |
What & why
Closes #823.
mxcli run --ensure-dbonly triedserviceand Debian'spg_ctlclustertostart local PostgreSQL. On Arch neither command exists, so bootstrap failed even
though
initdb,pg_ctl, andpsqlwere available.Minimal fix
service/pg_ctlclusterattempts.fall back to a user-owned cluster under
~/.mxcli/postgresusinginitdb/pg_ctl.pg_ctl startwhen that clusteris already running, making repeated
--ensure-dbcalls safe.postgresconnection, without requiring apostgresOS account orpasswordless
sudo. Keep the originalsudo -u postgres psqlpath for systemclusters.
Tests
Focused command-stub tests cover:
initdb/pg_ctlpg_ctl startfailureValidation:
go build ./...make vetgo test ./cmd/mxcli/docker -count=1EnsureDatabaseinvocation on thereported Arch-shaped environment
Docs
Updated the run-local skill, docs-site page, CHANGELOG, and fix-issue symptom
entry.