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

Add postgres connection timeout option #6160

Merged
merged 1 commit into from Jun 6, 2020

Commits on May 29, 2020

  1. feat: add postgres connection timeout option

    There was no documented way of setting a connection timeout for the
    postgres driver. We recently ran into an issue with our network that
    caused a container to hang indefinitely attempting to connect to
    postgres.
    
    We managed to resolve the issue by setting 'connectionTimeoutMillis' in
    the 'extra' field of our connection options. This approach does not
    appear to be documented anywhere.
    
    Seeing that MongoDB and MySQL drivers both support a connection timeout
    as part of the documented API, we felt it made sense to add a similar
    option to the Postgres driver and hopefully avoid some headaches down
    the road.
    
    This commit adds a 'connectTimeoutMS' option to the postgres driver
    that gets translated to the appropriate field for the pg library. It
    also updates the documentation to reflect this new option.
    
    Because the default behavior of the underlying pg library is to attempt
    to connect indefinitely, we didn't feel like it was a safe change to
    introduce a default timeout, even if that's more sane behavior.
    
    As mentioned earlier, both the MySQL and MongoDB drivers support a
    connection timeout option. MySQL uses 'connectTimeout' while MongoDB
    uses 'connectTimeoutMS'. We went with 'connectTimeoutMS' as to not
    introduce yet another name for a connection timeout, and because the
    'MS' suffix makes it clearer what is expected.
    
    We hope a future PR may adjust the MySQL connection options to adopt the
    same name, but will leave that up to someone with a stronger opinion.
    mothershipper committed May 29, 2020
    Copy the full SHA
    320f312 View commit details
    Browse the repository at this point in the history