0
I have an application in java that provides Rest services with Servlets and Hibernate, which at first works perfectly. I can make thousands of requests to various services that recover information in the base Firebird that she responds very well... But sometimes Firebird crashes or simply gets restarted, and then my application stayed It was jammed with communication problems even when the Firebird bank was back up and running. Then it was necessary to restart my application to get back to normal.
I solved this connection problem by adding the following commands in the file Hibernate.cfg.xml:
<property name="hibernate.c3p0.acquire_increment">5</property>
<property name="hibernate.c3p0.idle_test_period">120</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.timeout">600</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1</property>
After 120 seconds that the stopped flock returned to work, the application also restarted the connection, and allowed to make new requests...
Then I came across another problem.
Once the application is back up and running, it becomes unstable. It goes on to return synchronized connection errors according to the number of requests: time every three requests successfully one is returned the error (Always in that order); and if you do a new test, restarting the application, this schedule can change, as every 5 request a failure...
That mistake synchronized seems to me a symptom of a mistake that disarmed me...
All my configuration code from Hibernate.cfg.xml
<property name="hibernate.dialect">org.hibernate.dialect.FirebirdDialect</property>
<property name="hibernate.connection.driver_class">org.firebirdsql.jdbc.FBDriver</property>
<property name="hibernate.connection.url">jdbc:firebirdsql://localhost:3050/D:/automacao/projetos/DB/DB.FDB</property>
<property name="hibernate.connection.username">USER</property>
<property name="hibernate.connection.password">*******</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.connection.isolation">1</property>
<!--Configurações adicionais -->
<property name="current_session_context_class">thread</property>
<property name="connection.relaxAutoCommit">true</property>
<property name="connection.autoReconnect">true</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.connection.release_mode">on_close</property>
<!-- Usando as configurações do C3PO para pool de conexões -->
<property name="hibernate.c3p0.acquire_increment">5</property>
<property name="hibernate.c3p0.idle_test_period">120</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.timeout">600</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1</property>
I ask for the help of someone to try to solve this problem.
Unfortunately I could not find a solution, I believe it may be an error in the Firebird connection driver. But I managed to circumvent by creating a Windows service that tests the application from time to time and restarts apache Tomcat if there are any errors.
thanks for the help @ramarcio. The isolation is the same that I need... because it is an application for online stock control, so I need to know the changes of a third transaction even before it is committed...I will do the test taking off release_mode.
– João Paulo
@ramarcio, still continued with the problem after the changes, error that only happens after stopping and then starting the database.
– João Paulo
That sucks, I don’t know what else it could be. Did you try testing with another database, like Mysql or any other? Sometimes it may be a bug from the database or the connection driver.
– romarcio
I’m going to test yes....
– João Paulo