Potential bug with CS 4.1.1 to 4.2.1 db upgrade
Hello, Yesterday, I've upgraded a CloudStack 4.1.1 installation to CloudStack 4.2.1, I've received this error when I started the management service the first time after upgrade (below). To fix it, I've changed this line in schema-410to420.sql CREATE TABLE `cloud`.`vm_snapshots` ( to CREATE TABLE IF NOT EXISTS `cloud`.`vm_snapshots` ( And I've restored the cloud db backup from the mysql dump executed just before upgrade, and (re-)start the management service. All is good after. I've open this ticket on Jira https://issues.apache.org/jira/browse/CLOUDSTACK-5214 Please confirm that is a bug (or not). Milamber = 2013-11-20 00:12:31,057 INFO [utils.component.ComponentContext] (Timer-1:null) Running SystemIntegrityChecker managementServerNode 2013-11-20 00:12:31,057 INFO [utils.component.ComponentContext] (Timer-1:null) Running SystemIntegrityChecker databaseUpgradeChecker 2013-11-20 00:12:31,057 INFO [cloud.upgrade.DatabaseUpgradeChecker] (Timer-1:null) Grabbing lock to check for database upgrade. 2013-11-20 00:12:31,059 DEBUG [upgrade.dao.VersionDaoImpl] (Timer-1:null) Checking to see if the database is at a version before it was the version table is created 2013-11-20 00:12:31,063 INFO [cloud.upgrade.DatabaseUpgradeChecker] (Timer-1:null) DB version = 4.1.1 Code Version = 4.2.1-SNAPSHOT 2013-11-20 00:12:31,063 INFO [cloud.upgrade.DatabaseUpgradeChecker] (Timer-1:null) Database upgrade must be performed from 4.1.1 to 4.2.1-SNAPSHOT 2013-11-20 00:12:31,064 DEBUG [cloud.upgrade.DatabaseUpgradeChecker] (Timer-1:null) Running upgrade Upgrade410to420 to upgrade from 4.1.0-4.1.1 to 4.2.0 2013-11-20 00:12:31,069 DEBUG [utils.script.Script] (Timer-1:null) Looking for db/schema-410to420.sql in the classpath 2013-11-20 00:12:31,069 DEBUG [utils.script.Script] (Timer-1:null) System resource: file:/usr/share/cloudstack-management/setup/db/schema-410to420.sql 2013-11-20 00:12:31,069 DEBUG [utils.script.Script] (Timer-1:null) Absolute path = /usr/share/cloudstack-management/setup/db/schema-410to420.sql [] 2013-11-20 00:12:32,546 ERROR [utils.db.ScriptRunner] (Timer-1:null) Error executing: CREATE TABLE `cloud`.`vm_snapshots` ( `id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Primary Key', `uuid` varchar(40) NOT NULL, `name` varchar(255) NOT NULL, `display_name` varchar(255) default NULL, `description` varchar(255) default NULL, `vm_id` bigint(20) unsigned NOT NULL, `account_id` bigint(20) unsigned NOT NULL, `domain_id` bigint(20) unsigned NOT NULL, `vm_snapshot_type` varchar(32) default NULL, `state` varchar(32) NOT NULL, `parent` bigint unsigned default NULL, `current` int(1) unsigned default NULL, `update_count` bigint unsigned NOT NULL DEFAULT 0, `updated` datetime default NULL, `created` datetime default NULL, `removed` datetime default NULL, PRIMARY KEY (`id`), CONSTRAINT UNIQUE KEY `uc_vm_snapshots_uuid` (`uuid`), INDEX `vm_snapshots_name` (`name`), INDEX `vm_snapshots_vm_id` (`vm_id`), INDEX `vm_snapshots_account_id` (`account_id`), INDEX `vm_snapshots_display_name` (`display_name`), INDEX `vm_snapshots_removed` (`removed`), INDEX `vm_snapshots_parent` (`parent`), CONSTRAINT `fk_vm_snapshots_vm_id__vm_instance_id` FOREIGN KEY `fk_vm_snapshots_vm_id__vm_instance_id` (`vm_id`) REFERENCES `vm_instance` (`id`), CONSTRAINT `fk_vm_snapshots_account_id__account_id` FOREIGN KEY `fk_vm_snapshots_account_id__account_id` (`account_id`) REFERENCES `account` (`id`), CONSTRAINT `fk_vm_snapshots_domain_id__domain_id` FOREIGN KEY `fk_vm_snapshots_domain_id__domain_id` (`domain_id`) REFERENCES `domain` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 2013-11-20 00:12:32,546 ERROR [utils.db.ScriptRunner] (Timer-1:null) com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'vm_snapshots' already exists 2013-11-20 00:12:32,549 ERROR [cloud.upgrade.DatabaseUpgradeChecker] (Timer-1:null) Unable to execute upgrade script: /usr/share/cloudstack-management/setup/db/schema-410to420.sql com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'vm_snapshots' already exists 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:204) at com.cloud.upgrade.DatabaseUpgradeChecker.upgrade(DatabaseUpgradeChecker.java:265) at com.cloud.upgrade.DatabaseUpgradeChecker.check(DatabaseUpgradeChecker.java:394) at com.cloud.utils.component.ComponentContext.initComponentsLifeCycle(ComponentContext.java:90) at com.cloud.servlet.CloudStartupServlet$1.run(CloudStartupServlet.java:54) at java.util.TimerThread.mainLoop(Timer.java:534) at java.util.TimerThread.run(Timer.java:484) 2013-11-20 00:12:32,552 ERROR [cloud.upgrade.DatabaseUpgradeChecker] (Timer-1:null) Unable to upgrade the database com.cloud.utils.exception.C
RE: Potential bug with CS 4.1.1 to 4.2.1 db upgrade
This statement if fairly safe IMHO. We just catch a corner case if table does not exists. It warrants a fix. > -Original Message- > From: Milamber [mailto:milam...@apache.org] > Sent: Wednesday, November 20, 2013 3:37 AM > To: dev@cloudstack.apache.org > Subject: Potential bug with CS 4.1.1 to 4.2.1 db upgrade > > Hello, > > Yesterday, I've upgraded a CloudStack 4.1.1 installation to CloudStack 4.2.1, > I've received this error when I started the management service the first time > after upgrade (below). > > To fix it, I've changed this line in schema-410to420.sql CREATE TABLE > `cloud`.`vm_snapshots` ( to CREATE TABLE IF NOT EXISTS > `cloud`.`vm_snapshots` ( > > > And I've restored the cloud db backup from the mysql dump executed just > before upgrade, and (re-)start the management service. > All is good after. > > I've open this ticket on Jira > https://issues.apache.org/jira/browse/CLOUDSTACK-5214 > > Please confirm that is a bug (or not). > > Milamber > > > = > 2013-11-20 00:12:31,057 INFO [utils.component.ComponentContext] > (Timer-1:null) Running SystemIntegrityChecker managementServerNode > 2013-11-20 00:12:31,057 INFO [utils.component.ComponentContext] > (Timer-1:null) Running SystemIntegrityChecker databaseUpgradeChecker > 2013-11-20 00:12:31,057 INFO [cloud.upgrade.DatabaseUpgradeChecker] > (Timer-1:null) Grabbing lock to check for database upgrade. > 2013-11-20 00:12:31,059 DEBUG [upgrade.dao.VersionDaoImpl] > (Timer-1:null) Checking to see if the database is at a version before it was > the > version table is created > 2013-11-20 00:12:31,063 INFO [cloud.upgrade.DatabaseUpgradeChecker] > (Timer-1:null) DB version = 4.1.1 Code Version = 4.2.1-SNAPSHOT > 2013-11-20 00:12:31,063 INFO [cloud.upgrade.DatabaseUpgradeChecker] > (Timer-1:null) Database upgrade must be performed from 4.1.1 to 4.2.1- > SNAPSHOT > 2013-11-20 00:12:31,064 DEBUG [cloud.upgrade.DatabaseUpgradeChecker] > (Timer-1:null) Running upgrade Upgrade410to420 to upgrade from > 4.1.0-4.1.1 to 4.2.0 > 2013-11-20 00:12:31,069 DEBUG [utils.script.Script] (Timer-1:null) Looking for > db/schema-410to420.sql in the classpath > 2013-11-20 00:12:31,069 DEBUG [utils.script.Script] (Timer-1:null) System > resource: > file:/usr/share/cloudstack-management/setup/db/schema-410to420.sql > 2013-11-20 00:12:31,069 DEBUG [utils.script.Script] (Timer-1:null) Absolute > path = /usr/share/cloudstack-management/setup/db/schema-410to420.sql > [] > 2013-11-20 00:12:32,546 ERROR [utils.db.ScriptRunner] (Timer-1:null) > Error executing: CREATE TABLE `cloud`.`vm_snapshots` ( `id` bigint(20) > unsigned NOT NULL auto_increment COMMENT 'Primary Key', `uuid` > varchar(40) NOT NULL, `name` varchar(255) NOT NULL, `display_name` > varchar(255) default NULL, `description` varchar(255) default NULL, > `vm_id` bigint(20) unsigned NOT NULL, `account_id` bigint(20) unsigned > NOT NULL, `domain_id` bigint(20) unsigned NOT NULL, > `vm_snapshot_type` varchar(32) default NULL, `state` varchar(32) NOT > NULL, `parent` bigint unsigned default NULL, `current` int(1) > unsigned default NULL, `update_count` bigint unsigned NOT NULL DEFAULT > 0, `updated` datetime default NULL, `created` datetime default > NULL, `removed` datetime default NULL, PRIMARY KEY (`id`), > CONSTRAINT UNIQUE KEY `uc_vm_snapshots_uuid` (`uuid`), INDEX > `vm_snapshots_name` (`name`), INDEX `vm_snapshots_vm_id` (`vm_id`), > INDEX `vm_snapshots_account_id` (`account_id`), INDEX > `vm_snapshots_display_name` (`display_name`), INDEX > `vm_snapshots_removed` (`removed`), INDEX `vm_snapshots_parent` > (`parent`), CONSTRAINT `fk_vm_snapshots_vm_id__vm_instance_id` > FOREIGN > KEY `fk_vm_snapshots_vm_id__vm_instance_id` (`vm_id`) REFERENCES > `vm_instance` (`id`), CONSTRAINT > `fk_vm_snapshots_account_id__account_id` FOREIGN KEY > `fk_vm_snapshots_account_id__account_id` (`account_id`) REFERENCES > `account` (`id`), CONSTRAINT `fk_vm_snapshots_domain_id__domain_id` > FOREIGN KEY `fk_vm_snapshots_domain_id__domain_id` (`domain_id`) > REFERENCES `domain` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 > 2013-11-20 00:12:32,546 ERROR [utils.db.ScriptRunner] (Timer-1:null) > com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table > 'vm_snapshots' already exists > 2013-11-20 00:12:32,549 ERROR [cloud.upgrade.DatabaseUpgradeChecker] > (Timer-1:null) Unable to execute upgrade script: > /usr/share/cloudstack-management/setup/db/schema-410to420.sql > com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table > 'vm_snapshots' already exists > at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:193)