HikariPool-1 - Connection is not available, request timed out after 30000ms for very tiny load server

后端 未结 2 1358
醉酒成梦
醉酒成梦 2020-12-29 10:03

I have a small Java application for testing purposes. I have moved to hikari recently. What I notice is that I keep getting this error.

java.sql.SQLTransient         


        
相关标签:
2条回答
  • 2020-12-29 10:32

    Your database is not obtaining connection within (30000 milliseconds that is default connectionTimeout property) because of network latency or some of the queries which are taking too long to execute(more than 30000 milliseconds).

    Please try to increase value of property connectionTimeout.

    YML configuration example:

    spring:
      datasource:
        hikari:
          minimumIdle: 2
          maximumPoolSize: 10
          idleTimeout: 120000
          connectionTimeout: 300000
          leakDetectionThreshold: 300000
    

    Java Config example:

    HikariConfig config = new HikariConfig();
            config.setMaximumPoolSize(20);
            config.setConnectionTimeout(300000);
            config.setConnectionTimeout(120000);
            config.setLeakDetectionThreshold(300000);
    
    0 讨论(0)
  • 2020-12-29 10:42

    I am using spring boot and I was facing the same problem, and my solution was to get the connection like this "DataSourceUtils.getConnection(dataSource)". So I change from dataSource.getConnection() to DataSourceUtils.getConnection(dataSource).

    0 讨论(0)
提交回复
热议问题