feat(health): bounded DB connectivity check on /health#126
Merged
Conversation
The /health endpoint returned a static {status:"ok"} and never touched the
database, so it reported healthy even when the DB was unreachable. Run a
bounded SELECT 1 (2s timeout) on each request, surface the result as deps.db,
and return 503 when the probe fails.
SELECT 1 tests connectivity only (not schema), so a still-migrating fresh boot
reports db:ok as long as Postgres is reachable — this does not flap the Fly
deploy health-gate. Bump 0.9.2 -> 0.9.3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
/api/v1/healthreturned a static{status:"ok"}and never touched the database, so it reported healthy even when the DB was unreachable (the trigger for this work: council looked healthy while its DB cluster was inerror).This adds a bounded
SELECT 1connectivity probe to/health:deps.db: "ok" | "error"added to the response body.DB_HEALTH_TIMEOUT_MS), well under the Flyhttp_servicechecktimeout = 3s, so a slow/unreachable DB resolves to a fast 503 instead of hanging the endpoint.Why it does not re-break deploys
SELECT 1tests connectivity only, not schema. Migrations run as the Flyrelease_command(bluegreen) before new machines serve traffic, and even on a still-migrating boot a reachable Postgres returnsdb:ok. Only a genuine unreachable/unresponsive DB reportserror. Combined with the existinggrace_period = 60s, this will not flap the deploy health-gate.Tests
New
db-check_test.tscovers all three paths: ok (probe resolves), error (probe rejects = connection failure), and error (probe exceeds timeout). Full unit suite green (128 passed).Version
0.9.2 → 0.9.3