간단히 말해, 몇 분 동안 트랜잭션을 사용하지 않은 후에 연결을 시도하면 첫 번째 트랜잭션 설정이 실패합니다.Spring 3 DataSourceTransactionManager가 트랜잭션을 MySQL로 가져올 때 간헐적으로 시간이 초과됩니다.
일을 작업 할 때, 내 로그는 간단한 트랜잭션에 대해 다음을 보여
DEBUG: org.springframework.transaction.annotation.AnnotationTransactionAttributeSource - Adding transactional method 'getRecord' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,timeout_30; ''
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Creating new transaction with name [com.example.services.Service.getRecord]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,timeout_30; ''
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Acquired Connection [jdbc:mysql://dev-db.example.com:3306/example, [email protected], MySQL Connector Java] for JDBC transaction
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Switching JDBC Connection [jdbc:mysql://dev-db.example.com:3306/example, [email protected], MySQL Connector Java] to manual commit
을 그러나, 나는 몇 분 동안 어떤 활동을했다하지 않은 경우, 대신 나는이 메시지를 얻을 것이다 :
을DEBUG: org.springframework.transaction.annotation.AnnotationTransactionAttributeSource - Adding transactional method 'getRecord' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,timeout_30; ''
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Creating new transaction with name [com.example.services.Service.getRecord]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,timeout_30; ''
내 관찰 지금까지 :
- 는 활동을 기반으로 보인다, 그러나 나는 바로이 동작을 본 적이 내 Tomcat을 다시 시작한 후에는 데이터베이스에 도달하지 못했지만 MySQL 서버와 같은 네트워크 요소에 대해서는 비활성 상태라고 생각합니다.
- 내 응용 프로그램이 시작될 때 문제가없는 데이터베이스의 비 트랜잭션 요청이 몇 번 발생하여 트랜잭션과 관련이있는 것처럼 보입니다.
- @Transactional 표기법의 timeout 요소는이 경우 유효하지 않습니다. 결국 시간이 초과 된 것으로 보이지만 15 분이 걸립니다 (!).
- 이 트랜잭션 요청이 만료되는 동안, 후속 요청을 성공적으로 만들 수 있습니다.
- 은 굶주린 로컬 연결 풀로 보이지 않습니다. 나는 Tomcat을 다시 시작한 직후 이것을 보았습니다.
이 그것을 밖으로 마지막 시간 (I 15 분을 언급 않았다!) 나는 다음 얻을 :
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Acquired Connection [org.ap[email protected]] for JDBC transaction
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Switching JDBC Connection [connection is closed] to manual commit
DEBUG: org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
DEBUG: org.springframework.jdbc.datasource.DataSourceUtils - Could not close JDBC Connection
ERROR: java.sql.SQLException: Already closed.
ERROR: org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 1,312,604 milliseconds ago. The last packet sent successfully to the server was 924,748 milliseconds ago.
Caused by: java.net.SocketException: Connection timed out
실행 봄 3.1.1, MySQL은 5.1.32, 1.4 DBCP 공유지-및 공유지 풀 1.5.4.
누구인지 알고 계십니까?
여기에 ApplicationContext.xml을 입력하십시오. – Killer