简体   繁体   English

长时间不活动后,tomcat没有响应

[英]tomcat not responding after long time of inactivity

I am using hibernate c3p0 with mysql database , my c3p0 config is below: 1 我正在将hibernate c3p0与mysql数据库一起使用,我的c3p0配置如下:1

    <property name="hibernate.c3p0.idle_test_period">100</property>
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.max_size">20</property>        
        <property name="hibernate.c3p0.max_statements">0</property>
        <property name="hibernate.c3p0.timeout">200</property>
<property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>

it is working fine but problem arises when server stays idle for long time like 8-10 hours , tomcat not respond after that and there is no error log surprisingly from any side(mysql,hibernate,tomcat) it keeps me waiting for response (we are making httprequest to servlet) but do not throw any error, I cant see any error log on tomcat logs 它工作正常,但是当服务器长时间闲置(如8-10个小时)时出现问题,tomcat之后没有响应,并且从任何侧面(mysql,hibernate,tomcat)都没有令人惊讶的错误日志,这使我一直在等待响应(我们正在对servlet进行httprequest),但没有抛出任何错误,我在tomcat日志上看不到任何错误日志

so I am not sure if its the issue of c3p0 or mysql, anybody can help, much appreciated!! 所以我不确定是否是c3p0或mysql的问题,任何人都可以帮忙,不胜感激!

when the database is on a seperate box and there's a firewall in between which is set to timeout idle connections. 当数据库位于单独的盒子上并且中间有防火墙设置为超时空闲连接时。

In some circumstances the firewall cuts off the connection in such a way that the JDBC end doesn't detect, and attempting to use it results in an indefinite block. 在某些情况下,防火墙以JDBC端无法检测到的方式切断连接,尝试使用它会导致不确定的阻塞。

And if it is a custom connection pool which sent a test query down the connection before returning it from the pool. 如果它是一个自定义连接池,则在从连接池返回连接之前先向连接发送了一个测试查询。 Configured this test query to have a timeout using 'Statement.setQueryTimeout' so that it didn't block indefinitely. 使用“ Statement.setQueryTimeout”将此测试查询配置为具有超时,以使其不会无限期地阻塞。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM