playframework / playframework/play-slick
Cannot acquire connection on many "refresh"
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 794
- Forks
- 272
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 17
Description
When i try to refresh my application running on sbt, it seems like the connection pool is not releasing connections.
Here is the error
[debug] com.zaxxer.hikari.pool.HikariPool - Cannot acquire connection from data source
org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
at org.postgresql.Driver.makeConnection(Driver.java:454)
at org.postgresql.Driver.connect(Driver.java:256)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:117)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:123)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:365)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:194)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:460)
Caused by: java.net.SocketException: Bad file descriptor (Write failed)
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at org.postgresql.core.PGStream.flush(PGStream.java:527)
at org.postgresql.core.v3.ConnectionFactoryImpl.sendStartupPacket(ConnectionFactoryImpl.java:480)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:138)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
The config we use is this :
profile = "utils.MyPostgresProfile$"
db {
url = "jdbc:postgresql://localhost:5432/<dbname>?currentSchema=app&loggerLevel=TRACE&loggerFile=./log_pgsql.log&connectTimeout=3&socketTimeout=5&tcpKeepAlive=true&sslmode=disable&ssl=false&"
properties.driver = "org.postgresql.Driver"
user = <myuser>
password = <mypassword>
poolName = <mypoolname>
registerMbeans = false
connectionTimeout = 10s
connectionInitSql = "SELECT 1"
connectionTestQuery = "SELECT 1"
validationTimeout = 5000
idleTimeout = 300000
maxLifetime = 50000
minimumIdle = 10
leakDetectionThreshold=2000
maximumPoolSize = 25
initializationFailTimeout = 0
}
}
which is then taken under by Hikari and it looks like this
[warn] com.zaxxer.hikari.HikariConfig - The initializationFailFast propery is deprecated, see initializationFailTimeout
[warn] com.zaxxer.hikari.HikariConfig - app - idleTimeout is close to or more than maxLifetime, disabling it.
[debug] com.zaxxer.hikari.HikariConfig - app - configuration:
[debug] com.zaxxer.hikari.HikariConfig - allowPoolSuspension.............false
[debug] com.zaxxer.hikari.HikariConfig - autoCommit......................true
[debug] com.zaxxer.hikari.HikariConfig - catalog.........................none
[debug] com.zaxxer.hikari.HikariConfig - connectionInitSql..............."SELECT 1"
[debug] com.zaxxer.hikari.HikariConfig - connectionTestQuery............."SELECT 1"
[debug] com.zaxxer.hikari.HikariConfig - connectionTimeout...............10000
[debug] com.zaxxer.hikari.HikariConfig - dataSource......................none
[debug] com.zaxxer.hikari.HikariConfig - dataSourceClassName.............none
[debug] com.zaxxer.hikari.HikariConfig - dataSourceJNDI..................none
[debug] com.zaxxer.hikari.HikariConfig - dataSourceProperties............{password=<masked>, driver=org.postgresql.Driver}
[debug] com.zaxxer.hikari.HikariConfig - driverClassName.................none
[debug] com.zaxxer.hikari.HikariConfig - healthCheckProperties...........{}
[debug] com.zaxxer.hikari.HikariConfig - healthCheckRegistry.............none
[debug] com.zaxxer.hikari.HikariConfig - idleTimeout.....................0
[debug] com.zaxxer.hikari.HikariConfig - initializationFailFast..........false
[debug] com.zaxxer.hikari.HikariConfig - initializationFailTimeout.......-1
[debug] com.zaxxer.hikari.HikariConfig - isolateInternalQueries..........false
[debug] com.zaxxer.hikari.HikariConfig - jdbc4ConnectionTest.............false
[debug] com.zaxxer.hikari.HikariConfig - jdbcUrl.........................jdbc:postgresql://localhost:5432/<mydbname>?currentSchema=app&loggerLevel=TRACE&loggerFile=./log_pgsql.log&connectTimeout=3&socketTimeout=5&tcpKeepAlive=true&sslmode=disable&ssl=false&
[debug] com.zaxxer.hikari.HikariConfig - leakDetectionThreshold..........2000
[debug] com.zaxxer.hikari.HikariConfig - maxLifetime.....................50000
[debug] com.zaxxer.hikari.HikariConfig - maximumPoolSize.................100
[debug] com.zaxxer.hikari.HikariConfig - metricRegistry..................none
[debug] com.zaxxer.hikari.HikariConfig - metricsTrackerFactory...........none
[debug] com.zaxxer.hikari.HikariConfig - minimumIdle.....................20
[debug] com.zaxxer.hikari.HikariConfig - password........................<masked>
[debug] com.zaxxer.hikari.HikariConfig - poolName........................<mypoolname>
[debug] com.zaxxer.hikari.HikariConfig - readOnly........................false
[debug] com.zaxxer.hikari.HikariConfig - registerMbeans..................false
[debug] com.zaxxer.hikari.HikariConfig - scheduledExecutor...............none
[debug] com.zaxxer.hikari.HikariConfig - scheduledExecutorService........internal
[debug] com.zaxxer.hikari.HikariConfig - schema..........................none
[debug] com.zaxxer.hikari.HikariConfig - threadFactory...................internal
[debug] com.zaxxer.hikari.HikariConfig - transactionIsolation............default
[debug] com.zaxxer.hikari.HikariConfig - username........................<myuser>
[debug] com.zaxxer.hikari.HikariConfig - validationTimeout...............5000
And its always, always happening after 5 refresh. No matter what I set in maxConnections, numThreads, etc etc etc.
Any idea ?!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with the reported sbt refresh workflow and compare the configured pool values with the effective Hikari configuration shown in the logs. Inspect the PostgreSQL connection settings, refresh lifecycle, and pool behavior; done means identifying a reproducible cause for the connection failure after repeated refreshes and documenting the verified resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, scala
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100