この数日間、この例外が発生します。
この問題は、10 ++フォームを処理し、接続が最大サイズに達するまで30秒ごとから1分30秒まで増加し続ける場合に発生します。
すべての接続がすでに閉じていることを確認しました。なぜこのエラーが発生し続けるのですか?
環境:
私はこのエラーを受け取り続けます:
Caused by: javax.servlet.ServletException: Java.sql.SQLTransientConnectionException: ConcolePool - Connection is not available, request timed out after 30003ms.
at org.Apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.Java:909)
at org.Apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.Java:838)
at org.Apache.jsp.utilBillParaList_jsp._jspService(utilBillParaList_jsp.Java:761)
at org.Apache.jasper.runtime.HttpJspBase.service(HttpJspBase.Java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.Java:790)
at org.Apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.Java:438)
... 51 more
Caused by: Java.sql.SQLTransientConnectionException: ConcolePool - Connection is not available, request timed out after 30003ms.
at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.Java:548)
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.Java:186)
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.Java:145)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.Java:83)
at org.Apache.jsp.utilBillParaList_jsp._jspService(utilBillParaList_jsp.Java:322)
構成:
09:05:37,908 DEBUG com.zaxxer.hikari.HikariConfig :841 - ConcolePool - configuration:
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - allowPoolSuspension.............false
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - autoCommit......................true
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - catalog.........................null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - connectionInitSql...............null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - connectionTestQuery............."SELECT current_timestamp"
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - connectionTimeout...............30000
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - dataSource......................null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - dataSourceClassName............."com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - dataSourceJNDI..................null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - dataSourceProperties............{port=3307, user=root, password=<masked>, prepStmtCacheSqlLimit=2048, cachePrepStmts=true, prepStmtCacheSize=500, serverName=localhost}
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - driverClassName.................null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - healthCheckProperties...........{}
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - healthCheckRegistry.............null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - idleTimeout.....................600000
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - initializationFailFast..........true
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - isolateInternalQueries..........false
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - jdbc4ConnectionTest.............false
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - jdbcUrl.........................null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - leakDetectionThreshold..........30000
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - maxLifetime.....................1800000
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - maximumPoolSize.................10
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - metricRegistry..................null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - metricsTrackerFactory...........null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - minimumIdle.....................5
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - password........................<masked>
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - poolName........................"ConcolePool"
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - readOnly........................false
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - registerMbeans..................false
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - scheduledExecutorService........null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - threadFactory...................null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - transactionIsolation............null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - username........................null
09:05:37,924 DEBUG com.zaxxer.hikari.HikariConfig :857 - validationTimeout...............5000
09:05:37,924 INFO com.zaxxer.hikari.HikariDataSource :70 - ConcolePool - Started.
プールステータスのデバッグ:
2018-05-14 12:48:19 [ ConcolePool connection adder:5403109 ] - [ DEBUG ] ConcolePool - After adding stats (total=5, active=0, idle=5, waiting=0)
2018-05-14 12:48:49 [ ConcolePool housekeeper:5433109 ] - [ DEBUG ] ConcolePool - Pool stats (total=5, active=1, idle=4, waiting=0)
2018-05-14 12:48:49 [ ConcolePool connection adder:5433109 ] - [ DEBUG ] ConcolePool - Added connection com.mysql.jdbc.JDBC4Connection@39193bcd
2018-05-14 12:48:49 [ ConcolePool connection adder:5433109 ] - [ DEBUG ] ConcolePool - After adding stats (total=6, active=1, idle=5, waiting=0)
2018-05-14 12:49:07 [ ConcolePool housekeeper:5450750 ] - [ WARN ] Connection leak detection triggered for com.mysql.jdbc.JDBC4Connection@160af66e, stack trace follows
2018-05-14 12:49:19 [ ConcolePool housekeeper:5463125 ] - [ DEBUG ] ConcolePool - Pool stats (total=6, active=1, idle=5, waiting=0)
2018-05-14 12:49:49 [ ConcolePool housekeeper:5493140 ] - [ DEBUG ] ConcolePool - Pool stats (total=6, active=2, idle=4, waiting=0)
2018-05-14 12:49:49 [ ConcolePool connection adder:5493140 ] - [ DEBUG ] ConcolePool - Added connection com.mysql.jdbc.JDBC4Connection@207b7ac0
2018-05-14 12:49:49 [ ConcolePool connection adder:5493140 ] - [ DEBUG ] ConcolePool - After adding stats (total=7, active=2, idle=5, waiting=0)
2018-05-14 12:49:54 [ ConcolePool housekeeper:5497687 ] - [ WARN ] Connection leak detection triggered for com.mysql.jdbc.JDBC4Connection@10429350, stack trace follows
2018-05-14 12:50:19 [ ConcolePool housekeeper:5523156 ] - [ DEBUG ] ConcolePool - Pool stats (total=7, active=2, idle=5, waiting=0)
2018-05-14 12:50:49 [ ConcolePool housekeeper:5553172 ] - [ DEBUG ] ConcolePool - Pool stats (total=7, active=3, idle=4, waiting=0)
2018-05-14 12:50:49 [ ConcolePool connection adder:5553172 ] - [ DEBUG ] ConcolePool - Added connection com.mysql.jdbc.JDBC4Connection@4721d5d3
2018-05-14 12:50:49 [ ConcolePool connection adder:5553172 ] - [ DEBUG ] ConcolePool - After adding stats (total=8, active=3, idle=5, waiting=0)
2018-05-14 12:50:58 [ ConcolePool housekeeper:5561656 ] - [ WARN ] Connection leak detection triggered for com.mysql.jdbc.JDBC4Connection@76ff6438, stack trace follows
2018-05-14 12:51:19 [ ConcolePool housekeeper:5583187 ] - [ DEBUG ] ConcolePool - Pool stats (total=8, active=4, idle=4, waiting=0)
2018-05-14 12:51:19 [ ConcolePool connection adder:5583187 ] - [ DEBUG ] ConcolePool - Added connection com.mysql.jdbc.JDBC4Connection@1f4c60a8
2018-05-14 12:51:19 [ ConcolePool connection adder:5583187 ] - [ DEBUG ] ConcolePool - After adding stats (total=9, active=4, idle=5, waiting=0)
2018-05-14 12:51:42 [ ConcolePool housekeeper:5606359 ] - [ WARN ] Connection leak detection triggered for com.mysql.jdbc.JDBC4Connection@1cff4d1c, stack trace follows
2018-05-14 12:51:49 [ ConcolePool housekeeper:5613203 ] - [ DEBUG ] ConcolePool - Pool stats (total=9, active=4, idle=5, waiting=0)
2018-05-14 12:52:19 [ ConcolePool housekeeper:5643219 ] - [ DEBUG ] ConcolePool - Pool stats (total=9, active=4, idle=5, waiting=0)
2018-05-14 12:52:49 [ ConcolePool housekeeper:5673234 ] - [ DEBUG ] ConcolePool - Pool stats (total=9, active=5, idle=4, waiting=0)
2018-05-14 12:52:49 [ ConcolePool connection adder:5673234 ] - [ DEBUG ] ConcolePool - Added connection com.mysql.jdbc.JDBC4Connection@2d750b07
2018-05-14 12:52:49 [ ConcolePool connection adder:5673234 ] - [ DEBUG ] ConcolePool - After adding stats (total=10, active=5, idle=5, waiting=0)
2018-05-14 12:52:53 [ ConcolePool housekeeper:5676453 ] - [ WARN ] Connection leak detection triggered for com.mysql.jdbc.JDBC4Connection@708cdc47, stack trace follows
2018-05-14 12:53:19 [ ConcolePool housekeeper:5703250 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=6, idle=4, waiting=0)
2018-05-14 12:53:43 [ ConcolePool housekeeper:5726594 ] - [ WARN ] Connection leak detection triggered for com.mysql.jdbc.JDBC4Connection@39193bcd, stack trace follows
2018-05-14 12:53:49 [ ConcolePool housekeeper:5733265 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=6, idle=4, waiting=0)
2018-05-14 12:54:19 [ ConcolePool housekeeper:5763281 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=7, idle=3, waiting=0)
2018-05-14 12:54:39 [ ConcolePool housekeeper:5782984 ] - [ WARN ] Connection leak detection triggered for com.mysql.jdbc.JDBC4Connection@207b7ac0, stack trace follows
2018-05-14 12:54:49 [ ConcolePool housekeeper:5793297 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=7, idle=3, waiting=0)
2018-05-14 12:55:19 [ ConcolePool housekeeper:5823312 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=8, idle=2, waiting=0)
2018-05-14 12:55:45 [ ConcolePool housekeeper:5848906 ] - [ WARN ] Connection leak detection triggered for com.mysql.jdbc.JDBC4Connection@4721d5d3, stack trace follows
2018-05-14 12:55:49 [ ConcolePool housekeeper:5853328 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=8, idle=2, waiting=0)
2018-05-14 12:56:19 [ ConcolePool housekeeper:5883344 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=8, idle=2, waiting=0)
2018-05-14 12:56:49 [ ConcolePool housekeeper:5913359 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=8, idle=2, waiting=0)
2018-05-14 12:57:20 [ ConcolePool housekeeper:5943375 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=8, idle=2, waiting=0)
2018-05-14 12:57:50 [ ConcolePool housekeeper:5973390 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=8, idle=2, waiting=0)
2018-05-14 12:58:20 [ ConcolePool housekeeper:6003406 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=8, idle=2, waiting=0)
2018-05-14 12:58:50 [ ConcolePool housekeeper:6033422 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=8, idle=2, waiting=0)
2018-05-14 12:59:20 [ ConcolePool housekeeper:6063437 ] - [ DEBUG ] ConcolePool - Pool stats (total=10, active=10, idle=0, waiting=1)
この問題をトラブルシューティングする方法は?変更する必要があるものはありますか?
編集:
public Connection getConnection(){
try{
return datas.getConnection();
} catch (SQLException e){
e.printStackTrace();
datas.resumePool();
return null;
}
}
密接な接続の例:
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
DataSource datas = (DataSource) getServletContext().getAttribute("ds");
Connection conn = null;
Statement stmt = null;
try{
conn = datas.getConnection();
stmt = conn.createStatement();
//some sql
//process form
//pass the return values
stmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
接続を常に閉じているわけではないため、接続プールは制限に達します。
あなた必須ブロックが終了したら(すべてのリソースとして)接続とステートメントを閉じます。例外が発生した場合も、正しい/簡単な方法は リソースで試す アプローチです。
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
DataSource datas = (DataSource) getServletContext().getAttribute("ds");
try (Connection conn = datas.getConnection();Statement stmt = conn.createStatement()){
//some sql
//process form
//pass the return values
} catch (Exception e) {
e.printStackTrace();
}
}
Try-with-resourcesステートメントtry-with-resourcesステートメントは、1つ以上のリソースを宣言するtryステートメントです。リソースは、プログラムが終了した後に閉じる必要があるオブジェクトです。 try-with-resourcesステートメントは、ステートメントの最後で各リソースが閉じられるようにします。