2017-02-23 62 views
1

我對PlayFramework 2.5中HikariCP的配置有點困惑。PlayFramework 2.5:HikariCP忽略application.conf中的一些(但不是全部)設置

我補充說,我application.conf文件:

play.db { 
    # The combination of these two settings results in "db.default" as the 
    # default JDBC pool: 
    config = "db" 
    default = "default" 
    # Play uses HikariCP as the default connection pool. You can override 
    # settings by changing the prototype: 
    prototype { 
    hikaricp.maximumPoolSize = 30 
    hikaricp.connectionTimeout = 5 seconds 
    hikaticp.maxLifetime = 10 seconds 
    hikaticp.idleTimeout = 5 seconds 
    } 
} 

db.default.driver=org.postgresql.Driver 
db.default.url=${?JDBC_DATABASE_URL} 
db.default.username=${?DATABASE_USERNAME} 
db.default.password=${?DATABASE_PASSWORD} 

這工作正常。我獲得了到數據庫的連接並可以提交查詢和全部。我的問題是,只使用HikariCP設置的一部分。在應用程序開始我趕上使用HikariCP參數:

[ 2017-02-23 11:12:58,413 ] [info] application - Creating Pool for datasource 'default' 
[ 2017-02-23 11:12:58,424 ] [debug] c.z.h.HikariConfig - HikariPool-1 - configuration: 
[ 2017-02-23 11:12:58,430 ] [debug] c.z.h.HikariConfig - allowPoolSuspension.............false 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - autoCommit......................true 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - catalog.........................null 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - connectionInitSql...............null 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - connectionTestQuery.............null 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - connectionTimeout...............5000 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - dataSource......................null 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - dataSourceClassName.............null 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - dataSourceJNDI..................null 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - dataSourceProperties............{password=<masked>} 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - driverClassName................."org.postgresql.Driver" 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - healthCheckProperties...........{} 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - healthCheckRegistry.............null 
[ 2017-02-23 11:12:58,431 ] [debug] c.z.h.HikariConfig - idleTimeout.....................600000 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - initializationFailFast..........true 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - isolateInternalQueries..........false 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - jdbc4ConnectionTest.............false 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - jdbcUrl........................."XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - leakDetectionThreshold..........0 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - maxLifetime.....................1800000 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - maximumPoolSize.................30 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - metricRegistry..................null 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - metricsTrackerFactory...........null 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - minimumIdle.....................30 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - password........................<masked> 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - poolName........................"HikariPool-1" 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - readOnly........................false 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - registerMbeans..................false 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - scheduledExecutorService........null 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - threadFactory...................null 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - transactionIsolation............null 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - username........................"XXXXXXXXXXXXXXXX" 
[ 2017-02-23 11:12:58,432 ] [debug] c.z.h.HikariConfig - validationTimeout...............5000 

的值maximumPoolSizeconnectionTimeout如在application.conf設置。但maxLifetimeidleTimeout的值將被忽略並設置爲其他值。

application.conf的語法在某些點是錯誤的,我看不到錯誤?

回答

1

他們非常小,嘗試設置5分鐘。

現在你必須在類似

maxLifetime is less than 30000ms, using default 1800000ms. 

HikariCP源代碼中的日誌消息看:

LOGGER.warn("{} - maxLifetime is less than 30000ms, setting to default {}ms.", poolName, MAX_LIFETIME); 
... 
LOGGER.warn("{} - idleTimeout is less than 10000ms, setting to default {}ms.", poolName, IDLE_TIMEOUT); 
+0

謝謝!對於這些變量來說,最小值也是我的想法,但我還沒有找到提示。此外:應用程序的真正問題是連接處理不好,導致連接池在短時間後沒有可用連接。解決這個問題後,我們不需要這麼短的maxLifetime值。 – Thargor

相關問題