commit c1a6fdb9f64e3436dbbe97603df8beb7ddd6a501
Author: Ann Kamyshnikova <email address hidden>
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.
Reviewed: https:/ /review. openstack. org/273110 /git.openstack. org/cgit/ openstack/ neutron/ commit/ ?id=c1a6fdb9f64 e3436dbbe97603d f8beb7ddd6a501
Committed: https:/
Submitter: Jenkins
Branch: stable/kilo
commit c1a6fdb9f64e343 6dbbe97603df8be b7ddd6a501
Author: Ann Kamyshnikova <email address hidden>
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( )
_do_other_ thing()
with excutils. save_and_ reraise_ exception( ):
delete_ something( )
try:
except Exception:
def _do_other_thing(): session. begin(subtransa ctions= True):
with context.
....
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
Conflicts: source/ devref/ effective_ neutron. rst db/common_ db_mixin. py db/l3_hamode_ db.py
doc/
neutron/
neutron/
Change-Id: I952f6f7f868474 3aa7f829bd92b1d c41b2c6aecf 103a3b70f2bd236 afc846933b) 172be0c4cd02319 34bcbc8d23)
(cherry picked from commit 924f19e8f16aebf
(cherry picked from commit 229856666adf729