Hikari Connection Pool Possibly consider using a shorter maxLifetime value

Hi,
I am using Hikari Connection pool with Cockroach DB. I am facing below error.

Failed to validate connection org.postgresql.jdbc.PgConnection@3b2c7c97 (This connection has been closed.). Possibly consider using a shorter maxLifetime value.

Currently i have set Hikari max-lifetime as 5 minutes. Default is 30 minutes but still i am getting error to use shorter maxLifetime value.

What is the maxLifetime value for cockroach DB.

Ref: https://github.com/brettwooldridge/HikariCP

Thanks,
Jitu

Hi Jitu, thanks for the question.

A couple points and questions:

  • What version of CockroachDB are you using?
  • Does the error happen all the time, or just sometimes?
  • Does the error only happen if you use HikariCP.
  • The message “Possibly consider using a shorter maxLifetime value” comes from within HikariCP, not CockroachDB itself. So the advice in the message may not necessarily apply to CockroachDB.
  • v20.1 and earlier of CockroachDB does not have any functionality that automatically closes idle connections. However, this functionality is going to be included in v20.2 with the setting idle_in_session_timeout. See: https://github.com/cockroachdb/cockroach/pull/51223.

If you are using a v20.1 or earlier, then there must be something else that is causing the connections to close. Do you have a load balancer in between your app and the database? Perhaps that is incorrectly closing connections.

Thanks for the reply Rafi. we are using v20.1 and we do use load balancer and there is no time limit for it.