3

I have an app running Ruby on Rails, standard nothing fancy at all. Today when I was changing password in Postgresql I spot that app is still running with old credentials. This gives me time to rolling restart app with new db credentials. Open connections still work, because was authenticated with old credentials. How long Postgres will keep those connection active? I assume that there must be some time after client must re-authenticate. Where I can find more about it? Some setting? Tried to find something on https://www.postgresql.org/docs/9.5/static/runtime-config-connection.html but still don't know how it works in details.

1
  • afaik Password (authentication) check is only when connection starts. However authorization checks (ie table permissions) are valid when grant query ends.
    – Sahap Asci
    Commented Aug 18, 2017 at 8:17

1 Answer 1

5

A PostgreSQL instance will keep a client connection up and running until the connection either reaches a specified client timeout or the client (application) closes the connection.

A change of password has no effects on existing connections and will only affect new connections.

There is no mechanism that constantly checks if the connection is still "password valid". A client connection is a one time authentication and if it was valid at the time of authentication will keep on being valid until closed.

1
  • 2
    I know this is an older answer, but can you point to the docs on where the connection will stay open until the client closes it? I think Im having a similar issue but looking for documentation, thanks Commented Jul 25, 2020 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.