Hikari configuration settings

thumbnail
Pete Helgren, modified 4 Years ago. Regular Member Posts: 225 Join Date: 4/7/11 Recent Posts

I am dealing with what I think is a connection pooling issue.  The initial trigger was that we have an external service that calls a Liferay API (7.3.2-ga3 CE) .  The external service indicates that Liferay failed to respond from time to time.  Now, I understand that there are many moving parts here but my primary focus is to make sure that the LR instance is optimally configured.  So, my initial assumption was that we had a DB connection pool issue.  We have a connection to an external SQL server that originally was using the default Tomcat DB connection pool.  Using David Nebinger's blog post, I switched over to using Hikari.  That doesn't seem to have helped much.

To test the pooling and responses, I added a JMeter test to crank up 200 requests to the API.  I also set the Hikari logging to DEBUG.  What I see in the log is that HikariPool-1 throws an error:

2021-01-18 15:03:28.499 ERROR [http-nio-8080-exec-193][JSONWebServiceServiceAction:114] org.hibernate.exception.GenericJDBCException: Cannot open connection
2021-01-18 15:03:28.499 ERROR [http-nio-8080-exec-192][JDBCExceptionReporter:234] HikariPool-1 - Connection is not available, request timed out after 30000ms.

I think that indcates that the pool is exhausted (not sure though).  So my initial question here is what is HikariPool-1 ?  I see HikariPool-1, HikariPool-2 and HikariPool-3 listed in the DEBUG log.  I assume that one of them is the MSSQL server connection, probably HikariPool-3.  I understand that by default, Liferay uses Hikari, so I expect that either HikariPool-1 or HikariPool-2 is the Liferay connection.  But why are there two?  

Further, if HikariPool-1 and HikariPool-2 are related to Liferay, where do I configure those connection properties since at least one of them seems too small?  Any pointers here on how best to configure the Hikari pools would be helpful.  That, and helping me to determine why there seem to be two pools for Liferay OOTB.

Thanks

 

thumbnail
Jamie Sammons, modified 4 Years ago. New Member Posts: 4 Join Date: 10/8/12 Recent Posts

Hi Pete, I am facing the same problem when I generate large LAR files. It seems that hikari pool closes all connections after exceeding 30001 ms. I read this post by David Nebinger and moved some settings from the pool. I understand that with short transactions in time the pool works wonderfully but with long transactions it gets quite bogged down. The problem is that you would have to manage different pools for different type of transactions. I'm at that point in my research. Have you had any progress that you could share with me?

thumbnail
Jamie Sammons, modified 4 Years ago. New Member Posts: 4 Join Date: 10/8/12 Recent Posts

I forgot to mention that even though I moved a lot of pool settings I had the same results. Now I am working with this MySQL configuration to make the prepared statement cache bigger.

-prepStmtCacheSize

-prepStmtCacheSqlLimit

-cachePrepStmts

-useServerPrepStmts

thumbnail
Pete Helgren, modified 4 Years ago. Regular Member Posts: 225 Join Date: 4/7/11 Recent Posts

HI Guillermo,


You are forcing me to take a trip on the wayback machine... :-)  I am not seeing that error in the current logs so either I fixed it and it no longer is an issue, or it wasn't a Hakari issue.  What I did see in the logs was a 60 second timeout and that occurs when we have database server issues (offline).  So, it looks like I changed the timeout to 60 seconds.  I also have these settings which don't follow the pooling recommendations I read about for Hikari (FWIW):

       factory="com.zaxxer.hikari.HikariJNDIFactory"
       type="javax.sql.DataSource"
       minimumIdle="50"
       maximumPoolSize="250"

We'll be ramping up the connections again in about a week (400,000 users come back online) so we'll see if the problem reccurs.

Sorry I can't be of more help.

Pete