Repository navigation
test: run each test's Postgres on its Unix socket only - #861
Merged
Merged
Conversation
pgtemp picks a free TCP port, closes it, and starts Postgres on it a moment later. In a parallel test run another process, such as a test's mock server, can take the port in between: Postgres then fails to start, and the test waits out its pool's 30-second timeout on a server that never came up. That failed main's CI on 2026-11-23 (PoolTimedOut in a registry test) and has failed local runs too. Every test's Postgres now listens on no TCP port (`listen_addresses=''`) and is reached through its Unix socket in its data directory, so there is no port to lose. The registry and queue crates' helpers and the service's tests all start it this way; the service's helpers live in `test_support`. The password-checking server used by the `db` tests checks passwords on its socket instead. `it_a_temp_postgres_answers_when_its_port_is_taken` holds the port first: it fails with pgtemp's default server, which then can't start, and passes now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
cjorge-thegraph
added a commit
that referenced
this pull request
Nov 23, 2026
The writer fence's tests start their Postgres on its Unix socket only, as #861 does for the rest, and the registry's test databases keep the operator session and the writer pool on top of it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Every test's temporary Postgres now listens on its Unix socket only, so a parallel test run can no longer start it on a port another process has just taken.
The failure: main's CI on the merge of #854 failed in
dipper-pgregistry::it_registry_postgres::a_dips_info_block_denies_an_indexer_until_it_lapses_or_the_indexer_answerswithFailed to connect to temporary database: PoolTimedOutafter 30s (run). The same kind of failure, a different test each time, has shown up in local runs.Why it happens: pgtemp 0.6 picks a free TCP port by binding port 0 and closing it, then starts Postgres on that port a moment later (its source marks this as a race). In a parallel run, another process can take the port in between, a test's wiremock server for instance. Postgres then can't bind it and exits, and the test waits out its pool's 30-second timeout on a server that never started.
The fix: each test's Postgres starts with
listen_addresses=''and is reached through the socket pgtemp already puts in its data directory. With no TCP port involved, there is nothing to lose.dipper-service:test_support::temp_postgres,temp_postgres_from,temp_postgres_optionsandtemp_postgres_url, used by thedb,telemetryand Studio consumer tests. The password-checking server in thedbtests checks passwords on its socket.dipper-pgregistryanddipper-pgmq: their test helpers start and reach the server the same way.Tests:
it_a_temp_postgres_answers_when_its_port_is_takenholds the port first. With pgtemp's default server it fails (Postgres can't start, so its socket never appears), and it passes with this change.cargo +nightly fmt,cargo clippy --all-targets --all-features -D warnings, and 3 full runs ofcargo nextest run --all-features(1,268 tests each) pass locally.🤖 Generated with Claude Code