HikariCP icon indicating copy to clipboard operation
HikariCP copied to clipboard

HikariPool-1 - Failed to validate connection oracle.jdbc.driver.T4CConnection@3b904d4f (IO Error: Invalid Operation, NOT Connected). Possibly consider using a shorter maxLifetime value.

Open sanchitgarg-its opened this issue 3 years ago • 19 comments

I am using below maven dependency with below configuration but getting some warn in log.

<dependency>
       		<groupId>com.zaxxer</groupId>
       		<artifactId>HikariCP</artifactId>
		<version>3.3.0</version>
</dependency>

with below config datasource.driver-class-name=oracle.jdbc.OracleDriver datasource.maximum-pool-size=25 datasource.connection-timeout=30000 datasource.connection-test-query=select 1 from dual datasource.minimum-idle=1

Log see:

HikariPool-1 - Failed to validate connection oracle.jdbc.driver.T4CConnection@3b904d4f (IO Error: Invalid Operation, NOT Connected). Possibly consider using a shorter maxLifetime value.

sanchitgarg-its avatar Feb 09 '21 02:02 sanchitgarg-its

I have the same problem. Spring Boot app using HikariCP-3.4.2.jar. App is working as it should, doing a scheduled task which succeeds. Then 20 minutes after this error starts, and the calling method is PoolBase.isConnectionAlive This is invoked by org.springframework.boot.actuate.jdbc.DataSourceHealthIndicator and is called all the time by Kubernetes readiness check. But suddenly this happens, and after a while the Kubernetes pod is restarted and everything is back to normal. Is there something we should do about it?

niklasskeppstedt avatar Mar 17 '21 10:03 niklasskeppstedt

I have the same problem. The app is working but keeps printing such msg.

FeynmanCheng avatar Jun 03 '21 08:06 FeynmanCheng

Has anyone found an answer as to why this keeps happenig? I have the same issue on an app we've deployed on our platform.

ghost avatar Jun 21 '21 11:06 ghost

For some reason the network timeout in PoolBase is set to 0 which throws an exception. If I set a breakpoint in PoolBase::isConnectionAlive and patch the networkTimeout value to 10 then the problem 'goes away'.

rpgn avatar Aug 03 '21 10:08 rpgn

It would be worth checking with your network team to see if the firewall between database and the app servers is dropping the connections.

raja-anbazhagan avatar Jan 17 '22 17:01 raja-anbazhagan

@sanchitgarg-its did you find a solution?

GuilhermeSerra avatar Oct 04 '22 18:10 GuilhermeSerra

@sanchitgarg-its did you find a solution?

try something like 30minutes、10minutes, or even 2minutes.I set max-lifetime to 2 minutes and the problem is solved.

ChanaLii avatar Oct 08 '22 07:10 ChanaLii

That's not solving the problem. That is at most mitigating the problem. This should work without giving any nasty messages or errors out of the box.

rpgn avatar Oct 11 '22 06:10 rpgn

Is anybody found a solution?

DurableHumorGitHub avatar Dec 29 '22 05:12 DurableHumorGitHub

I'm facing this also. Is the issue related to HikariCP itself?

By default, the Hikari max-lifetime is 1800000 ms (30 mins). I'm giving it a try with a shorter max lifetime. Let's see how it goes. If there is any permanent solution, please let me know.

Updated: Still getting the issue. :(

jamilxt avatar Mar 07 '23 07:03 jamilxt

@jamilxt did you upgrade to lastest version, im facing same issue at 4.0.3 :(

thanhhaibka avatar Mar 10 '23 04:03 thanhhaibka

Guys, If you have any firewall between your Application servers and Database, You may need to check the timeout for your Firewall settings. Usually, some firewalls disconnect any TCP connections that didn't have any packets.

It is also possible that the database has a connection time limit as well.

It's worth checking both of these situations.

raja-anbazhagan avatar Mar 10 '23 04:03 raja-anbazhagan

@jamilxt did you upgrade to lastest version, im facing same issue at 4.0.3 :(

@thanhhaibka latest version of? I'm experiencing it while using Azure SQL DB. When I switched to my local MSSQL, the issue doesn't occur. I think @raja-anbazhagan is right checking other reasons as well. I will check on Azure or our company's firewall, if the issue is causing because of them.

Thank you @raja-anbazhagan for the hint!

jamilxt avatar Mar 12 '23 14:03 jamilxt

Many thanks, @jamilxt and @raja-anbazhagan , i will try to check my firewall and will update when I have.

thanhhaibka avatar Mar 13 '23 02:03 thanhhaibka

Having the same issue, has anyone been able to fix this so far?

PiotrekWojtowicz avatar Mar 29 '23 11:03 PiotrekWojtowicz

We're also facing and still investigating this issue. In our case, it only happens when running within a VM and when a VM snapshot is created (which possibly results in a short-term stall of the VM).

We were able to rule out infrastructure related causes (network, database, VM) and we're now focusing on software side causes (e.g. HikariCP or within our applications which use HikariCP).

Questions to all affected users here:

  • For your applications which are affected by this issue - are they running on bare-metal, a container or within a VM?
  • For VM users: Is the issue happening randomly or does it correlate to VM snapshot creations or other special actions?
  • Which HikariCP, oracle database and jdbc driver version are you using?

patric-r avatar Mar 29 '23 12:03 patric-r

Having the same issue, has anyone been able to fix this so far? With my issue, I have checked the Hikari detail log and noticed that the connection was invalid, even though it was created just 2 seconds prior. Therefore, I requested the Infrastructure team to disable all McAfee firewalls, and the issue was resolved.

thanhhaibka avatar Mar 31 '23 10:03 thanhhaibka

There is a fairly recent documentation entry from oracle, 2910414.1. Interestingly, it is referring to exactly this error when using HikariCP!

Recommendation is to ensure that the net.core.somaxconn kernel parameter of the database server (not the server on which the applications are running!) is set to an high enough value, e.g. 32768.

To all affected users: Can you try that and see whether increasing this parameter will solve this issue?

patric-r avatar Apr 17 '23 16:04 patric-r

Is this Problem related with Scheduler? I am facing same problem.

Rejwan-Sharif avatar Jan 22 '24 16:01 Rejwan-Sharif