MySQLNonTransientConnectionException:commit()期间的通信链接失败。未知交易决议

时间:2015-09-02 09:35:18

标签: mysql svn jdbc ant sonarqube

每当我在Hudson中构建一个作业时,在尝试将结果存储在数据库中时,它总是在最后失败。整个工作通常需要大约一个小时才能建立并失败。

源文件存储在SVN服务器上,可以在本地下载和编辑。一旦我验证作业能够在本地成功构建,我就会对SVN进行任何更改。

我最近改用了基于ANT的方法,该方法将蚂蚁目标与对象审核者进行对齐。所以我创建了一个sonar.xml文件,其中包含一个名为sonar_scan的目标,该目标在项目的build.xml文件中调用。

我已将net_read_timeout,net_write_timeout和innodb_lock_wait_timeout设置为10分钟,而不是默认值60秒或更短。 wait_timeout设置为8小时,所以我知道wait_timeout不是问题。

  • 我使用的数据库是mysql版本5.6.25
  • 我正在使用的Sonar版本是5.1

我收到的完整错误消息是:

[sonar:sonar] 19:09:43.831 ERROR - JDBC commit failed    
[sonar:sonar] com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during commit(). Transaction resolution unknown.
    [sonar:sonar]   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_45]
    [sonar:sonar]   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_45]
    [sonar:sonar]   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_45]
    [sonar:sonar]   at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_45]
    [sonar:sonar]   at com.mysql.jdbc.Util.handleNewInstance(Util.java:377) ~[mysql-connector-java-5.1.34.jar:5.1.34]
    [sonar:sonar]   at com.mysql.jdbc.Util.getInstance(Util.java:360) ~[mysql-connector-java-5.1.34.jar:5.1.34]
    [sonar:sonar]   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) ~[mysql-connector-java-5.1.34.jar:5.1.34]
    [sonar:sonar]   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935) ~[mysql-connector-java-5.1.34.jar:5.1.34]
    [sonar:sonar]   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924) ~[mysql-connector-java-5.1.34.jar:5.1.34]
    [sonar:sonar]   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870) ~[mysql-connector-java-5.1.34.jar:5.1.34]
    [sonar:sonar]   at com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.java:1611) ~[mysql-connector-java-5.1.34.jar:5.1.34]
    [sonar:sonar]   at org.apache.commons.dbcp.DelegatingConnection.commit(DelegatingConnection.java:334) ~[sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.commit(PoolingDataSource.java:211) ~[sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:170) ~[sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:146) ~[sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.sonar.jpa.session.JpaDatabaseSession.commit(JpaDatabaseSession.java:83) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.sonar.jpa.session.JpaDatabaseSession.commitAndClose(JpaDatabaseSession.java:69) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.sonar.jpa.session.JpaDatabaseSession.stop(JpaDatabaseSession.java:64) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_45]
    [sonar:sonar]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_45]
    [sonar:sonar]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_45]
    [sonar:sonar]   at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_45]
    [sonar:sonar]   at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.stop(ReflectionLifecycleStrategy.java:96) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.stop(AbstractInjectionFactory.java:88) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.picocontainer.behaviors.AbstractBehavior.stop(AbstractBehavior.java:179) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.picocontainer.behaviors.Stored$RealComponentLifecycle.stop(Stored.java:141) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.picocontainer.behaviors.Stored.stop(Stored.java:118) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.picocontainer.DefaultPicoContainer.stopAdapters(DefaultPicoContainer.java:1047) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.picocontainer.DefaultPicoContainer.stop(DefaultPicoContainer.java:802) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.sonar.api.platform.ComponentContainer.stopComponents(ComponentContainer.java:123) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.sonar.api.platform.ComponentContainer.stopComponents(ComponentContainer.java:118) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.sonar.batch.bootstrapper.Batch.stop(Batch.java:107) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67) [sonar-batch-maven-compat-5.1.jar:na]
    [sonar:sonar]   at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48) [sonar-runner-batch1253226961910621726.jar:na]
    [sonar:sonar]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_45]
    [sonar:sonar]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_45]
    [sonar:sonar]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_45]
    [sonar:sonar]   at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_45]
    [sonar:sonar]   at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87) [sonar-ant-task-2.3.jar:na]
    [sonar:sonar]   at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) [sonar-ant-task-2.3.jar:na]
    [sonar:sonar]   at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_45]
    [sonar:sonar]   at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) [sonar-ant-task-2.3.jar:na]
    [sonar:sonar]   at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) [sonar-ant-task-2.3.jar:na]
    [sonar:sonar]   at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) [sonar-ant-task-2.3.jar:na]
    [sonar:sonar]   at org.sonar.runner.api.Runner.execute(Runner.java:100) [sonar-ant-task-2.3.jar:na]
    [sonar:sonar]   at org.sonar.ant.SonarTask.launchAnalysis(SonarTask.java:51) [sonar-ant-task-2.3.jar:na]
    [sonar:sonar]   at org.sonar.ant.SonarTask.execute(SonarTask.java:46) [sonar-ant-task-2.3.jar:na]
    [sonar:sonar]   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) [ant.jar:1.9.2]
    [sonar:sonar]   at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) ~[na:na]
    [sonar:sonar]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_45]
    [sonar:sonar]   at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_45]
    [sonar:sonar]   at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) [ant.jar:na]
    [sonar:sonar]   at org.apache.tools.ant.Task.perform(Task.java:348) [ant.jar:1.9.2]
    [sonar:sonar]   at org.apache.tools.ant.Target.execute(Target.java:435) [ant.jar:1.9.2]
    [sonar:sonar]   at org.apache.tools.ant.Target.performTasks(Target.java:456) [ant.jar:1.9.2]
    [sonar:sonar]   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393) [ant.jar:1.9.2]
    [sonar:sonar]   at org.apache.tools.ant.Project.executeTarget(Project.java:1364) [ant.jar:1.9.2]
    [sonar:sonar]   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) [ant.jar:na]
    [sonar:sonar]   at org.apache.tools.ant.Project.executeTargets(Project.java:1248) [ant.jar:1.9.2]
    [sonar:sonar]   at org.apache.tools.ant.Main.runBuild(Main.java:851) [ant.jar:1.9.2]
    [sonar:sonar]   at org.apache.tools.ant.Main.startAnt(Main.java:235) [ant.jar:1.9.2]
    [sonar:sonar]   at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) [ant-launcher.jar:na]
    [sonar:sonar]   at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) [ant-launcher.jar:na]
    [sonar:sonar] 19:09:43.831 WARN  - SQL Error: 0, SQLState: null
    [sonar:sonar] 19:09:43.831 ERROR - Already closed.

    BUILD FAILED
    D:\SVN_7_1\buildscripts\sonar.xml:168: org.sonar.runner.impl.RunnerException: Unable to execute Sonar
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.sonar.ant.SonarTask.launchAnalysis(SonarTask.java:51)
        at org.sonar.ant.SonarTask.execute(SonarTask.java:46)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:435)
        at org.apache.tools.ant.Target.performTasks(Target.java:456)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
        at org.apache.tools.ant.Main.runBuild(Main.java:851)
        at org.apache.tools.ant.Main.startAnt(Main.java:235)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
    Caused by: org.hibernate.exception.GenericJDBCException: Cannot release connection
        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
        at org.hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:478)
        at org.hibernate.jdbc.ConnectionManager.aggressiveRelease(ConnectionManager.java:429)
        at org.hibernate.jdbc.ConnectionManager.afterTransaction(ConnectionManager.java:316)
        at org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(JDBCContext.java:248)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:158)
        at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
        at org.sonar.jpa.session.JpaDatabaseSession.commit(JpaDatabaseSession.java:83)
        at org.sonar.jpa.session.JpaDatabaseSession.commitAndClose(JpaDatabaseSession.java:69)
        at org.sonar.jpa.session.JpaDatabaseSession.stop(JpaDatabaseSession.java:64)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.stop(ReflectionLifecycleStrategy.java:96)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.stop(AbstractInjectionFactory.java:88)
        at org.picocontainer.behaviors.AbstractBehavior.stop(AbstractBehavior.java:179)
        at org.picocontainer.behaviors.Stored$RealComponentLifecycle.stop(Stored.java:141)
        at org.picocontainer.behaviors.Stored.stop(Stored.java:118)
        at org.picocontainer.DefaultPicoContainer.stopAdapters(DefaultPicoContainer.java:1047)
        at org.picocontainer.DefaultPicoContainer.stop(DefaultPicoContainer.java:802)
        at org.sonar.api.platform.ComponentContainer.stopComponents(ComponentContainer.java:123)
        at org.sonar.api.platform.ComponentContainer.stopComponents(ComponentContainer.java:118)
        at org.sonar.batch.bootstrapper.Batch.stop(Batch.java:107)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
        ... 24 more
    Caused by: java.sql.SQLException: Already closed.
        at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:114)
        at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191)
        at org.hibernate.connection.DatasourceConnectionProvider.closeConnection(DatasourceConnectionProvider.java:97)
        at org.hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:474)
        ... 54 more

    Total time: 42 minutes 5 seconds

我到处寻找可能的解决方案,到目前为止我还没找到。如果有人可以提出我尚未做过的事情那么我会非常感激。

1 个答案:

答案 0 :(得分:2)

网络不稳定

重新出现代码:

true