wrong alembic when alter enum in postgre

Bug #1520777 reported by Luo Gangyi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gnocchi
Fix Released
High
Luo Gangyi
1.3
Fix Released
High
Unassigned

Bug Description

      File "/home/luogangyi/tmp/gnocchi/gnocchi/indexer/alembic/env.py", line 83, in run_migrations_online
        context.run_migrations()
      File "<string>", line 8, in run_migrations
      File "/usr/lib/python2.7/site-packages/alembic/runtime/environment.py", line 797, in run_migrations
        self.get_context().run_migrations(**kw)
      File "/usr/lib/python2.7/site-packages/alembic/runtime/migration.py", line 312, in run_migrations
        step.migration_fn(**kw)
      File "/home/luogangyi/tmp/gnocchi/gnocchi/indexer/alembic/versions/3901f5ea2b8e_create_instance_disk_and_instance_.py", line 53, in upgrade
        op.execute("ALTER TYPE resource_type_enum ADD VALUE '%s'" % value)
      File "<string>", line 8, in execute
      File "<string>", line 3, in execute
      File "/usr/lib/python2.7/site-packages/alembic/operations/ops.py", line 1826, in execute
        return operations.invoke(op)
      File "/usr/lib/python2.7/site-packages/alembic/operations/base.py", line 318, in invoke
        return fn(self, operation)
      File "/usr/lib/python2.7/site-packages/alembic/operations/toimpl.py", line 161, in execute_sql
        execution_options=operation.execution_options
      File "/usr/lib/python2.7/site-packages/alembic/ddl/impl.py", line 121, in execute
        self._exec(sql, execution_options)
      File "/usr/lib/python2.7/site-packages/alembic/ddl/impl.py", line 118, in _exec
        return conn.execute(construct, *multiparams, **params)
      File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
        return meth(self, multiparams, params)
      File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
        return connection._execute_clauseelement(self, multiparams, params)
      File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
        compiled_sql, distilled_params
      File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
        context)
      File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1337, in _handle_dbapi_exception
        util.raise_from_cause(newraise, exc_info)
      File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
        reraise(type(exception), exception, tb=exc_tb)
      File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
        context)
      File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
        cursor.execute(statement, parameters)
    oslo_db.exception.DBError: (psycopg2.InternalError) ALTER TYPE ... ADD cannot run inside a transaction block
     [SQL: "ALTER TYPE resource_type_enum ADD VALUE 'instance_network_interface'"]

it is the problem in postgre, see http://stackoverflow.com/questions/1771543/postgresql-updating-an-enum-type/10404041#10404041

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

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

Changed in gnocchi:
assignee: nobody → Luo Gangyi (luogangyi)
status: New → In Progress
Julien Danjou (jdanjou)
Changed in gnocchi:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to gnocchi (master)

Reviewed: https://review.openstack.org/251039
Committed: https://git.openstack.org/cgit/openstack/gnocchi/commit/?id=20418cd339af775842e84c2b6d2a820289888f00
Submitter: Jenkins
Branch: master

commit 20418cd339af775842e84c2b6d2a820289888f00
Author: Luo Gangyi <email address hidden>
Date: Sat Nov 28 21:56:42 2015 +0800

    fix error in alembic when upgrade postgresql

    ALTER TYPE ... ADD cannot run inside a transaction block,
    therefore we use another way to update it.

    Change-Id: I8c6f62b7642917a2ea1bc0280e41261797aca172
    Closes-Bug: #1520777

Changed in gnocchi:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to gnocchi (stable/1.3)

Fix proposed to branch: stable/1.3
Review: https://review.openstack.org/253540

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to gnocchi (stable/1.3)

Reviewed: https://review.openstack.org/253540
Committed: https://git.openstack.org/cgit/openstack/gnocchi/commit/?id=26641ac63c86fa2eee5769dcf4eaaf74bb1b892e
Submitter: Jenkins
Branch: stable/1.3

commit 26641ac63c86fa2eee5769dcf4eaaf74bb1b892e
Author: Luo Gangyi <email address hidden>
Date: Sat Nov 28 21:56:42 2015 +0800

    fix error in alembic when upgrade postgresql

    ALTER TYPE ... ADD cannot run inside a transaction block,
    therefore we use another way to update it.

    Change-Id: I8c6f62b7642917a2ea1bc0280e41261797aca172
    Closes-Bug: #1520777
    (cherry picked from commit 20418cd339af775842e84c2b6d2a820289888f00)

Julien Danjou (jdanjou)
Changed in gnocchi:
milestone: none → 2.0.0
status: Fix Committed → Fix Released
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.