Incorrect error message logged: Entity already exists

Bug #1489457 reported by Dave McCowan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Barbican
Fix Released
Medium
Samantha Blanco

Bug Description

When an entry is made into the database when a resource is created, SQLalchemy performs a set of constraint checks to verify that the entry will be valid. In Barbican, a resource includes secrets, containers, consumers, transport-keys, etc. Constraints that can be checked include uniqueness (no duplicates), not null, matches an entry in another table (Foreign Key), etc.

When a constraint check fails, SQLalchemy raises the exception exc.IntegrityError.
BaseRepo():create_from() catches that and then raises the exception exc.Duplicate.

This can be misleading when debugging a problem, since the message now indicates that a duplicate entry exists, when in reality any number of constraints could have failed instead.

This code should raise a new exception that preserves more information about the failure, and does not provide incorrect information.

From barbican/model/repositories.py
        try:
            LOG.debug("Saving entity...")
            entity.save(session=session)
        except sqlalchemy.exc.IntegrityError:
            LOG.exception(u._LE('Problem saving entity for create'))
            _raise_entity_already_exists(self._do_entity_name())

Neetu Jain (nutshi)
Changed in barbican:
assignee: nobody → Neetu Jain (nutshi)
Changed in barbican:
status: New → Triaged
importance: Undecided → Medium
Changed in barbican:
assignee: Neetu Jain (nutshi) → nobody
Changed in barbican:
assignee: nobody → Pradeep Kumar Singh (pradeep-singh-u)
Changed in barbican:
assignee: Pradeep Kumar Singh (pradeep-singh-u) → nobody
Changed in barbican:
assignee: nobody → Priti Desai (priti-desai)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on barbican (master)

Change abandoned by Kaitlin Farr (<email address hidden>) on branch: master
Review: https://review.openstack.org/267826
Reason: To clean up the Barbican review queue, I am abandoning this patch because it has negative reviews and has not been updated since the start of the current development cycle (Newton). Please feel free to restore the patch and address any comments or issues if you'd still like to contribute this patch.

Changed in barbican:
assignee: Priti Desai (priti-desai) → nobody
assignee: nobody → Dave McCowan (dave-mccowan)
status: Triaged → In Progress
milestone: none → pike-1
Revision history for this message
Dave McCowan (dave-mccowan) wrote :
Changed in barbican:
assignee: Dave McCowan (dave-mccowan) → Samantha Blanco (sblanco1)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to barbican (master)

Reviewed: https://review.openstack.org/430471
Committed: https://git.openstack.org/cgit/openstack/barbican/commit/?id=9744f8018650b92e1537360ce627b053eaab1101
Submitter: Jenkins
Branch: master

commit 9744f8018650b92e1537360ce627b053eaab1101
Author: Dave McCowan <email address hidden>
Date: Thu Jan 14 15:31:40 2016 -0600

    Handle SQL Integrity Error More Generically

    SQL command with IntegrityError when any number of
    constraints fail to pass. These include checking for
    duplicates, checking for not null, or foreign key checks.

    Barbican was reporting these all as duplicates which can confuse
    debugging. This patch reports the error more accurately as an
    SQL constraint check failure.

    Change-Id: I7043fe01f949326b1e38c8f320ece8418f36acc4
    Co-Authored-By: Dave McCowan <email address hidden>
    Closes-bug: #1489457

Changed in barbican:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/barbican 5.0.0.0b1

This issue was fixed in the openstack/barbican 5.0.0.0b1 development milestone.

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.