Database clients panic on first start before postgres is ready
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;chaoshas nodepends_onat all.- The postgres healthcheck runs
pg_isreadyover 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 evencondition: service_healthywould 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.
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!