You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by "gavin lee (JIRA)" <ji...@apache.org> on 2013/02/21 10:22:13 UTC

[jira] [Created] (CLOUDSTACK-1355) Exception when DB upgrade from 4.0.0 to 4.2.0-SNAPSHOT

gavin lee created CLOUDSTACK-1355:
-------------------------------------

             Summary: Exception when DB upgrade  from 4.0.0 to 4.2.0-SNAPSHOT
                 Key: CLOUDSTACK-1355
                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-1355
             Project: CloudStack
          Issue Type: Bug
      Security Level: Public (Anyone can view this level - this is the default.)
          Components: Install and Setup
    Affects Versions: 4.2.0
         Environment: osx 10.8.2
apache-maven-3.0.4
            Reporter: gavin lee
             Fix For: 4.2.0


Build for DevCloud on master, after pull latest code, run jetty will raise below Exception:
bash$ mvn -pl client jetty:run

INFO  [cloud.upgrade.DatabaseUpgradeChecker] (main:) Grabbing lock to check for database upgrade.
INFO  [cloud.upgrade.DatabaseUpgradeChecker] (main:) DB version = 4.0.0 Code Version = 4.2.0-SNAPSHOT
INFO  [cloud.upgrade.DatabaseUpgradeChecker] (main:) Database upgrade must be performed from 4.0.0 to 4.2.0-SNAPSHOT
ERROR [utils.db.ScriptRunner] (main:) Error executing: alter table storage_pool modify id bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL 
ERROR [utils.db.ScriptRunner] (main:) java.sql.SQLException: Cannot change column 'id': used in a foreign key constraint 'fk_storage_pool_details__pool_id' of table 'cloud.storage_pool_details'
ERROR [cloud.upgrade.DatabaseUpgradeChecker] (main:) Unable to execute upgrade script: /Users/gavin_lee/projects/cs-apache/incubator-cloudstack/client/target/utilities/scripts/db/db/schema-40to410.sql
java.sql.SQLException: Cannot change column 'id': used in a foreign key constraint 'fk_storage_pool_details__pool_id' of table 'cloud.storage_pool_details'
	at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:193)
	at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:87)
	at com.cloud.upgrade.DatabaseUpgradeChecker.runScript(DatabaseUpgradeChecker.java:172)
	at com.cloud.upgrade.DatabaseUpgradeChecker.upgrade(DatabaseUpgradeChecker.java:232)
	at com.cloud.upgrade.DatabaseUpgradeChecker.check(DatabaseUpgradeChecker.java:357)
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
	at com.cloud.utils.db.TransactionContextBuilder.AroundAnyMethod(TransactionContextBuilder.java:43)
	at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
	at com.cloud.utils.component.ComponentContext.initComponentsLifeCycle(ComponentContext.java:72)

When apply following work around:
SET foreign_key_checks = 0; 
on top of setup/db/db/schema-40to410.sql
and 
SET foreign_key_checks = 1; 
at bottom of setup/db/db/schema-40to410.sql

Another exception will raise:

INFO  [cloud.upgrade.DatabaseUpgradeChecker] (main:) Grabbing lock to check for database upgrade.
INFO  [cloud.upgrade.DatabaseUpgradeChecker] (main:) DB version = 4.0.0 Code Version = 4.2.0-SNAPSHOT
INFO  [cloud.upgrade.DatabaseUpgradeChecker] (main:) Database upgrade must be performed from 4.0.0 to 4.2.0-SNAPSHOT
ERROR [utils.db.ScriptRunner] (main:) Error executing: alter table vm_template add image_data_store_id bigint unsigned 
ERROR [utils.db.ScriptRunner] (main:) com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'image_data_store_id'
ERROR [cloud.upgrade.DatabaseUpgradeChecker] (main:) Unable to execute upgrade script: /Users/gavin_lee/projects/cs-apache/incubator-cloudstack/client/target/utilities/scripts/db/db/schema-40to410.sql
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'image_data_store_id'
	at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:193)
	at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:87)
	at com.cloud.upgrade.DatabaseUpgradeChecker.runScript(DatabaseUpgradeChecker.java:172)
	at com.cloud.upgrade.DatabaseUpgradeChecker.upgrade(DatabaseUpgradeChecker.java:232)
	at com.cloud.upgrade.DatabaseUpgradeChecker.check(DatabaseUpgradeChecker.java:357)
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
	at com.cloud.utils.db.TransactionContextBuilder.AroundAnyMethod(TransactionContextBuilder.java:43)
	at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira