我正在尝试使用两个tomcat在集群中运行我的应用程序,当同时启动两个tomcat时,一个tomcat上的迁移失败。我的弹簧配置是 -
<bean id="flyway" class="com.googlecode.flyway.core.Flyway" init-method="migrate">
<property name="dataSource" ref="dataSource"/>
<property name="initOnMigrate" value="true" />
</bean>
我还将innodb_lock_wait_timeout增加到900,mysql版本是5.6.15
请帮我这个,日志是 -
org.springframework.beans.factory.BeanCreationException:创建名为&#39; flyway&#39;的bean时出错在类路径资源[spring / db.xml]中定义:init方法的调用失败;嵌套异常是com.googlecode.flyway.core.api.FlywayException:无法为版本&#39; 1&#39;插入行。在元数据表connect_dev
中。schema_version
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1554)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
在org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:302)
在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
在org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:975)
在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:752)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
在org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4937)
在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
在org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1120)
在org.apache.catalina.startup.HostConfig $ DeployDirectory.run(HostConfig.java:1678)
at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
在java.lang.Thread.run(Thread.java:745)
引起:com.googlecode.flyway.core.api.FlywayException:无法为版本&#39; 1&#39;插入行在元数据表connect_dev
中。schema_version
在com.googlecode.flyway.core.metadatatable.MetaDataTableImpl.addAppliedMigration(MetaDataTableImpl.java:158)
在com.googlecode.flyway.core.metadatatable.MetaDataTableImpl.addInitMarker(MetaDataTableImpl.java:280)
在com.googlecode.flyway.core.command.DbInit $ 1.doInTransaction(DbInit.java:95)
在com.googlecode.flyway.core.command.DbInit $ 1.doInTransaction(DbInit.java:74)
在com.googlecode.flyway.core.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72)
在com.googlecode.flyway.core.command.DbInit.init(DbInit.java:74)
在com.googlecode.flyway.core.Flyway $ 1.execute(Flyway.java:841)
在com.googlecode.flyway.core.Flyway $ 1.execute(Flyway.java:819)
在com.googlecode.flyway.core.Flyway.execute(Flyway.java:1200)
在com.googlecode.flyway.core.Flyway.migrate(Flyway.java:819)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java:483)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1682)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1621)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1550)
......还有27个
引起:com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException:尝试获取锁定时发现死锁;尝试重新启动事务
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
在com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
在com.mysql.jdbc.Util.getInstance(Util.java:381)
在com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1045)
在com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
在com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
在com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
在com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
在com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
在com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019)
在com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937)
在com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922)
答案 0 :(得分:0)
在Spring数据源中配置maxWait值,看看是否正在改变这种情况。