HikariCP
HikariCP copied to clipboard
HikariPool-1 - Connection is not available, request timed out after 30002ms.
Hi, I am currently using Hibernate ORM with JPA WITHOUT Spring Data and wanted to use HikariCP. After some time I get these errors and no DB requests are responding (I can't get any DATA). I am also using CDI from WELD but that shouldn't be a problem.
This is what I use and how I use it:
implementation 'org.hibernate:hibernate-core:5.6.5.Final'
runtimeOnly 'org.hibernate:hibernate-hikaricp:5.6.5.Final'
This is my persistence.xml
<persistence
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="PERSISTENCE">
<description>Interception Hibernate ORM</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>dev.marvn.interception.db.entitys.ServerDataEntity</class>
<class>dev.marvn.interception.db.entitys.WelcomeDataEntity</class>
<class>dev.marvn.interception.db.entitys.VerifyRoleEntity</class>
<class>dev.marvn.interception.db.entitys.VerifyDataEntity</class>
<class>dev.marvn.interception.db.entitys.TempChannelTemporaryEntity</class>
<class>dev.marvn.interception.db.entitys.TempChannelMainEntity</class>
<class>dev.marvn.interception.db.entitys.TempChannelCommandChannelEntity</class>
<class>dev.marvn.interception.db.entitys.JoinRoleEntity</class>
<properties>
<property name="javax.persistence.jdbc.driver"
value="com.mysql.cj.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url"
value="XXXXXXX"/>
<property name="javax.persistence.jdbc.user" value="XXXXX"/>
<property name="javax.persistence.jdbc.password" value="XXXX"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.hikari.maximumPoolSize" value="15"/>
<property name="hibernate.hikari.idleTimeout" value="30000"/>
<property name="hibernate.connection.provider_class"
value="org.hibernate.hikaricp.internal.HikariCPConnectionProvider"/>
</properties>
</persistence-unit>
</persistence>
This is one method which I call pretty often. #getEntityManager does return a freshly build entityManager!
public Optional<TempChannelTemporaryEntity> getTempChannelTempByVoiceChannelId(Long voiceChannelId) {
var entityManager = getEntityManager();
var query = entityManager.createNamedQuery("TempChannelTemporary.GetByVoiceChannelId", TempChannelTemporaryEntity.class);
query.setParameter("id", voiceChannelId);
return query.
getResultStream()
.findAny();
}
This is my error
[ERROR] 2022-02-24 10:16:41,648 | org.hibernate.engine.jdbc.spi.SqlExceptionHelper : logExceptions > HikariPool-1 - Connection is not available, request timed out after 30002ms.
2022-02-24T10:16:41.658336500Z [ERROR] 2022-02-24 10:16:41,653 | org.javacord.core.util.logging.PrivacyProtectionLogger : logMessage > Unhandled exception in a listener thread for Marvn's behinderter Test Server voll mit unfreundlichen Bots!
2022-02-24T10:16:41.658384300Z org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
2022-02-24T10:16:41.658402500Z at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:48) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658418000Z at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:37) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658432200Z at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658447500Z at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658459600Z at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:111) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658473500Z at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658488800Z at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658497400Z at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658510000Z at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658526800Z at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658544900Z at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2122) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658573700Z at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2059) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658591400Z at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658605000Z at org.hibernate.loader.Loader.scroll(Loader.java:2945) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658620800Z at org.hibernate.loader.custom.CustomLoader.scroll(CustomLoader.java:383) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658636600Z at org.hibernate.internal.SessionImpl.scrollCustomQuery(SessionImpl.java:2156) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658659600Z at org.hibernate.internal.AbstractSharedSessionContract.scroll(AbstractSharedSessionContract.java:1209) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658678500Z at org.hibernate.query.internal.NativeQueryImpl.doScroll(NativeQueryImpl.java:224) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658690900Z at org.hibernate.query.internal.AbstractProducedQuery.scroll(AbstractProducedQuery.java:1574) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658704500Z at org.hibernate.query.internal.AbstractProducedQuery.stream(AbstractProducedQuery.java:1598) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658719800Z at org.hibernate.query.Query.getResultStream(Query.java:1140) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.658736200Z at dev.marvn.interception.db.DatabaseManager.getServerData(DatabaseManager.java:38) ~[Interception-Javacord-3.0.3.jar:?]
2022-02-24T10:16:41.658765300Z at dev.marvn.interception.db.DatabaseManager$Proxy$_$$_WeldClientProxy.getServerData(Unknown Source) ~[Interception-Javacord-3.0.3.jar:?]
2022-02-24T10:16:41.658777700Z at dev.marvn.interception.commandFramework.CommandContextListener.transform(CommandContextListener.java:46) ~[Interception-Javacord-3.0.3.jar:?]
2022-02-24T10:16:41.658790000Z at dev.marvn.interception.commandFramework.CommandContextListener$Proxy$_$$_WeldClientProxy.transform(Unknown Source) ~[Interception-Javacord-3.0.3.jar:?]
2022-02-24T10:16:41.658804900Z at net.kautler.command.api.CommandHandler.computePrefix(CommandHandler.java:315) ~[command-framework-0.4.0-SNAPSHOT.jar:?]
2022-02-24T10:16:41.658821400Z at net.kautler.command.api.CommandHandler.doHandleMessage(CommandHandler.java:275) ~[command-framework-0.4.0-SNAPSHOT.jar:?]
2022-02-24T10:16:41.658838000Z at net.kautler.command.handler.CommandHandlerJavacord.handleMessage(CommandHandlerJavacord.java:174) ~[command-framework-0.4.0-SNAPSHOT.jar:?]
2022-02-24T10:16:41.658853600Z at org.javacord.core.util.event.EventDispatcher.lambda$dispatchMessageCreateEvent$146(EventDispatcher.java:5249) ~[javacord-core-3.4.0.jar:?]
2022-02-24T10:16:41.658870700Z at org.javacord.core.util.event.EventDispatcherBase.lambda$dispatchEvent$12(EventDispatcherBase.java:209) ~[javacord-core-3.4.0.jar:?]
2022-02-24T10:16:41.658881800Z at org.javacord.core.util.event.EventDispatcherBase.lambda$checkRunningListenersAndStartIfPossible$20(EventDispatcherBase.java:277) ~[javacord-core-3.4.0.jar:?]
2022-02-24T10:16:41.658925300Z at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
2022-02-24T10:16:41.658944200Z at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
2022-02-24T10:16:41.659010200Z at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
2022-02-24T10:16:41.659019800Z at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
2022-02-24T10:16:41.659032900Z at java.lang.Thread.run(Thread.java:832) [?:?]
2022-02-24T10:16:41.659047900Z Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30002ms.
2022-02-24T10:16:41.659059700Z at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:676) ~[HikariCP-3.2.0.jar:?]
2022-02-24T10:16:41.659076700Z at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:190) ~[HikariCP-3.2.0.jar:?]
2022-02-24T10:16:41.659092700Z at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:155) ~[HikariCP-3.2.0.jar:?]
2022-02-24T10:16:41.659106100Z at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:100) ~[HikariCP-3.2.0.jar:?]
2022-02-24T10:16:41.659125000Z at org.hibernate.hikaricp.internal.HikariCPConnectionProvider.getConnection(HikariCPConnectionProvider.java:77) ~[hibernate-hikaricp-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.659141400Z at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.659159800Z at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) ~[hibernate-core-5.6.5.Final.jar:5.6.5.Final]
2022-02-24T10:16:41.659177400Z ... 31 more
I have no clue what's going on. I need help.Just let me know if you need additional data Best Regards
I had a same question.
Finally, I found that my param maximum-pool-size
is too small.
My program is web's Program, and the servlet work thread is bigger than the hikariCP's maximum-pool-size.
Sometimes, it had the HikariPool-1 - Connection is not available
error.
I had a same question. Finally, I found that my param
maximum-pool-size
is too small.My program is web's Program, and the servlet work thread is bigger than the hikariCP's maximum-pool-size. Sometimes, it had the
HikariPool-1 - Connection is not available
error.
Is the connection closed when the query had completed?
No, when the query had completed, the connection return to Hikari‘s Pool.