failed nova db migration upgrading from grizzly to havana
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Won't Fix
|
Wishlist
|
Tiantian Gao | ||
Ubuntu Cloud Archive |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
I recently upgraded a Nova cluster from grizzly to havana. We're using the Ubuntu Cloud Archive and so in terms of package versions the upgrade was from 1:2013.
After the upgrade, "nova-manage db sync" failed as follows:
# nova-manage db sync
2013-10-13 21:08:54.132 26592 INFO migrate.
2013-10-13 21:08:54.138 26592 INFO migrate.
2013-10-13 21:08:54.140 26592 INFO migrate.
2013-10-13 21:08:54.145 26592 INFO migrate.
2013-10-13 21:08:54.146 26592 INFO migrate.
2013-10-13 21:08:54.154 26592 INFO migrate.
2013-10-13 21:08:54.154 26592 INFO migrate.
2013-10-13 21:08:54.162 26592 INFO migrate.
2013-10-13 21:08:54.162 26592 INFO migrate.
2013-10-13 21:08:54.167 26592 INFO migrate.
2013-10-13 21:08:54.170 26592 INFO migrate.
2013-10-13 21:08:54.175 26592 INFO migrate.
2013-10-13 21:08:54.176 26592 INFO migrate.
2013-10-13 21:08:54.184 26592 INFO migrate.
2013-10-13 21:08:54.184 26592 INFO migrate.
2013-10-13 21:08:54.189 26592 INFO migrate.
2013-10-13 21:08:54.189 26592 INFO migrate.
2013-10-13 21:08:54.199 26592 INFO migrate.
2013-10-13 21:08:54.199 26592 INFO migrate.
2013-10-13 21:08:54.204 26592 INFO migrate.
2013-10-13 21:08:54.205 26592 INFO migrate.
2013-10-13 21:08:54.841 26592 INFO migrate.
2013-10-13 21:08:54.842 26592 INFO migrate.
2013-10-13 21:08:54.883 26592 INFO nova.db.
2013-10-13 21:08:54.888 26592 INFO nova.db.
2013-10-13 21:08:54.889 26592 INFO nova.db.
2013-10-13 21:08:54.897 26592 INFO nova.db.
2013-10-13 21:08:54.905 26592 INFO nova.db.
2013-10-13 21:08:54.911 26592 INFO nova.db.
2013-10-13 21:08:54.911 26592 INFO nova.db.
2013-10-13 21:08:54.923 26592 INFO nova.db.
2013-10-13 21:08:54.928 26592 INFO nova.db.
2013-10-13 21:08:54.934 26592 INFO nova.db.
2013-10-13 21:08:54.946 26592 INFO nova.db.
2013-10-13 21:08:54.951 26592 INFO nova.db.
2013-10-13 21:08:54.991 26592 INFO migrate.
2013-10-13 21:08:54.991 26592 INFO migrate.
2013-10-13 21:08:55.052 26592 INFO migrate.
2013-10-13 21:08:55.053 26592 INFO migrate.
2013-10-13 21:08:55.146 26592 INFO migrate.
2013-10-13 21:08:55.147 26592 INFO migrate.
2013-10-13 21:08:55.171 26592 INFO migrate.
2013-10-13 21:08:55.172 26592 INFO migrate.
2013-10-13 21:08:55.236 26592 INFO migrate.
2013-10-13 21:08:55.237 26592 INFO migrate.
2013-10-13 21:08:55.635 26592 INFO migrate.
2013-10-13 21:08:55.636 26592 INFO migrate.
2013-10-13 21:08:55.692 26592 INFO migrate.
2013-10-13 21:08:55.692 26592 INFO migrate.
2013-10-13 21:08:55.734 26592 INFO migrate.
2013-10-13 21:08:55.734 26592 INFO migrate.
2013-10-13 21:08:55.786 26592 INFO migrate.
2013-10-13 21:08:55.786 26592 INFO migrate.
2013-10-13 21:08:55.829 26592 INFO migrate.
2013-10-13 21:08:55.830 26592 INFO migrate.
2013-10-13 21:08:55.872 26592 INFO migrate.
2013-10-13 21:08:55.874 26592 INFO migrate.
2013-10-13 21:08:56.092 26592 INFO migrate.
2013-10-13 21:08:56.093 26592 INFO migrate.
Command failed, please check log for more info
2013-10-13 21:09:00.315 26592 CRITICAL nova [-] (OperationalError) (1553, "Cannot drop index 'uniq_instance_
2013-10-13 21:09:00.315 26592 TRACE nova Traceback (most recent call last):
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/bin/
2013-10-13 21:09:00.315 26592 TRACE nova sys.exit(main())
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova ret = fn(*fn_args, **fn_kwargs)
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova return migration.
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova return IMPL.db_
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova return versioning_
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova return _migrate(url, repository, version, upgrade=True, err=err, **opts)
2013-10-13 21:09:00.315 26592 TRACE nova File "<string>", line 2, in _migrate
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova return f(*a, **kw)
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova schema.
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova change.
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova script_func(engine)
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova return _uc_rename(
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova old_name, *(columns))
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova uc.drop()
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova self.__
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova run_single_
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova fn(element, **kwargs)
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova self._visit_
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova self.execute()
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova return self.connection
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova params)
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova statement, parameters
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova context)
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova exc_info
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova reraise(
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova context)
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova cursor.
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova self.errorhandl
2013-10-13 21:09:00.315 26592 TRACE nova File "/usr/lib/
2013-10-13 21:09:00.315 26592 TRACE nova raise errorclass, errorvalue
2013-10-13 21:09:00.315 26592 TRACE nova OperationalError: (OperationalError) (1553, "Cannot drop index 'uniq_instance_
2013-10-13 21:09:00.315 26592 TRACE nova
After some investigation I decided to fix it as follows:
mysql> show create table instance_
+------
| Table | Create Table |
+------
| instance_
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`instance_
`project_id` varchar(255) DEFAULT NULL,
`deleted` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_instance_
CONSTRAINT `instance_
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+------
1 row in set (0.00 sec)
mysql> alter table instance_
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table instance_
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table instance_
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table instance_
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table instance_
+------
| Table | Create Table |
+------
| instance_
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`instance_
`project_id` varchar(255) DEFAULT NULL,
`deleted` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_instance_
CONSTRAINT `instance_
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+------
1 row in set (0.00 sec)
I checked that the rest of 185 was applied, bumped the version in the DB to 185, and a second run of "nova-manage db sync" completed without incident.
tags: | added: canonistack |
description: | updated |
tags: | added: havana-rc-potential |
Changed in nova: | |
assignee: | nobody → Roman Podolyaka (rpodolyaka) |
status: | New → Confirmed |
Changed in nova: | |
status: | Confirmed → Incomplete |
tags: |
added: havana-backport-potential removed: havana-rc-potential |
Changed in nova: | |
status: | Incomplete → Confirmed |
tags: | added: db |
Changed in nova: | |
importance: | Undecided → High |
Changed in nova: | |
assignee: | Roman Podoliaka (rpodolyaka) → Tiantian Gao (gtt116) |
Changed in nova: | |
status: | Confirmed → In Progress |
no longer affects: | nova/icehouse |
Ok, so this is odd, but known behavior of MySQL.
Let's consider the following example:
mysql> create table testtbl (a integer primary key);
Query OK, 0 rows affected (0.09 sec)
mysql> create table testtbl2 (a integer primary key, b varchar(36), c integer, foreign key test_fk (c) references testtbl (a));
Query OK, 0 rows affected (0.09 sec)
mysql> alter table testtbl2 add constraint unique test_unique (c, b);
Query OK, 0 rows affected (0.15 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table testtbl2;
| testtbl2 | CREATE TABLE `testtbl2` (
`a` int(11) NOT NULL,
`b` varchar(36) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `test_idx` (`c`),
CONSTRAINT `testtbl2_ibfk_1` FOREIGN KEY (`c`) REFERENCES `testtbl` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
1 row in set (0.00 sec)
mysql> alter table testtbl2 drop index test_unique;
ERROR 1553 (HY000): Cannot drop index 'test_unique': needed in a foreign key constraint
so if we want to drop the UC, we have to drop the FK first, then drop the UC, and finally recreate the FK.
But:
mysql> create index test_idx on testtbl2 (c);
Query OK, 0 rows affected (0.13 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table testtbl2 drop index test_unique;
Query OK, 0 rows affected (0.07 sec)
Records: 0 Duplicates: 0 Warnings: 0
Returning to our problem. The reporter shown his definition of 'instance_ type_projects' table with migration 184 applied:
CREATE TABLE `instance_ type_projects` ( type_id` int(11) NOT NULL, type_id_ x_project_ id_x_deleted` (`instance_ type_id` ,`project_ id`,`deleted` ), type_projects_ ibfk_1` FOREIGN KEY (`instance_ type_id` ) REFERENCES `instance_types` (`id`)
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`instance_
`project_id` varchar(255) DEFAULT NULL,
`deleted` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_instance_
CONSTRAINT `instance_
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
At the same time applying of all migrations from 133 (initial one) to 184 gives me the following definition:
CREATE TABLE `instance_ type_projects` ( type_id` int(11) NOT NULL, type_id_ x_project_ id_x_deleted` (`instance_ type_id` ,`project_ id`,`deleted` ), type_id` ), type_projects_ ibfk_1` FOREIGN KEY (`instance_ type_id` ) REFERENCES `instance_types` (`id`)
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`instance_
`project_id` varchar(255) DEFAULT NULL,
`deleted` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_instance_
KEY `instance_type_id` (`instance_
CONSTRAINT `instance_
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
So, for some reason the reporter doesn't have index on column 'instance_type_id' ( KEY `instance_type_id` (`instance_ type_id` )). This explains the fact, that our migrations tests pass. That index is created in the initial migration (133_folsom.py) and doesn't see m to be modified anywhere.
Could you please give us more information on your setup? Have you modified you DB schema manually (created...