Hibernate, C3P0, Mysql — Broken Pipe

后端 未结 5 483
予麋鹿
予麋鹿 2020-12-08 16:46

MySQL seems to have an 8 hour time out on its connections. I\'m running multiple WARs in Tomcat utilizing Hibernate for ORM. After 8 hours (i.e. overnight), I get broken pip

5条回答
  •  难免孤独
    2020-12-08 17:18

    This is a solution when you have a broken pipe because of combination of tomcat's wait_timeout=28800 sec(8h) and maxIdleTime=0 in c3p0:

    I've changed the local tomcat wait_timeout via my.ini file to 120sec (2 min). And I placed the following:
    maxIdleTime=100
    idleConnectionTestPeriod=0 (same as default/as if it didn't exist)
    other:
    acquireIncrement=2
    minPoolSize=2
    maxPoolSize=5
    maxIdleTimeExcessConnections=10

    I had no problems with this setup.

    I didn't need to use idleConnectionTestPeriod!

    If tomcat's wait_timeout is 28800 sec, and maxIdleTime is 25200, it means that c3p0 will close the idle connection in 3600sec (1h) earlier, before tomcat throws a "broken pipe" exception. Isn't that right?!

    As you can see I have no issues with providing only maxIdleTime.

    Unfortunately, these:
    maxIdleTime
    idleConnectionTestPeriod
    configuring_connection_testing
    testConnectionOnCheckin
    don't explain too much the corner cases.

    And, btw, here is how to open the tomcat's my.ini file with Notepad++: http://drupal.org/node/32715#comment-4907440

    Cheers,
    Despot

提交回复
热议问题