2014-06-17 2 views
0

전 MySQL DB에서 작동하는 여러 서버가있는 분산 시스템에서 작동하고 여러 가지 다양한 쿼리로 DB를 복제했습니다. 여러 서버가 최대 1000 개의 연결 (하드 시간에 700 - 800, 900)의 복합 물질을 사용합니다. 주기적으로C3P0 설정이 모호합니다.

나는 MySQL의에 의해 폐쇄 연결에 문제가 이미 지루한 예외를 참조하십시오 아웃 (wait_timeout)의

The last packet sent successfully to the server was 65,179,696 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. 

MySQL의 설정은 기본이고 내가 C3P0 최대 절전 모드와 짝을 사용

28800 (8 시간)에 해당

<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> 
    <property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property> 
    <property name="hibernate.connection.url">jdbc:mysql://xxx.xxx.xxx.xxx:3306/ibaserver?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=cp1251&amp;zeroDateTimeBehavior=convertToNull</property> 
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="hibernate.connection.username">username</property> 
    <property name="hibernate.connection.password">********</property> 
    <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> 
    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> 

    <property name="hibernate.c3p0.min_size">5</property> 
    <property name="hibernate.c3p0.max_size">50</property> 
    <property name="hibernate.c3p0.timeout">1800</property> 
    <property name="hibernate.c3p0.max_statements">0</property> 
    <property name="hibernate.c3p0.idle_test_period">59</property> 
    <property name="hibernate.c3p0.acquire_increment">3</property> 
    <property name="hibernate.c3p0.preferredTestQuery">select 1</property> 

    <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property> 
    <property name="hibernate.cache.use_query_cache">false</property> 
    <property name="hibernate.cache.use_second_level_cache">false</property> 

수 아무도 응답 : 서비스에 대한 MySQL의 내 연결과 모두 최대 절전 모드 - 사용자 정의 * .XML의 모든 서버에서 다음 C3P0 설정이 내가 뭘 잘못하고있어? 주기적으로 연결이 끊어지는 이유

+0

수영장과 마찬가지로 18 시간 동안 사용되지 않은 (유휴 상태 인) 연결이 반환되었습니다. 'c3p0.timeout'과'c3p0.idle_test_period' 설정은 그것을 막아야합니다. 이 설정이 실제로 구성된대로 사용되는지 확인할 수 있습니까? – vanOekel

+0

Shoud 나는 c3p0.idle_test_period와 함께 connection.url에서 "autoReconnect = true"를 사용합니까? 둘 중 하나만 남겨두면 어떨까요? – user2602807

답변

0

풀에서 빌려온 유효성 검사 쿼리를 사용하여 MySQL이 연결 예외를 종료하지 않도록하십시오.

UPDATE가

당신이 몇 가지 추가 CONFIGS없이 실행되지 않습니다 정의 검증 쿼리,이 충분해야합니다 hibernate.c3p0.validate을 = 사실 hibernate.c3p0.testConnectionOnCheckout 그것은 사실이 보인다 =

+0

어떻게 할 수 있습니까? 기존 설정 hibernate.c3p0.preferredTestQuery = 이미 1을 선택하십시오. 그렇지 않습니까? – user2602807

+0

아하, 나는 몰랐다. 나는 다른 풀을 사용하는데, 실제로 실행되지 않도록 일부 구성이 누락되어 있다고 생각합니다. – MarianP

+0

hibernate.c3p0.validate = true – MarianP