Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max_conns and max_conn_lifetime breaks db.Ping #464

Closed
matteosuppo opened this issue May 22, 2017 · 6 comments
Closed

max_conns and max_conn_lifetime breaks db.Ping #464

matteosuppo opened this issue May 22, 2017 · 6 comments
Labels
bug Something is not working.
Milestone

Comments

@matteosuppo
Copy link
Contributor

matteosuppo commented May 22, 2017

$ export DATABASE_URL="postgres://*:*@*:5432/auth?max_conn_lifetime=1m&max_conns=20&max_idle_conns=4"
$ ./hydra host --dangerous-force-http                                                                                                                                   
INFO[0000] Connecting with postgres://*:*@*:5432/auth?max_conn_lifetime=1m&max_conns=20&max_idle_conns=4 
ERRO[0000] An error occurred                             error="Could not connect to SQL: pq: unrecognized configuration parameter "max_idle_conns""

Investigating I discovered that it's this call that fails: https://github.com/ory/hydra/blob/master/config/backend_connections.go#L41

Unfortunately the custom parameters hydra uses to control the number of connections appear to break the connection since they're not recognized by the database library.

Not sure if this happens with all postgres databases. I tried with our production one and a docker one summoned with

docker run --rm --name postgres -e POSTGRES_PASSWORD=password -p 5432:5432 postgres -d 5
@aeneasr
Copy link
Member

aeneasr commented May 22, 2017

Oh ok so the issue is that we need to remove those parameters from the database DSN as apparently there is some validation going on in postgres!

@aeneasr aeneasr added the bug Something is not working. label May 22, 2017
@aeneasr aeneasr added this to the 1.0.0: stable release milestone May 22, 2017
@matteosuppo
Copy link
Contributor Author

I can attempt a pull request in the next few days

@aeneasr
Copy link
Member

aeneasr commented May 23, 2017

I'm already working on it :)

@matteosuppo
Copy link
Contributor Author

Uhm, it doesn't seem to have been fixed:

➜  hydra git:(master) ✗ docker run -e "DATABASE_URL=$DATABASE_URL" -e "SYSTEM_SECRET=$SYSTEM_SECRET" --rm --name my-hydra -p 4444:4444 oryd/hydra:v0.8.3-http -h
time="2017-05-24T08:48:42Z" level=info msg="Connecting with postgres://*:*@*:5432/auth?" 
time="2017-05-24T08:48:43Z" level=error msg="An error occurred" error="Could not connect to SQL: pq: unrecognized configuration parameter "max_conn_lifetime"" 
time="2017-05-24T08:48:43Z" level=info msg="Retrying in 0.100000 seconds..." 

Am I doing something wrong?

@aeneasr aeneasr reopened this May 24, 2017
@aeneasr
Copy link
Member

aeneasr commented May 24, 2017

No, my bad, I updated the log but not the actual URL that get's connected. I also wrote test cases but unfortunately the postgres instance I use does not seem to care.

aeneasr pushed a commit that referenced this issue May 24, 2017
@aeneasr
Copy link
Member

aeneasr commented May 24, 2017

@matteosuppo what postgres version are you running by the way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

2 participants