[Yahoo-eng-team] [Bug 1501686] Re: Incorrect exception handling in DB code involving rollbacked transactions.

2016-08-21 Thread LIU Yulong
** Changed in: neutron/kilo
   Status: New => Fix Released

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

Title:
  Incorrect exception handling in DB code involving rollbacked
  transactions.

Status in neutron:
  Fix Released
Status in neutron kilo series:
  Fix Released

Bug description:
  I found out that some methods like  add_ha_port
  
https://github.com/openstack/neutron/blob/master/neutron/db/l3_hamode_db.py#L312-L328
  contain the following logic:

  def create():
    create_something()
    try:
  _do_other_thing()
    except Exception:
   with excutils.save_and_reraise_exception():
   delete_something()

  def  _do_other_thing():
   with context.session.begin(subtransactions=True):
   

  The problem is that when exception is raised in _do_other_thing it is
  caught in except block, but the object cannot be deleted in except
  section because internal transaction has been rolled back. We have
  tests on these methods, but they also are not correct (for example
  
https://github.com/openstack/neutron/blob/master/neutron/tests/unit/db/test_l3_hamode_db.py#L360-L377)
  as methods  _do_other_thing() are mocked so inside transaction is
  never created and aborted.

  The possible solution is to use nested transaction in such places like
  this:

  def create()
     with context.session.begin(subtransactions=True):
     create_something()
     try:
     _do_other_thing()
     except Exception:
     with excutils.save_and_reraise_exception():
     delete_something()

  def _do_other_thing():
   with context.session.begin(nested=True):
   

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

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp


[Yahoo-eng-team] [Bug 1501686] Re: Incorrect exception handling in DB code involving rollbacked transactions.

2016-05-09 Thread Dave Walker
** Also affects: neutron/kilo
   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/1501686

Title:
  Incorrect exception handling in DB code involving rollbacked
  transactions.

Status in neutron:
  Fix Released
Status in neutron kilo series:
  New

Bug description:
  I found out that some methods like  add_ha_port
  
https://github.com/openstack/neutron/blob/master/neutron/db/l3_hamode_db.py#L312-L328
  contain the following logic:

  def create():
    create_something()
    try:
  _do_other_thing()
    except Exception:
   with excutils.save_and_reraise_exception():
   delete_something()

  def  _do_other_thing():
   with context.session.begin(subtransactions=True):
   

  The problem is that when exception is raised in _do_other_thing it is
  caught in except block, but the object cannot be deleted in except
  section because internal transaction has been rolled back. We have
  tests on these methods, but they also are not correct (for example
  
https://github.com/openstack/neutron/blob/master/neutron/tests/unit/db/test_l3_hamode_db.py#L360-L377)
  as methods  _do_other_thing() are mocked so inside transaction is
  never created and aborted.

  The possible solution is to use nested transaction in such places like
  this:

  def create()
     with context.session.begin(subtransactions=True):
     create_something()
     try:
     _do_other_thing()
     except Exception:
     with excutils.save_and_reraise_exception():
     delete_something()

  def _do_other_thing():
   with context.session.begin(nested=True):
   

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

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp


[Yahoo-eng-team] [Bug 1501686] Re: Incorrect exception handling in DB code involving rollbacked transactions.

2016-01-21 Thread OpenStack Infra
Reviewed:  https://review.openstack.org/230481
Committed: 
https://git.openstack.org/cgit/openstack/neutron/commit/?id=924f19e8f16aebf103a3b70f2bd236afc846933b
Submitter: Jenkins
Branch:master

commit 924f19e8f16aebf103a3b70f2bd236afc846933b
Author: Ann Kamyshnikova 
Date:   Sat Dec 12 22:11:37 2015 +0300

Make object creation methods in l3_hamode_db atomic

Methods _create_ha_network, add_ha_port don't have wrapping
transaction in them, so they are prone to race conditions.
This commit adds a transaction to them. To avoid problem with
rolling back outmost transaction during exception handling,
internal methods have been wrapped in nested transaction.

Nested transaction is required in places like this:

def create():
  create_something()
  try:
_do_other_thing()
  except Exception:
 with excutils.save_and_reraise_exception():
 delete_something()

def _do_other_thing():
 with context.session.begin(subtransactions=True):
 

When exception is raised in _do_other_thing it
is caught in except block, but the object cannot be deleted in
except section because internal transaction has been rolled back.

A new method safe_creation and has been added
that provides a common way of handling such situations.

Closes-bug: #1501686

Change-Id: I952f6f7f8684743aa7f829bd92b1dc41b2c6aecf


** Changed in: neutron
   Status: In Progress => Fix Released

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

Title:
  Incorrect exception handling in DB code involving rollbacked
  transactions.

Status in neutron:
  Fix Released

Bug description:
  I found out that some methods like  add_ha_port
  
https://github.com/openstack/neutron/blob/master/neutron/db/l3_hamode_db.py#L312-L328
  contain the following logic:

  def create():
    create_something()
    try:
  _do_other_thing()
    except Exception:
   with excutils.save_and_reraise_exception():
   delete_something()

  def  _do_other_thing():
   with context.session.begin(subtransactions=True):
   

  The problem is that when exception is raised in _do_other_thing it is
  caught in except block, but the object cannot be deleted in except
  section because internal transaction has been rolled back. We have
  tests on these methods, but they also are not correct (for example
  
https://github.com/openstack/neutron/blob/master/neutron/tests/unit/db/test_l3_hamode_db.py#L360-L377)
  as methods  _do_other_thing() are mocked so inside transaction is
  never created and aborted.

  The possible solution is to use nested transaction in such places like
  this:

  def create()
     with context.session.begin(subtransactions=True):
     create_something()
     try:
     _do_other_thing()
     except Exception:
     with excutils.save_and_reraise_exception():
     delete_something()

  def _do_other_thing():
   with context.session.begin(nested=True):
   

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

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp