Skip to content

test: run each test's Postgres on its Unix socket only - #861

Merged
cjorge-thegraph merged 1 commit into
mainfrom
cjorge/temp-postgres-over-its-socket
Nov 23, 2026
Merged

cjorge-thegraph merged 1 commit into
mainfrom
cjorge/temp-postgres-over-its-socket

Conversation

@cjorge-thegraph

Copy link
Copy Markdown
Contributor

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_answers with Failed to connect to temporary database: PoolTimedOut after 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_options and temp_postgres_url, used by the db, telemetry and Studio consumer tests. The password-checking server in the db tests checks passwords on its socket.
  • dipper-pgregistry and dipper-pgmq: their test helpers start and reach the server the same way.

Tests:

  • it_a_temp_postgres_answers_when_its_port_is_taken holds 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 of cargo nextest run --all-features (1,268 tests each) pass locally.

🤖 Generated with Claude Code

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
cjorge-thegraph merged commit bc9e2b2 into main Nov 23, 2026
13 checks passed
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>
@MoonBoi9001
MoonBoi9001 deleted the cjorge/temp-postgres-over-its-socket branch November 26, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant