Activity log for bug #1501686

Date Who What changed Old value New value Message
2015-10-01 10:03:10 Ann Taraday bug added bug
2015-10-01 10:19:57 Ann Taraday description I found out that some methods like _create_ha_interfaces https://github.com/openstack/neutron/blob/master/neutron/db/l3_hamode_db.py#L329-L345 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): .... 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):          ....
2015-10-01 11:50:42 Ann Taraday neutron: importance Undecided Medium
2015-10-01 14:10:29 Assaf Muller neutron: status New Confirmed
2015-10-01 14:10:47 Assaf Muller tags db db l3-ha
2015-10-02 14:53:30 OpenStack Infra neutron: status Confirmed In Progress
2015-11-26 17:18:13 OpenStack Infra neutron: assignee Ann Kamyshnikova (akamyshnikova) Cedric Brandily (cbrandily)
2015-11-26 18:47:14 Ann Taraday neutron: assignee Cedric Brandily (cbrandily) Ann Kamyshnikova (akamyshnikova)
2016-01-21 13:56:58 OpenStack Infra neutron: status In Progress Fix Released
2016-01-31 06:38:37 OpenStack Infra tags db l3-ha db in-stable-liberty l3-ha
2016-04-01 01:03:44 OpenStack Infra tags db in-stable-liberty l3-ha db in-stable-kilo in-stable-liberty l3-ha
2016-05-09 11:44:42 Dave Walker nominated for series neutron/kilo
2016-05-09 11:44:43 Dave Walker bug task added neutron/kilo
2016-08-22 01:54:37 LIU Yulong neutron/kilo: status New Fix Released
2016-09-08 17:46:29 OpenStack Infra tags db in-stable-kilo in-stable-liberty l3-ha db in-stable-kilo in-stable-liberty in-stable-mitaka l3-ha