oslo.db now wraps all DB exceptions

Bug #1364986 reported by Roman Podoliaka
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Eugeniya Kudryashova

Bug Description

tl;dr

In a few versions of oslo.db (maybe when we release 1.0.0?), every project using oslo.db should inspect their code and remove usages of 'raw' DB exceptions like IntegrityError/OperationalError/etc from except clauses and replace them with the corresponding custom exceptions from oslo.db (at least a base one - DBError).

Full version

A recent commit to oslo.db changed the way the 'raw' DB exceptions are wrapped (e.g. IntegrityError, OperationalError, etc). Previously, we used decorators on Session methods and wrapped those exceptions with oslo.db custom ones. This is mostly useful for handling them later (e.g. to retry DB API methods on deadlocks).

The problem with Session decorators was that it wasn't possible to catch and wrap all possible exceptions. E.g. SA Core exceptions and exceptions raised in Query.all() calls were ignored. Now we are using a low level SQLAlchemy event to catch all possible DB exceptions. This means that if consuming projects had workarounds for those cases and expected 'raw' exceptions instead of oslo.db ones, they would be broken. That's why we *temporarily* added both 'raw' exceptions and new ones to expect clauses in consuming projects code when they were ported to using of oslo.db to make the transition smooth and allow them to work with different oslo.db versions.

On the positive side, we now have a solution for problems like https://bugs.launchpad.net/nova/+bug/1283987 when exceptions in Query methods calls weren't handled properly.

In a few releases of oslo.db we can safely remove 'raw' DB exceptions like IntegrityError/OperationalError/etc from projects code and except only oslo.db specific ones like DBDuplicateError/DBReferenceError/DBDeadLockError/etc (at least, we wrap all the DB exceptions with our base exception DBError, if we haven't found a better match).

oslo.db exceptions and their description: https://github.com/openstack/oslo.db/blob/master/oslo/db/exception.py

Tags: db
description: updated
tags: added: db
description: updated
Changed in nova:
assignee: nobody → Eugeniya Kudryashova (ekudryashova)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/101901
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=1b83b2f11054ddd3f72fe75c5cef496060afcb3a
Submitter: Jenkins
Branch: master

commit 1b83b2f11054ddd3f72fe75c5cef496060afcb3a
Author: Andrey Kurilin <email address hidden>
Date: Sat Jun 21 13:56:42 2014 +0300

    Move to oslo.db

    Replace common oslo code nova.openstack.common.db by usage
    of oslo.db library and remove common code.

    Replaced catching of raw sqlalchemy exceptions by catches
    of oslo.db exceptions(such as DBError, DBDuplicateEntry, etc).

    Co-Authored-By: Eugeniya Kudryashova <email address hidden>

    Closes-Bug: #1364986
    Closes-Bug: #1353131
    Closes-Bug: #1283987
    Closes-Bug: #1274523
    Change-Id: I0649539e071b2318ec85ed5d70259c949408e64b

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → juno-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-rc1 → 2014.2
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.