SafeLine icon indicating copy to clipboard operation
SafeLine copied to clipboard

Database clients panic on first start before postgres is ready

Open AdzerKI opened this issue 1 month ago • 1 comments

On a fresh install safeline-mgt, safeline-luigi and safeline-chaos start together with safeline-pg and panic with failed to connect to host=safeline-pg ... connection refused while postgres is still in initdb. restart: always brings them back after a few restarts, but docker compose up -d --wait gives up right away with container safeline-mgt is unhealthy.

Two things in compose.yaml cause it:

  • depends_on: [postgres] waits only for the container to start, not for the database; chaos has no depends_on at all.
  • The postgres healthcheck runs pg_isready over the unix socket. The temporary server of initdb listens on that socket only, so the check passes before the real server accepts TCP connections, and even condition: service_healthy would let the clients in too early.

Fix: condition: service_healthy on postgres for mgt, luigi and chaos, and pg_isready -h 127.0.0.1 in the healthcheck. PR follows.

Seen with 9.3.7 images, Docker 29.9.3, Compose v5.7.0.

AdzerKI avatar Nov 04 '26 07:11 AdzerKI

Thank you for the detailed report. We've logged this issue in our internal tracking system and will keep this Issue updated as progress is made. We appreciate your patience!

Windsley avatar Nov 11 '26 07:11 Windsley