Skip to content

fix(selfhost): gate gittensory's depends_on on postgres/pgbouncer health#2546

Merged
JSONbored merged 1 commit into
mainfrom
fix/pgbouncer-postgres-depends-on
Jul 2, 2026
Merged

fix(selfhost): gate gittensory's depends_on on postgres/pgbouncer health#2546
JSONbored merged 1 commit into
mainfrom
fix/pgbouncer-postgres-depends-on

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • gittensory's depends_on in docker-compose.yml only gated on redis and qdrant, never postgres or pgbouncer, even though --profile postgres/--profile pgbouncer are documented first-class deployment modes. On a cold Postgres volume, compose started gittensory in parallel with postgres initdb instead of waiting for the healthcheck; the app's own waitForPostgres() fallback (~30s hard cap) commonly lost that race on a slow disk/first pull, crash-looping the app via restart: unless-stopped before Postgres was reachable.
  • pgbouncer had no healthcheck: block at all, so there was no readiness signal to gate on even conceptually.
  • Added postgres/pgbouncer to gittensory's depends_on with condition: service_healthy, required: false (mirroring the existing qdrant entry — required: false keeps the default no-profile SQLite path unaffected), and gave pgbouncer a pg_isready-based healthcheck (same approach postgres itself uses — verified locally against a running edoburu/pgbouncer container that pg_isready reports "accepting connections" purely from the pooler accepting the startup packet, independent of whether the upstream Postgres is reachable, which is the correct pooler-layer liveness signal).
  • Validated with docker compose --profile postgres --profile pgbouncer config (and the full profile combination) — both parse clean.

Closes #2500. Closes #2503.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally — this is a docker-compose.yml/test/** change with no src/** lines, so it carries no Codecov patch obligation; the new structural YAML assertions pass.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — N/A, no auth/cookie/CORS changes.
  • API/OpenAPI/MCP behavior is updated and tested where needed. — N/A.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A, no UI changes.
  • Visible UI changes include a UI Evidence section below — N/A, no UI changes.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

Notes

gittensory's depends_on only gated on redis and qdrant, never postgres
or pgbouncer, even though --profile postgres/--profile pgbouncer are
documented first-class deployment modes. On a cold Postgres volume,
compose started gittensory in parallel with postgres initdb instead of
waiting for the healthcheck; the app's own waitForPostgres() fallback
(~30s hard cap) commonly lost that race on a slow disk/first pull,
crash-looping the app via restart: unless-stopped before Postgres was
reachable.

Add postgres/pgbouncer to depends_on with condition: service_healthy,
required: false (mirroring the existing qdrant entry), and give pgbouncer
a pg_isready healthcheck so there's an actual readiness signal to gate
on -- it had none, so nothing could depend on it even conceptually.
required: false keeps the default (no-profile) SQLite path unaffected.
@dosubot dosubot Bot added the size:XS label Jul 2, 2026
@loopover-orb

loopover-orb Bot commented Jul 2, 2026

Copy link
Copy Markdown

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-02 09:11:10 UTC

2 files · 1 AI reviewer · no blockers · readiness 77/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
The change coherently fixes the startup-ordering gap by making the app wait on healthy Postgres/PgBouncer services while keeping those profile-gated dependencies optional for the default path. Adding a PgBouncer healthcheck gives the new dependency a real signal, and the added unit test covers the intended compose structure without relying on Docker availability. I do not see a reachable break in the provided diff.

Nits — 6 non-blocking
  • nit: docker-compose.yml:89 adds a long operational explanation inline; this is useful context, but it makes the compose file noisier than the surrounding service wiring and could be shortened now that the behavior is covered by a test.
  • nit: test/unit/selfhost-compose-db-health.test.ts:5 duplicates the YAML reader shape already used by nearby self-host compose tests, so consider sharing the small helper if more compose-structure tests keep landing.
  • nit: test/unit/selfhost-compose-db-health.test.ts:36 asserts PgBouncer has some positive retry count but does not lock the intended interval/timeout values added in docker-compose.yml:178, leaving part of the healthcheck contract untested.
  • docker-compose.yml:89: shorten the comment to the durable rule, for example that profile-backed services must use `required: false` and `service_healthy`, and leave the incident detail in the PR/issues.
  • test/unit/selfhost-compose-db-health.test.ts:36: assert `healthcheck.interval` and `healthcheck.timeout` alongside `test` and `retries` so future edits do not accidentally make the probe too aggressive or too slow.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2500, #2503
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (size label size:XS; 2 linked issues).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 65 registered-repo PR(s), 55 merged, 548 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 65 PR(s), 548 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Review top overlaps.
  • Add a concise scope and risk note.
  • Triage stale or unlinked PRs.
  • No action.
  • Check active issues and PRs before submitting.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.97%. Comparing base (75d7530) to head (b581f54).
⚠️ Report is 27 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2546      +/-   ##
==========================================
+ Coverage   95.95%   95.97%   +0.01%     
==========================================
  Files         226      228       +2     
  Lines       25423    25709     +286     
  Branches     9244     9349     +105     
==========================================
+ Hits        24395    24674     +279     
- Misses        417      425       +8     
+ Partials      611      610       -1     

see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit c6b1295 into main Jul 2, 2026
13 checks passed
@JSONbored
JSONbored deleted the fix/pgbouncer-postgres-depends-on branch July 2, 2026 09:20
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

fix(selfhost): add a healthcheck to the pgbouncer service fix(selfhost): gate gittensory's depends_on on postgres/pgbouncer health

1 participant