]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
_update_router_db: don't hold open transactions
authorKevin Benton <blak111@gmail.com>
Thu, 16 Oct 2014 08:49:19 +0000 (01:49 -0700)
committerKevin Benton <blak111@gmail.com>
Wed, 22 Oct 2014 23:13:14 +0000 (16:13 -0700)
commitf23f2ecee68ba4abd12139bbb91b77ba9410f581
tree77d80d3749d8c13953a1862f40e53fe38620e092
parentdfe800bbd5b8cfe13b6c3b662995064ffed055a6
_update_router_db: don't hold open transactions

This patch prevents the L3 _update_router_db method from
starting a transaction before calling the gateway interface
removal functions. With these port changes now occuring
outside of the L3 DB transaction, a failure to update the
router DB information will not rollback the port deletion
operation.

The 'VPN in use' check had to be moved inside of the DB deletion
transaction now that there isn't an enclosing transaction to undo
the delete when an 'in use' error is raised.

===Details===

The router update db method starts a transaction and calls
the gateway update method with the transaction held open.
This becomes a problem when the update results in an
interface removal which uses a port table lock.

Because the delete_port caller is still holding open a
transaction, other sessions are blocked from getting an
SQL lock on the same tables when delete_port starts
performing RPC notifications, external controller calls,
etc. During those external calls, eventlet will
yield and another thread may try to get a lock on the
port table, causing the infamous mysql/eventlet deadlock.

This separation of L2/L3 transactions is similiar to change
I3ae7bb269df9b9dcef94f48f13f1bde1e4106a80 in nature. Even
though there is a loss in the atomic behavior of the interface
removal operation, it was arguably incorrect to begin with.
The restoration of port DB records during a rollback after some
other failure doesn't undo the backend operations (e.g. REST calls)
that happened during the original deletion. So, having a delete
rollback without corresponding 'create_port' calls to the backend
causes a loss in consistency.

Closes-Bug: #1377241
Change-Id: I5fdb6b24bf2fb80ac5e36a742aa7056db72c8c7d
neutron/db/l3_db.py