wrong unique constraint names

Bug #1182054 reported by Viktor Serhieiev
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Viktor Serhieiev
oslo-incubator
Fix Released
High
Viktor Serhieiev

Bug Description

There is unique constraint name convention: "uniq_c1_x_c2_x_c3" means that columns c1, c2, c3 are in UniqueConstraint.

But there are some constraints that don't much this convention, such as
- key_pairs_uniq_name_and_user_id,
- virtual_interfaces_address_key,
- instance_info_caches_instance_uuid_key

It works fine with sqlite but if we will use mysql or postgresql in case of integrity error we can't get column names from error message.

Tags: db
Changed in nova:
assignee: nobody → Victor Sergeyev (vsergeyev)
status: New → In Progress
Changed in nova:
importance: Undecided → High
description: updated
description: updated
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Revision history for this message
Mark McLoughlin (markmc) wrote :

The oslo review is here: https://review.openstack.org/29888

Changed in oslo:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Victor Sergeyev (vsergeyev)
importance: Medium → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo-incubator (master)

Reviewed: https://review.openstack.org/29888
Committed: http://github.com/openstack/oslo-incubator/commit/3286ca90351d01b08aa6c66e8e3644fb1787a7fe
Submitter: Jenkins
Branch: master

commit 3286ca90351d01b08aa6c66e8e3644fb1787a7fe
Author: Victor Sergeyev <email address hidden>
Date: Tue May 21 11:16:42 2013 +0300

    Changed processing unique constraint name.

    Function `_raise_if_duplicate_entry_error()` modified respectively to
    new unique constraint name convention.

    We found that current constraint name convention allows us create
    constraints with duplicate names. It happens if we will add constraints
    in different tables with same column names (for example, `name`,
    `deleted`). In this case we can not create new constraint due to mysql
    limitation (it requires unique constraint name for database)
    To solve this issue unique constraint name convention was changed
    from "uniq_c1_x_c2_x_c3" to "uniq_t$c1$c2$c3" where `t` it is table name
    and columns `c1`, `c2`, `c3` are in UniqueConstraint.

    Function `_raise_if_duplicate_entry_error()` parse error from
    database and provides us correct column names in error message.
    So now we receive correct error message from function.

    Change-Id: I4a507deba97c499fcd9738d980e36ca0f9454b71
    Fixes: bug 1182054

Changed in oslo:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in oslo:
milestone: none → havana-1
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/30108
Committed: http://github.com/openstack/nova/commit/64ce647003b110771331d3daf92980729bd3988e
Submitter: Jenkins
Branch: master

commit 64ce647003b110771331d3daf92980729bd3988e
Author: Victor Sergeyev <email address hidden>
Date: Wed May 22 15:46:02 2013 +0300

    Rename unique constraints due to new convention.

    We have found that current constraint name convention allows us to create
    constraints with duplicate names. It happens if we add constraints
    in different tables with the same column names (for example, `name`,
    `deleted`). In this case we can not create new constraint in mysql due to
    database limitation (it requires constraint name to be unique within a
    database). To solve this issue unique constraint name convention has
    been changed from "uniq_c1_x_c2_x_c3" to "uniq_t0c10c20c3" where `t` is
    a table name and columns `c1`, `c2`, `c3` are in UniqueConstraint.
    Fixed unique constraints in models description.
    Synced db code from oslo (function `_raise_if_duplicate_entry_error()`
    modified respectively to new unique constraint name convention).

    blueprint db-enforce-unique-keys
    Fixes: bug 1182054

    Change-Id: I4122dfb910a07a1a423781ebc22e9ce50596a05d

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → havana-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in oslo:
milestone: havana-1 → 2013.2
Thierry Carrez (ttx)
Changed in nova:
milestone: havana-2 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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