Repository navigation
feat(startup): wait for Postgres and IISA instead of exiting - #849
Merged
cjorge-thegraph merged 4 commits intoNov 19, 2026
Merged
Conversation
Dipper exited when IISA had not answered its health check after 3 tries 2 seconds apart, and when its first database connect failed other than by a refusal the pool retries itself. Both are away for longer in ordinary operations: IISA's own rollout stops its old pod before the new one is ready, 90 seconds or more, and a database restarting or failing over can drop connections or be unreachable for a while. A dipper starting in such a gap restarted in a loop until it closed. Startup now waits for both, with pauses of 1 second doubling to at most 30, for up to `iisa.startup_wait` (180 seconds by default) and `db.connect_wait` (120 by default), then exits as before. A database that answers with a refusal, such as a wrong password, or a connection set up wrongly still ends the wait at once. Together with the existing RPC and indexer URL retries, startup stays within the deployment's 600-second startup probe. The health server also answers `GET /ready`, 200 while a `SELECT 1` succeeds within 2 seconds and 503 otherwise, and the manifest's readiness probe uses it instead of a TCP check of the admin port, so a pod that lost its database stops counting as available while liveness, which a restart would not fix, stays unaffected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Readiness decides whether a pod counts as available and gets traffic. Tying it to the database, which every dipper shares, would only turn a database blip into the Deployment going unavailable and back, with nothing to route around: dipper runs as 1 pod, and its admin port takes no load-balanced traffic. Readiness stays the TCP check of the admin port, which opens once startup has finished, and the database's reachability belongs in metrics and alerts. This takes `/ready` back out and keeps the startup waits for the database and IISA. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…may clear up Review found the waits did not do what they said: - The database wait asked the pool, which blocks each attempt for its 30s acquire timeout and then reports only that it timed out, so a 120s wait took about 127s and hid the cause. It now tries 1 connection at a time, each cut off at what is left of the wait (10s at most), and opens the pool once one gets in. An IISA health check that hangs is likewise cut off at what is left, where it could add its 30s request timeout before. - Errors that fail the same way every time were retried for the whole wait: rustls reports a rejected certificate as an I/O error of invalid data, and protocol errors mean something other than Postgres answered. Now an I/O error is retried unless it is invalid data, a database error only when Postgres is starting up (57P03), out of connections (53300) or reports a connection failure (class 08), and a timed-out attempt always; nothing else is. - The final error gave the configured wait as the time waited. It now gives the tries made and the time actually waited. - The startup probe allowed 600s, which the RPC domain fetch, the indexer URL snapshot and the 2 new waits can exceed together. It allows 900s, and its comment adds the steps up. The tests that could not fail are replaced: a hanging IISA check must end at the 60s wait, a server that accepts and never answers must be given up on within a 2s wait, every attempt is given the time left, and the retry decision is checked on the error shapes sqlx and rustls really return. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…res-and-iisa-at-start Resolves db.rs against #847 and #850. The startup probe now fails before the pool does, so a refused password check gets #850's explanation there as well, and the TLS tests, whose stub drops each connection after its handshake, set a 1s connect wait instead of waiting 120s out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
cjorge-thegraph
marked this pull request as ready for review
November 19, 2026 20:32
MoonBoi9001
pushed a commit
that referenced
this pull request
Nov 23, 2026
🤖 I have created a release *beep* *boop* --- ## [0.3.4](v0.3.3...v0.3.4) (2026-11-23) ### Added * **config:** type secrets as such and read config from several files ([#857](#857)) ([fe92407](fe92407)) * **db:** connect to Postgres over TLS ([#847](#847)) ([2673181](2673181)) * **db:** let only 1 dipper process write, enforced by the database ([#858](#858)) ([6f88900](6f88900)) * **db:** make the database password optional ([#850](#850)) ([cb5d3b1](cb5d3b1)) * **metrics:** serve Prometheus metrics and optionally log as JSON ([#851](#851)) ([523819e](523819e)) * **rpc:** expose effective indexing targets and chain identity ([#860](#860)) ([aafc0ce](aafc0ce)) * **startup:** wait for Postgres and IISA instead of exiting ([#849](#849)) ([d1406d4](d1406d4)) ### Fixed * **db:** sslmode=verify-ca skips the hostname check, as libpq does ([#859](#859)) ([5fec97d](5fec97d)) * **k8s:** roll dipper out one pod at a time ([#846](#846)) ([de57e46](de57e46)) * **shutdown:** stop taking jobs first and fit the teardown in its budget ([#854](#854)) ([a1bc47d](a1bc47d)) ### Tests * run each test's Postgres on its Unix socket only ([#861](#861)) ([bc9e2b2](bc9e2b2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Dipper exited when IISA had not passed its health check after 3 tries 2 seconds apart, and when its first database connect failed in any way the pool does not retry itself (the pool only retries a refused connection or a Postgres "starting up", and only for its 30s acquire timeout). Both dependencies are away for longer in ordinary operations: IISA's own rollout stops the old pod before the new one is ready, 90 seconds or more by its readiness probe, and a database restarting or failing over can drop connections or be unreachable for a while. A dipper starting in such a gap restarted in a loop until it closed.
startup::retry_withinretries with pauses of 1s doubling to at most 30s, for up to a wait, and gives up at once on an error not worth retrying.wait_for_iisawaits up toiisa.startup_wait(new, 180s by default) and then exits as before.db::connectwaits up todb.connect_wait(new, 120s by default) for an unreachable or dropping server. A server that answers with a refusal (a wrong password, a missing database), a bad option or a TLS failure still ends the wait at once.The probes are otherwise unchanged. Liveness stays on
/health, which is local to the process, and readiness stays the TCP check of the admin port, which opens once startup has finished. Neither depends on the database or IISA: every pod shares those, so a blip would mark the Deployment unavailable with nothing to route around. Their reachability belongs in metrics and alerts instead.The RPC-domain and indexer-URL loops keep their own retries; they could move onto
retry_withinin a follow-up.Tests:
waiting_for_iisa_rides_out_an_iisa_rollout(paused clock) failed against the old 3-try loop and passes now.connect_retries_a_server_that_drops_the_connectionsaw 1 attempt onmainand 2 now.just fmt-check,just check,just test-unitpass locally.Changes after review
db.connect_wait(10s at most), and opens the pool once one gets in. Asking the pool made each attempt wait its 30s acquire timeout and hid the cause behind "pool timed out". An IISA health check that hangs is cut off at what is left ofiisa.startup_wait.🤖 Generated with Claude Code