Hi, we created an application using RapidclipseX and using PostgreSQL as a database. Below was my initial setting of peristance.xml.
property name="hibernate.hbm2ddl.auto" value="none" />
<property name="javax.persistence.sharedCache.mode" value="ENABLE_SELECTIVE" />
<property name="hibernate.c3p0.max_size" value="50000" />
<property name="hibernate.c3p0.idle_test_period" value="300" />
<property name="hibernate.c3p0.max_statements" value="100" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL95Dialect" />
<property name="hibernate.cache.use_query_cache" value="true" />
<property name="hibernate.c3p0.min_size" value="1" />
<property name="hibernate.default_schema" value="canavans" />
<property name="rap.queryCache.mode" value="ENABLE_SELECTIVE" />
<property name="hibernate.archive.autodetection" value="" />
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.c3p0.timeout" value="3000" />
<property name="hibernate.transaction.auto_close_session" value="false" />
<property name="hibernate.javax.cache.uri" value="classpath:ehcache.xml" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jcache.JCacheRegionFactory" />
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="hibernate.generate_statistics" value="false" />
<property name="hibernate.auto_quote_keyword" value="true" />
<property name="hibernate.globally_quoted_identifiers" value="true" />
When we went on production, we started to get an error: " acquire test – the pool is already maxed out."
Then I added these 2 lines:
<property name="hibernate.c3p0.unreturnedConnectionTimeout" value="120" />
<property name="hibernate.c3p0.debugUnreturnedConnectionStackTraces" value="true" />
For some time, it solved our issue. But now, after we imported the old database, we started to get a new error:
2020-11-25 16:44:11 DEBUG DefaultConnectionTester:207 - Testing a Connection in response to an Exception:
org.postgresql.util.PSQLException: This connection has been closed.
2020-11-25 16:44:11 DEBUG NewPooledConnection:207 - com.mchange.v2.c3p0.impl.NewPooledConnection@614f3f61 invalidated by Exception.
when I google for the problem, I found that: the solution for the Maxed out the problem that I've implemented (those 2 lines) can be the problem for the new exceptions.
I've also found the connection leak problem. I tried to close entityManager in DAOs, but when I add any JPA-SQL Query and load the Java file, those lines disappear.
Please help me how to solve this issue once and for all. Is there is any efficient way to do this? We have to restart our application on production again and again.
I really appreciate any help you can provide.
I came to know that connection leak is happening because of the Gallery I have created.
Describe the bug
We have the situation: where we are showing the pictures in a gallery. These pictures are loading from the local resource (hard drive).
We are using code from the example given on Vaadin Documentation. [Dynamic Content](https://vaadin.com/docs/flow/advanced/tutorial-dynamic-content.html).
We have designed our picture gallery to display the pictures on our website (a compulsory module). For a long time, this project is live, and we were having a pool issue. The pool was getting created but never getting close whenever we load our gallery view. From the beginning till now, we have to restart our application.
A few weeks ago, I created an issue on the Vaadin's Github page. Vaddin Github Bug Page
and as suggested by them, we start to test this gallery code in a new fresh project.
Till the time we didn't configure the project with JPA/Hibernate, the view page was working fine without any pool generation.
But the moment we configure the project with Hibernate/JPA and when we load the page, it starts to create pools (even if we are not using any hibernate query on that page).
I have explained all the scenarios in detail on Vaadin's Github (Vaddin Github Bug Page).
I have also sent an email of the demo project and its log to: firstname.lastname@example.org, email@example.com, and firstname.lastname@example.org