securitygroups table is created again while migrating database from havana to icehouse

Bug #1271231 reported by Jakub Libosvar
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
Jakub Libosvar

Bug Description

There is attempt to create a new table securitygroups by 49f5e553f61f_ml2_security_groups.py while table already exists (created by 3cb5d900c5de_security_groups.py)

INFO [alembic.migration] Context impl MySQLImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
INFO [alembic.migration] Running upgrade havana -> e197124d4b9, add unique constraint to members
INFO [alembic.migration] Running upgrade e197124d4b9 -> 1fcfc149aca4, Add a unique constraint on (agent_type, host) columns to prevent a race
condition when an agent entry is 'upserted'.
INFO [alembic.migration] Running upgrade 1fcfc149aca4 -> 50e86cb2637a, nsx_mappings
INFO [alembic.migration] Running upgrade 50e86cb2637a -> ed93525fd003, bigswitch_quota
INFO [alembic.migration] Running upgrade ed93525fd003 -> 49f5e553f61f, security_groups
Traceback (most recent call last):
  File "/usr/local/bin/neutron-db-manage", line 10, in <module>
    sys.exit(main())
  File "/opt/stack/new/neutron/neutron/db/migration/cli.py", line 143, in main
    CONF.command.func(config, CONF.command.name)
  File "/opt/stack/new/neutron/neutron/db/migration/cli.py", line 80, in do_upgrade_downgrade
    do_alembic_command(config, cmd, revision, sql=CONF.command.sql)
  File "/opt/stack/new/neutron/neutron/db/migration/cli.py", line 59, in do_alembic_command
    getattr(alembic_command, cmd)(config, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/alembic/command.py", line 124, in upgrade
    script.run_env()
  File "/usr/local/lib/python2.7/dist-packages/alembic/script.py", line 199, in run_env
    util.load_python_file(self.dir, 'env.py')
  File "/usr/local/lib/python2.7/dist-packages/alembic/util.py", line 199, in load_python_file
    module = load_module(module_id, path)
  File "/usr/local/lib/python2.7/dist-packages/alembic/compat.py", line 55, in load_module
    mod = imp.load_source(module_id, path, fp)
  File "/opt/stack/new/neutron/neutron/db/migration/alembic_migrations/env.py", line 105, in <module>
    run_migrations_online()
  File "/opt/stack/new/neutron/neutron/db/migration/alembic_migrations/env.py", line 89, in run_migrations_online
    options=build_options())
  File "<string>", line 7, in run_migrations
  File "/usr/local/lib/python2.7/dist-packages/alembic/environment.py", line 652, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/usr/local/lib/python2.7/dist-packages/alembic/migration.py", line 225, in run_migrations
    change(**kw)
  File "/opt/stack/new/neutron/neutron/db/migration/alembic_migrations/versions/49f5e553f61f_ml2_security_groups.py", line 53, in upgrade
    sa.PrimaryKeyConstraint('id')
  File "<string>", line 7, in create_table
  File "/usr/local/lib/python2.7/dist-packages/alembic/operations.py", line 647, in create_table
    self._table(name, *columns, **kw)
  File "/usr/local/lib/python2.7/dist-packages/alembic/ddl/impl.py", line 149, in create_table
    self._exec(schema.CreateTable(table))
  File "/usr/local/lib/python2.7/dist-packages/alembic/ddl/impl.py", line 76, in _exec
    conn.execute(construct, *multiparams, **params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1449, in execute
    params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1542, in _execute_ddl
    compiled
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1698, in _execute_context
    context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1691, in _execute_context
    context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 331, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
sqlalchemy.exc.OperationalError: (OperationalError) (1050, "Table 'securitygroups' already exists") '\nCREATE TABLE securitygroups (\n\ttenant_id VARCHAR(255), \n\tid VARCHAR(36) NOT NULL, \n\tname VARCHAR(255), \n\tdescription VARCHAR(255), \n\tPRIMARY KEY (id)\n)\n\n' ()

summary: - securitygroups table is created twice while migrating database from
+ securitygroups table is created again while migrating database from
havana to icehouse
Revision history for this message
Eugene Nikanorov (enikanorov) wrote :

What was the configuration prior to migration?
securitygroups table was not created via migration for ml2 plugin until 49f5e553f61f was added.
So either you had database created by neutron-server or you had different plugin which caused this table to be created.

Changed in neutron:
status: New → Incomplete
importance: Undecided → High
Revision history for this message
Jakub Libosvar (libosvar) wrote :

This was reveled by grenade upgrade from havana to current master. Problem is that securitygroups table is needed in havana but revision that creates this table using neutron-db-manage is not included in havana.

Havana released was started thus securitygroups table was created. During migration from havana to head it was attempted to create this table again.

Changed in neutron:
status: Incomplete → Triaged
assignee: nobody → Jakub Libosvar (libosvar)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Changed in neutron:
status: Triaged → In Progress
Revision history for this message
Akihiro Motoki (amotoki) wrote :

IMO it is better to backport to stable/havana to keep consistency.

tags: added: havana-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/69416
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=2302ed3f22512590af23a649e09b952189e0fa9d
Submitter: Jenkins
Branch: master

commit 2302ed3f22512590af23a649e09b952189e0fa9d
Author: Jakub Libosvar <email address hidden>
Date: Mon Jan 27 18:09:26 2014 +0100

    Move db migration of ml2 security groups to havana

    ml2 plugin is a havana feature. Currently securitygroups table are
    created in chain of migration after havana release. It causes db
    migration failure when migrating from havana to current head because
    securitygroups table is attempted to be created although it was already
    created by create_all().

    Closes-bug: #1271231
    Change-Id: If450bd95de7a5fdfdb2219cfbf7eb0c1323044bb

Changed in neutron:
status: In Progress → Fix Committed
Changed in neutron:
milestone: none → icehouse-3
Thierry Carrez (ttx)
Changed in neutron:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: icehouse-3 → 2014.1
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.