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
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 |
e2ea586 to
79dae2b
Compare
|
Thanks for the thorough review, @ako — all seven points are addressed. Rebased onto Moderate
Minor
Each new test was proven to fail on the un-fixed code (reverted each change in a throwaway worktree and watched the matching test fail with the reported symptom). |
79dae2b to
a99673e
Compare
Review (round 2)Thanks — I re-verified all seven points from the previous round and they are all addressed. Three new issues, one of which is a regression introduced by the fix for point 1. What I verified — merged the branch into current
Blocker1. The short probe turns "slow but working" into a hard failure.
Against real PostgreSQL that The likely trigger is not exotic: crash recovery after a reaped container. PostgreSQL refuses connections while replaying WAL ( Fix — in // Something already owns the port (e.g. a service-started server still in
// crash recovery). Never initdb a competitor — EnsureDatabase's authoritative
// 20s wait decides.
if pingTCP(net.JoinHostPort(host, port), time.Second) == nil {
return nil
}A short probe should answer "should I look further?", never "should I build a competitor?". Moderate2.
That directory mode is the entire access control behind Fix: 3. The 0700-socket control lives only in a command-line flag, not in the cluster.
Fix: persist it in the cluster's own config — write Minor
ChecklistBug-fix requirements met: symptom row appended at the end of the table, tests accompany the fix, the sync source skill ( The stub-test coverage is a real strength here — the port-guard and idempotency cases in particular made the two remaining defects cheap to demonstrate rather than argue about. 🤖 Generated with Claude Code |
d035f8a to
8efbd32
Compare
|
Thanks, @ako — round 2 is fully addressed in Blocker
Moderate
Minor and follow-through
The final tree passed |
…s#823) Fall back to a user-owned initdb/pg_ctl cluster under ~/.mxcli/postgres when no service-managed PostgreSQL becomes ready. Provision through its private Unix socket without requiring a postgres OS account or sudo, while retaining the sudo path for system clusters. Harden the fallback for both review rounds: bound service probes, remove the invalid pg_ctlcluster placeholder, avoid competing with an occupied port, use SCRAM on TCP, enforce 0700 socket access, persist the endpoint in postgresql.conf, reject legacy host-trust clusters, and validate running-cluster endpoints and ports. Add focused regression coverage and update the run-local skill, user documentation, changelog, and fix-issue record.
8efbd32 to
01cd6c5
Compare
|
Final self-audit amended the single commit to |
What & why
Closes #823.
mxcli run --ensure-dbonly knewserviceand a non-working Debianpg_ctlclusterplaceholder. On Arch neither produced a server, so bootstrap failed even though the portableinitdb,pg_ctl, andpsqltools were available.Fix
service postgresql startwith a bounded readiness probe, then fall back to a user-owned cluster under~/.mxcli/postgreswhen no service becomes ready. The unusablepg_ctlcluster -- startplaceholder is removed.0700.listen_addresses,port,unix_socket_directories, andunix_socket_permissions = 0700inpostgresql.conf; plain laterpg_ctl -D ... starttherefore preserves the safe endpoint without mxcli-only runtime flags.sudo -u postgres psqlfor system clusters, and keep remote hosts check-only.Tests
Focused command-stub regressions cover service readiness, the occupied-port race, the removed placeholder, first/repeated/running starts, port and socket mismatches, existing-directory permissions, persistent and idempotent configuration, legacy host trust, authentication arguments, superuser resolution, validation, and actionable failures.
Validation completed on the final tree:
make buildmake vetmake testgo test ./cmd/mxcli/docker -count=1go test -racefor the changed package pathspg_ctlrestart without-o, reconnect, and legacy-host-trust refusalDocs and scope
Updated only the implementation, its focused tests, the run-local skill/docs, CHANGELOG, and the final fix-issue table row: six files, one concern, one commit on current
main. The docs now explain persistence, the server log, and safe stop/removal. No MDL fixture is applicable because this change has no MDL surface.