sqlalchemy session needs to be rolled back after catching a db exception

Bug #1409774 reported by Rossella Sblendido
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
neutron
Expired
Undecided
Unassigned

Bug Description

To avoid errors like this:

sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back by a nested rollback() call. To begin a new transaction, issue Session.rollback() first

the sqlalchemy session needs to be rolled back after catching a db exception in a transaction, see sqlalchemy faq http://docs.sqlalchemy.org/en/rel_0_8/faq.html#this-session-s-transaction-has-been-rolled-back-due-to-a-previous-exception-during-flush-or-similar . There are places in Neutron code where a db exception is caught and the session is not properly rolled back. As explained in the sqlalchemy faq, this is the right way:

try:
<use session>
session.commit()
except:
session.rollback()
raise
finally:
session.close() # optional, depends on use case

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/146542

Changed in neutron:
assignee: nobody → Rossella Sblendido (rossella-o)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron (master)

Change abandoned by Kyle Mestery (<email address hidden>) on branch: master
Review: https://review.openstack.org/146542
Reason: This review is > 4 weeks without comment, and failed Jenkins the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

Ping?

Changed in neutron:
status: In Progress → Incomplete
assignee: Rossella Sblendido (rossella-o) → nobody
Revision history for this message
Ann Taraday (akamyshnikova) wrote :

I filed and I'm working on a bug similar to this https://bugs.launchpad.net/neutron/+bug/1501686

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for neutron because there has been no activity for 60 days.]

Changed in neutron:
status: Incomplete → Expired
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.