]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Simplify ip allocation/recycling to relieve db pressure
authorCarl Baldwin <carl.baldwin@hp.com>
Mon, 18 Nov 2013 23:32:19 +0000 (23:32 +0000)
committerCarl Baldwin <carl.baldwin@hp.com>
Wed, 29 Jan 2014 21:19:00 +0000 (21:19 +0000)
commit89f25623a4345b5044a58cff36e7fd103c6b88e8
tree814e804ac3db73ff35fbb3154796b69d1d760e54
parentb78eea6146145793a7c61705a1602cf5e9ac3d3a
Simplify ip allocation/recycling to relieve db pressure

I found that multiple calls to delete_port can pile up on the
_recycle_ip operation.  This patch simplifies this operation.  It
reduces the _recycle_ip operation to a single row delete in the ip
allocations table and doesn't touch the availability table.

To acheive the recycling of ips in a pool, this code runs a more
complex operation of rebuilding the availability table when it is
exhausted.  Only one API process will perform this more expensive
operation and others waiting for allocation will immediately benefit.
The amortized cost of this operation is much less than the cumulative
cost of running the more expensive _recycle_ip operation for every
port delete.

IP allocation behaves a bit differently with this patch.  Instead of
giving out the first IP available in a pool, the entire pool will be
allocated before wrapping around and recycling ip addresses that have
been released.  This is a desirable feature as it puts ip addresses in
a sort of quarantine after they are released.  It is easier to
distinguish newly allocated ips from old ones.

Change-Id: Ia55b66128de9986e075b0f87acc401d211cd91d3
Closes-Bug: #1252506
Closes-Bug: #1257815
neutron/db/db_base_plugin_v2.py
neutron/db/models_v2.py
neutron/tests/unit/nicira/test_networkgw.py
neutron/tests/unit/test_db_plugin.py