31 to 32 and 38 to 39 db upgrade fail due to foreign key error

Bug #1455726 reported by UltimateDogg
22
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Cinder
Invalid
Undecided
UltimateDogg

Bug Description

This is on a centos 7, kernel 3.10.0-229.4.2.el7.x86_64, openstack juno via rdo project and now migrating to openstack kilo.
I belive the issue is the same as https://bugs.launchpad.net/cinder/+bug/1240189 since i manually added DEFAULT CHARSET=utf8 and ran the sql and it worked. This should be what mysql_charset='utf8' in cinder\db\sqlalchemy\migrate_repo\versions\040_add_volume_attachment.py would do.

[root@danstack versions]# cinder-manage db sync
/usr/lib/python2.7/site-packages/cinder/openstack/common/service.py:38: DeprecationWarning: The oslo namespace package is deprecated. Please use oslo_config instead.
  from oslo.config import cfg
No handlers could be found for logger "oslo_config.cfg"
2015-05-16 00:19:21.440 11007 INFO migrate.versioning.api [-] 39 -> 40...
2015-05-16 00:19:21.459 11007 ERROR 040_add_volume_attachment [-] Table volume_attachment not created!
2015-05-16 00:19:21.459 11007 CRITICAL cinder [-] OperationalError: (OperationalError) (1005, "Can't create table 'cinder.volume_attachment' (errno: 150)") '\nCREATE TABLE volume_attachment (\n\tcreated_at DATETIME, \n\tupdated_at DATETIME, \n\tdeleted_at DATETIME, \n\tdeleted BOOL, \n\tid VARCHAR(36) NOT NULL, \n\tvolume_id VARCHAR(36) NOT NULL, \n\tattached_host VARCHAR(255), \n\tinstance_uuid VARCHAR(36), \n\tmountpoint VARCHAR(255), \n\tattach_time DATETIME, \n\tdetach_time DATETIME, \n\tattach_mode VARCHAR(36), \n\tattach_status VARCHAR(255), \n\tPRIMARY KEY (id), \n\tCHECK (deleted IN (0, 1)), \n\tFOREIGN KEY(volume_id) REFERENCES volumes (id)\n)ENGINE=InnoDB\n\n' ()
2015-05-16 00:19:21.459 11007 TRACE cinder Traceback (most recent call last):
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/bin/cinder-manage", line 10, in <module>
2015-05-16 00:19:21.459 11007 TRACE cinder sys.exit(main())
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/cinder/cmd/manage.py", line 564, in main
2015-05-16 00:19:21.459 11007 TRACE cinder fn(*fn_args)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/cinder/cmd/manage.py", line 230, in sync
2015-05-16 00:19:21.459 11007 TRACE cinder return db_migration.db_sync(version)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/cinder/db/migration.py", line 61, in db_sync
2015-05-16 00:19:21.459 11007 TRACE cinder init_version=init_version)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/migration.py", line 79, in db_sync
2015-05-16 00:19:21.459 11007 TRACE cinder return versioning_api.upgrade(engine, repository, version)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/migrate/versioning/api.py", line 186, in upgrade
2015-05-16 00:19:21.459 11007 TRACE cinder return _migrate(url, repository, version, upgrade=True, err=err, **opts)
2015-05-16 00:19:21.459 11007 TRACE cinder File "<string>", line 2, in _migrate
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/migrate/versioning/util/__init__.py", line 160, in with_engine
2015-05-16 00:19:21.459 11007 TRACE cinder return f(*a, **kw)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/migrate/versioning/api.py", line 366, in _migrate
2015-05-16 00:19:21.459 11007 TRACE cinder schema.runchange(ver, change, changeset.step)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/migrate/versioning/schema.py", line 93, in runchange
2015-05-16 00:19:21.459 11007 TRACE cinder change.run(self.engine, step)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/migrate/versioning/script/py.py", line 148, in run
2015-05-16 00:19:21.459 11007 TRACE cinder script_func(engine)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/cinder/db/sqlalchemy/migrate_repo/versions/040_add_volume_attachment.py", line 63, in upgrade
2015-05-16 00:19:21.459 11007 TRACE cinder volume_attachment.create()
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.py", line 655, in create
2015-05-16 00:19:21.459 11007 TRACE cinder checkfirst=checkfirst)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1617, in _run_visitor
2015-05-16 00:19:21.459 11007 TRACE cinder conn._run_visitor(visitorcallable, element, **kwargs)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1246, in _run_visitor
2015-05-16 00:19:21.459 11007 TRACE cinder **kwargs).traverse_single(element)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/visitors.py", line 120, in traverse_single
2015-05-16 00:19:21.459 11007 TRACE cinder return meth(obj, **kw)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 732, in visit_table
2015-05-16 00:19:21.459 11007 TRACE cinder self.connection.execute(CreateTable(table))
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 729, in execute
2015-05-16 00:19:21.459 11007 TRACE cinder return meth(self, multiparams, params)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 69, in _execute_on_connection
2015-05-16 00:19:21.459 11007 TRACE cinder return connection._execute_ddl(self, multiparams, params)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 783, in _execute_ddl
2015-05-16 00:19:21.459 11007 TRACE cinder compiled
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 958, in _execute_context
2015-05-16 00:19:21.459 11007 TRACE cinder context)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/compat/handle_error.py", line 261, in _handle_dbapi_exception
2015-05-16 00:19:21.459 11007 TRACE cinder e, statement, parameters, cursor, context)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1156, in _handle_dbapi_exception
2015-05-16 00:19:21.459 11007 TRACE cinder util.raise_from_cause(newraise, exc_info)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
2015-05-16 00:19:21.459 11007 TRACE cinder reraise(type(exception), exception, tb=exc_tb)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 951, in _execute_context
2015-05-16 00:19:21.459 11007 TRACE cinder context)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 436, in do_execute
2015-05-16 00:19:21.459 11007 TRACE cinder cursor.execute(statement, parameters)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
2015-05-16 00:19:21.459 11007 TRACE cinder self.errorhandler(self, exc, value)
2015-05-16 00:19:21.459 11007 TRACE cinder File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
2015-05-16 00:19:21.459 11007 TRACE cinder raise errorclass, errorvalue
2015-05-16 00:19:21.459 11007 TRACE cinder OperationalError: (OperationalError) (1005, "Can't create table 'cinder.volume_attachment' (errno: 150)") '\nCREATE TABLE volume_attachment (\n\tcreated_at DATETIME, \n\tupdated_at DATETIME, \n\tdeleted_at DATETIME, \n\tdeleted BOOL, \n\tid VARCHAR(36) NOT NULL, \n\tvolume_id VARCHAR(36) NOT NULL, \n\tattached_host VARCHAR(255), \n\tinstance_uuid VARCHAR(36), \n\tmountpoint VARCHAR(255), \n\tattach_time DATETIME, \n\tdetach_time DATETIME, \n\tattach_mode VARCHAR(36), \n\tattach_status VARCHAR(255), \n\tPRIMARY KEY (id), \n\tCHECK (deleted IN (0, 1)), \n\tFOREIGN KEY(volume_id) REFERENCES volumes (id)\n)ENGINE=InnoDB\n\n' ()
2015-05-16 00:19:21.459 11007 TRACE cinder

tags: added: migration
Revision history for this message
UltimateDogg (ultimatedogg) wrote :

i have a patch but the contact info tab is being silly so i cant commit it right now. ill try again tomorrow or sunday

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/183814

Changed in cinder:
assignee: nobody → UltimateDogg (ultimatedogg)
status: New → In Progress
Mike Perez (thingee)
Changed in cinder:
status: In Progress → Invalid
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on cinder (master)

Change abandoned by Mike Perez (<email address hidden>) on branch: master
Review: https://review.openstack.org/183814
Reason: Over a month with no update.

Revision history for this message
Kevin Fox (kevpn) wrote :

We just hit this same issue. sl7 + rdo juno to sl7.1 + rdo kilo upgrade.

Revision history for this message
Arne Wiebalck (arne-wiebalck) wrote :

We also hit this one when going from CentOS7/Juno-3 to CentOS7/Kilo-1.

Revision history for this message
Toni Ylenius (toni-ylenius) wrote :

We bumbed in to this too, but found the solution on the mailing lists. See http://lists.openstack.org/pipermail/openstack-operators/2015-September/008153.html

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.