Ask Your Question
2

trouble migrating keystone database from juno to mitaka

asked 2016-04-17 21:49:35 -0500

don gravatar image

updated 2016-04-17 22:01:51 -0500

I have a juno installation of keystone (schema ver 55) and am trying to migrate to mitaka. if i run keystone-manage db_sync on mitaka, it fails with:

KeyError: <VerNum(56)>

OK, so lets try a migration to liberty first. That succeeds without error. Now lets try mitaka again.

2016-04-18 02:39:43.258 2860 ERROR keystone DBError: (_mysql_exceptions.IntegrityError) (1215, 'Cannot add foreign key constraint') [SQL: u'\nCREATE TABLE local_user (\n\tid INTEGER NOT NULL AUTO_INCREMENT, \n\tuser_id VARCHAR(64) NOT NULL, \n\tdomain_id VARCHAR(64) NOT NULL, \n\tname VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (id), \n\tUNIQUE (domain_id, name), \n\tUNIQUE (user_id), \n\tFOREIGN KEY(user_id) REFERENCES user (id) ON DELETE CASCADE\n)\n\n']

ok, why is that?

if i run 'show engine innodb status' i get:

2016-04-17 23:09:32 7f2cd4aed700 Error in foreign key constraint of table keystone/local_user:
FOREIGN KEY(user_id) REFERENCES user (id) ON DELETE CASCADE ):
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.
Note that the internal storage type of ENUM and SET changed in
tables created with >= InnoDB-4.1.12, and such columns in old tables
cannot be referenced by such columns in new tables.
See http://dev.mysql.com/doc/refman/5.6/en/innodb-foreign-key-constraints.html
for correct foreign key definition.

so it is complaining about the foreign key in the local_user table its trying to create.

if i look @ user:

mysql> describe user;
+--------------------+--------------+------+-----+---------+-------+
| Field              | Type         | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+-------+
| id                 | varchar(64)  | NO   | PRI | NULL    |       |
| name               | varchar(255) | NO   |     | NULL    |       |
| extra              | text         | YES  |     | NULL    |       |
| password           | varchar(128) | YES  |     | NULL    |       |
| enabled            | tinyint(1)   | YES  |     | NULL    |       |
| domain_id          | varchar(64)  | NO   | MUL | NULL    |       |
| default_project_id | varchar(64)  | YES  |     | NULL    |       |
+--------------------+--------------+------+-----+---------+-------+
7 rows in set (0.00 sec)
mysql> show index from user;                                                                                                                                                                                                    +-------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name  | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| user  |          0 | PRIMARY   |            1 | id          | A         |        1055 |     NULL | NULL   |      | BTREE      |         |               |
| user  |          0 | domain_id |            1 | domain_id   | A         |           4 |     NULL | NULL   |      | BTREE      |         |               |
| user  |          0 | domain_id |            2 | name        | A         |        1055 |     NULL | NULL   |      | BTREE      |         |               |
+-------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
3 rows in set (0.00 sec)

so, uh, any suggestions? its the 89-90 step that fails

edit retag flag offensive close merge delete

Comments

Failing on this one: https://github.com/openstack/keystone/blame/stable/mitaka/keystone/common/sql/migrate_repo/versions/090_add_local_user_and_password_tables.py (https://github.com/openstack/keystone...)

fiorix gravatar imagefiorix ( 2016-04-18 13:37:47 -0500 )edit

When I comment out the ForeignKey constraint from the file above, it migrates well but then breaks again at 90->91 due to not being able to drop ixu_user_name_domain_id.

fiorix gravatar imagefiorix ( 2016-04-18 14:23:06 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-04-19 22:59:25 -0500

don gravatar image

OK in case someone else hits this. despite my connect line having charset=utf8, i needed to do an alter database before the upgrade:

alter database keystone DEFAULT CHARACTER SET utf8;
alter database keystone DEFAULT COLLATE utf8_general_ci;

and then the upgrade worked provided i did juno->liberty, and then liberty->mitaka. its not possible to do juno->mitaka intact. But the alter database commands allowed the varchar(id) and varchar(user_id) to match.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2016-04-17 21:49:35 -0500

Seen: 818 times

Last updated: Apr 19 '16