我在amazon vm上使用amazon RDS运行我的tomcat,最近我注意到如果RDS必须重新启动,那么我的webapp将失去与它的连接,并且不会完成api请求。那是我发现hiberante c3p0的连接池的时候。
我最近的问题是运行6-12小时后tomcat将停止响应请求,然后一旦我进入tomcat服务器状态,我可以在线程上看到这个
Max threads: 200 Current thread count: 150 Current thread busy: 150..
此外还有大量响应时间的api电话。 然而,在记忆中一切似乎都没问题。 几乎感觉就像hibernate开始挂起一段时间后?虽然sql server上的连接数非常少,但小于10。
我很确定我的hibernate配置文件中有什么问题,可以请别人看看那里有什么奇怪的东西,
<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>
祝你好运