0

我们正在使用 JBoss 版本 7.0.2,其中托管了 6 个以上的 war 文件。在生产环境中,它工作正常,但有时在尝试连接数据库时会抛出异常“通信链路故障”。当异常持续出现时,CPU 负载会自动增加。

数据库- MYSQL,操作系统- UBUNTU。下面发布的是服务器日志、c3p0 配置和 JBoss 配置。

什么时候会抛出这个异常,在什么情况下?

C3p0:-

<entry key="hibernate.max_fetch_depth" value="3"> </entry>
                <entry key="hibernate.hbm2ddl.auto" value="validate"></entry>
                <entry key="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"></entry>
                <entry key="hibernate.connection.url"  value="${hibernate.connection.url}"></entry>  
                <entry key="hibernate.connection.username" value="${hibernate.connection.username}"></entry>  
                <entry key="hibernate.connection.password" value="${hibernate.connection.password}"></entry>
                <entry key="hibernate.show_sql" value="true"></entry>
                <entry key="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup"></entry>
                <entry key="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"></entry>
                <entry key="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"></entry>
                <entry key="hibernate.c3p0.max_size" value="200"></entry>
                <entry key="hibernate.c3p0.min_size" value="10"></entry>
                <entry key="hibernate.c3p0.acquire_increment" value="100"></entry>
                <entry key="hibernate.c3p0.idle_test_period" value="120"></entry>
                <entry key="hibernate.c3p0.max_statements" value="2000"></entry>
                <entry key="hibernate.c3p0.timeout" value="60"></entry>
                <entry key="hibernate.c3p0.validate" value="true"></entry>
                <entry key="hibernate.c3p0.unreturnedConnectionTimeout" value="600"></entry>
                <entry key="hibernate.c3p0.debugUnreturnedConnectionStackTraces" value="true"></entry>

jBoss 配置:-

                    <connection-url>
                        jdbc:mysql://xxxx:3306/xxxx
                    </connection-url>
                    <driver>
                        com.mysql
                    </driver>
                    <transaction-isolation>
                        TRANSACTION_READ_COMMITTED
                    </transaction-isolation>
                    <pool>
                        <min-pool-size>
                            10
                        </min-pool-size>
                        <max-pool-size>
                            100
                        </max-pool-size>
                        <prefill>
                            false
                        </prefill>
                        <use-strict-min>
                            false
                        </use-strict-min>
                        <flush-strategy>
                            FailingConnectionOnly
                        </flush-strategy>
                    </pool>
                    <security>
                        <user-name>
                            xxxxx
                        </user-name>
                        <password>
                            xxxxx
                        </password>
                    </security>
                    <validation>
                        <check-valid-connection-sql>
                            select 1
                        </check-valid-connection-sql>
                        <validate-on-match>
                            true
                        </validate-on-match>
                        <background-validation>
                            false
                        </background-validation>
                        <use-fast-fail>
                            false
                        </use-fast-fail>
                    </validation>
                    <timeout>
                        <blocking-timeout-millis>
                            5000
                        </blocking-timeout-millis>
                        <idle-timeout-minutes>
                            60000
                        </idle-timeout-minutes>
                        <set-tx-query-timeout/>
                    </timeout>
                    <statement>
                        <prepared-statement-cache-size>
                            0
                        </prepared-statement-cache-size>
                    </statement>

服务器日志:-

21:14:02,016 WARNING [org.hibernate.util.JDBCExceptionReporter] (http-xxxx-1.1.1.1-8080-101) **SQL Error: 0, SQLState: 08S01**
21:14:02,017 SEVERE [org.hibernate.util.JDBCExceptionReporter] (http-xxxx-1.1.1.1-8080-101) **Communications link failure**

The last packet successfully received from the server was 63,109 milliseconds ago.  The last packet sent successfully to the server was 63,108 milliseconds ago.
21:14:02,017 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101) org.springframework.dao.DataAccessResourceFailureException: could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query
21:14:02,018 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:631)
21:14:02,018 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
21:14:02,018 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
21:14:02,018 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
21:14:02,019 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:1046)
21:14:02,039 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
21:14:02,039 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
21:14:02,039 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
21:14:02,039 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
21:14:02,040 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
21:14:02,040 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
21:14:02,040 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
21:14:02,041 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139)
21:14:02,041 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)
21:14:02,041 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)
21:14:02,041 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154)
21:14:02,041 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
21:14:02,042 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
21:14:02,042 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
21:14:02,042 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
21:14:02,043 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)
21:14:02,055 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952)
21:14:02,055 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at java.lang.Thread.run(Thread.java:745)
21:14:02,055 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101) Caused by: org.hibernate.exception.JDBCConnectionException: could not execute query
21:14:02,056 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
21:14:02,056 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
21:14:02,056 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.hibernate.loader.Loader.doList(Loader.java:2545)
21:14:02,056 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
21:14:02,057 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.hibernate.loader.Loader.list(Loader.java:2271)
21:14:02,057 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
21:14:02,057 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
21:14:02,057 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
21:14:02,057 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.springframework.orm.hibernate3.HibernateTemplate$36.doInHibernate(HibernateTemplate.java:1056)
21:14:02,058 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.springframework.orm.hibernate3.HibernateTemplate$36.doInHibernate(HibernateTemplate.java:1)
21:14:02,058 ERROR [stderr] (http-xxxx-1.1.1.1-8080-101)   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)   
4

0 回答 0