← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1409774] [NEW] sqlalchemy session needs to be rolled back after catching a db exception

 

Public bug reported:

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

** Affects: neutron
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1409774

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

Status in OpenStack Neutron (virtual network service):
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1409774/+subscriptions


Follow ups

References