如何在达到maxActive时告诉Spring创建更多数据库连接?

时间:2018-02-12 11:38:19

标签: java spring hibernate jpa spring-boot

我有一个具有以下数据库池设置的Spring Boot应用程序。如果应用程序连续运行2到3天,我会出现池空错误。那么,有关于此的两个问题,

  1. 我真的怀疑连接泄漏可能已经发生。我们的应用程序的用户数量非常少,因此我们的用户群不应该耗尽32。我怎样才能找到泄露的连接?
  2. 如果我想告诉Spring在达到maxActive(在我的情况下为32)时创建更多连接,那么需要添加什么设置?

    poolProperties.setTestOnBorrow(true);
    poolProperties.setTestOnConnect(true);
    poolProperties.setTestWhileIdle(true);
    poolProperties.setInitialSize(10);
    poolProperties.setMinIdle(10);
    poolProperties.setMaxIdle(10);
    poolProperties.setMaxActive(32);
    poolProperties.setMaxWait(5000); //5 secs
    poolProperties.setLogValidationErrors(true);
    poolProperties.setLogAbandoned(true);
    poolProperties.setValidationQuery("SELECT 1");
    
  3. o.h.e.jdbc.spi.SqlExceptionHelper.logExceptions(129) - [http-nio-6061-exec-9] Timeout: Pool empty. Unable to fetch a connection in 5 seconds, none available[size:32; busy:32; idle:0; lastwait:5000]

0 个答案:

没有答案