我有一个使用spring的默认hikari连接池的spring boot运行的应用程序。最近服务器开始出现不可用连接的问题:
DEBUG HikariPool (411) - HikariPool-1 - Pool stats (total=20, active=20, idle=0, waiting=3)
DEBUG HikariPool (411) - HikariPool-1 - Timeout failure stats (total=20, active=20, idle=0, waiting=2)
WARN SqlExceptionHelper(137) - SQL Error: 0, SQLState: null
ERROR SqlExceptionHelper(142) - HikariPool-1 - Connection is not available, request timed out after 30005ms.
由于它是一个共享数据库,首先我不确定它是否是我的应用程序中的问题。但重新启动应用程序后,连接又恢复正常,所以我现在需要找出原因。这个错误只发生在生产系统上,它是全天候使用的,每分钟有许多动作。我试图找出是什么导致了hikari中活动连接的增加,方法是扫描日志,查找在连接增加之前执行的特定语句——但总是有不同或不清楚的操作。
因此,我们在数据库上执行了一个脚本来返回所有活动连接(gv$session)。结果没有返回一个活动会话,即使hikari日志同时显示活动连接。有人能告诉我这意味着什么和/或有线索在哪里找到这个问题的根源吗?
我使用SpringBootV2.1.4。以下是我的hikari设置:(spring.datasource.hikari.maximum pool size=20的默认值)
DEBUG HikariConfig (1020) - HikariPool-1 - configuration:
DEBUG HikariConfig (1052) - allowPoolSuspension.............false
DEBUG HikariConfig (1052) - autoCommit......................true
DEBUG HikariConfig (1052) - catalog.........................none
DEBUG HikariConfig (1052) - connectionInitSql...............none
DEBUG HikariConfig (1052) - connectionTestQuery.............none
DEBUG HikariConfig (1052) - connectionTimeout...............30000
DEBUG HikariConfig (1052) - dataSource......................none
DEBUG HikariConfig (1052) - dataSourceClassName.............none
DEBUG HikariConfig (1052) - dataSourceJNDI..................none
DEBUG HikariConfig (1052) - dataSourceProperties............{password=<masked>}
DEBUG HikariConfig (1052) - driverClassName................."oracle.jdbc.OracleDriver"
DEBUG HikariConfig (1052) - healthCheckProperties...........{}
DEBUG HikariConfig (1052) - healthCheckRegistry.............none
DEBUG HikariConfig (1052) - idleTimeout.....................600000
DEBUG HikariConfig (1052) - initializationFailTimeout.......1
DEBUG HikariConfig (1052) - isolateInternalQueries..........false
DEBUG HikariConfig (1052) - jdbcUrl.........................jdbc:oracle:thin:<masked>
DEBUG HikariConfig (1052) - leakDetectionThreshold..........0
DEBUG HikariConfig (1052) - maxLifetime.....................1800000
DEBUG HikariConfig (1052) - maximumPoolSize.................20
DEBUG HikariConfig (1052) - metricRegistry..................none
DEBUG HikariConfig (1052) - metricsTrackerFactory...........none
DEBUG HikariConfig (1052) - minimumIdle.....................20
DEBUG HikariConfig (1052) - password........................<masked>
DEBUG HikariConfig (1052) - poolName........................"HikariPool-1"
DEBUG HikariConfig (1052) - readOnly........................false
DEBUG HikariConfig (1052) - registerMbeans..................false
DEBUG HikariConfig (1052) - scheduledExecutor...............none
DEBUG HikariConfig (1052) - schema..........................none
DEBUG HikariConfig (1052) - threadFactory...................internal
DEBUG HikariConfig (1052) - transactionIsolation............default
DEBUG HikariConfig (1052) - username........................none
DEBUG HikariConfig (1052) - validationTimeout...............5000
1条答案
按热度按时间blmhpbnm1#
启用
leakDetectionThreshold=<max query time in ms>
(此处记录)。它记录在指定时间内未返回到池的连接。