Hibernate, Tomcat hangs after a while

1.3k views Asked by At

Im running my tomcat on amazon vm, with amazon RDS, recently i noticed that if RDS has to restart then my webapp loses connection to it and no api requests would complete. That's when i discovered connection pool for hiberante c3p0.

My most recent issue is that after 6-12 hours of running tomcat would stop responding to the requests, then once i go to the tomcat server status i can see this on Threads

 Max threads: 200 Current thread count: 150 Current thread busy: 150..

Also with stock of api calls that is being holed with huge response time. However on memory everything seems alright. It almost feels like after some time hibernate starts to hang? although the number of connections on sql server is pretty low, less than 10.

I'm pretty sure i have something wrong in my hibernate config file, could please someone see if that see anything weird in there,

<hibernate-configuration>
    <session-factory>
            <property name="hibernate.connection.url">jdbc:mysql://myapp.amazon.us-west-2.rds.amazonaws.com:3306</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
        <!--<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>-->
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>


        <property name="hibernate.connection.username"></property>
        <property name="hibernate.connection.password">password</property>
        <property name="hibernate.default_schema">default_schema</property>

        <property name="hibernate.connection.autoReconnect">true</property>
        <property name="hibernate.show_sql">true</property>


        <!--Settings for c3p0 connection pool-->
        <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <property name="hibernate.c3p0.acquire_increment">1</property>
        <property name="hibernate.c3p0.idle_test_period">60</property>
        <property name="hibernate.c3p0.min_size">1</property>
        <property name="hibernate.c3p0.max_size">50</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.timeout">30</property>
        <property name="hibernate.c3p0.acquireRetryAttempts">1</property>
        <property name="hibernate.c3p0.acquireRetryDelay">300</property>

        <!--<property name="hibernate.c3p0.breakAfterAcquireFailure">false</property>-->


        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.use_sql_comments">true</property>

        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
        <property name="hibernate.current_session_context_class">thread</property>

        <!--<property name="hibernate.c3p0.preferredTestQuery">select 1</property>-->
        <!--<property name="hibernate.c3p0.testConnectionOnCheckout">true</property>-->
        <!--=======================-->


        <mapping resource="/mappings/...>
    </session-factory>
</hibernate-configuration>

Best regards

0

There are 0 answers