hasura / hasura/graphql-engine
Unhelpful error message while using local db and incomplete docs
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Component
CLI
### What is the current behaviour?
Connector container in docker is unable to start and showing unclear error message when restarting docker using `HASURA_DDN_PAT=$(ddn auth print-pat) docker compose up --build --watch` after adding connector , changing default connection string to a local db connection string and doing sucessful db introspection. The error log from the docker container is unclear as to why it is unable to start.
Expected behaviour is connector container starting up with schema exposed at `localhost:8085/schema`
### What is the expected behaviour?
No warnings and wherever the warning is applicable the message should be helpful
### How to reproduce the issue?
1. using the latest cli initialize a supergraph(this will either create a dir and create necessary files)
2. add a new subgraph and add postgres connector following the getting started guide
3. change the `CONNECTION_URI` in the ./my_subgraph/connector/my_pg/.env.local from the default connection url to your local pg db connection url
4. do db introspection using the command `ddn connector introspect --connector my_subgraph/connector/my_pg/connector.local.yaml` (this step is sucessful and updates configuration.json)
4. interrupt the `HASURA_DDN_PAT=$(ddn auth print-pat) docker compose up --build --watch` command that was run after supergraph initialization.
5. restart the command `HASURA_DDN_PAT=$(ddn auth print-pat) docker compose up --build --watch` with updated compose.yaml(got updated when the connector was added)
### Screenshots or Screencast

https://github.com/user-attachments/assets/961881b6-a19b-4589-8b93-3d9d51ed88f8
### Please provide any traces or logs that could help here.
2024-07-15 15:52:20 OpenTelemetry trace error occurred. Exporter otlp encountered the following error(s): the grpc server returns error (Unknown error): , detailed error message: transport error
2024-07-15 15:52:50 error initializing connector state: unable to initialize connection pool: pool timed out while waiting for an open connection
2024-07-15 16:22:33 error initializing connector state: unable to initialize connection pool: pool timed out while waiting for an open connection
2024-07-15 15:52:50 {"timestamp":"2024-07-15T10:22:50.203465Z","level":"ERROR","fields":{"meta.signal_type":"log","event.domain":"ndc","event.name":"Initialization error","name":"Initialization error","body":"error initializing connector state: unable to initialize connection pool: pool timed out while waiting for an open connection","error":true},"target":"ndc_postgres::connector"}
2024-07-15 16:22:33 {"timestamp":"2024-07-15T10:52:33.480702Z","level":"ERROR","fields":{"meta.signal_type":"log","event.domain":"ndc","event.name":"Initialization error","name":"Initialization error","body":"error initializing connector state: unable to initialize connection pool: pool timed out while waiting for an open connection","error":true},"target":"ndc_postgres::connector"}
### Any possible solutions/workarounds you're aware of?
postgres://:@localhost:5432/
the `localhost` should be replaced with `local.hasura.dev` for the docker to communicate with the database
### Keywords
local pg db connector error
Contributor guide
Research direction
Start by following the reproduction steps with docker compose up --build --watch and inspect the connector logs, especially the connection-pool timeout. Check the local database connection string in ./my_subgraph/connector/my_pg/.env.local and the generated compose.yaml; verify whether local.hasura.dev is required. Done means the connector starts with the documented local connection setup and failures provide a helpful warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, postgresql
- Domain
- cli, databases, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100