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

Bug #1409774 reported by Rossella Sblendido on 2015-01-12
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
neutron
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

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

Changed in neutron:
assignee: nobody → Rossella Sblendido (rossella-o)
status: New → In Progress

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.

Ping?

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

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

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  Edit
Everyone can see this information.

Other bug subscribers