]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
port-update fails when using SELECT FOR UPDATE lock
authorzhhuabj <zhhuabj@cn.ibm.com>
Wed, 10 Jul 2013 09:49:01 +0000 (17:49 +0800)
committerzhhuabj <zhhuabj@cn.ibm.com>
Wed, 10 Jul 2013 10:07:32 +0000 (18:07 +0800)
In Postgresql, it will throw the bellow exception when
using SELECT FOR UPDATE lock combined with outer join.
"SELECT FOR UPDATE/SHARE cannot be applied to the
 nullable side of an outer join"

The reason can refer http://www.postgresql.org/ \
message-id/21634.1160151923@sss.pgh.pa.us

for this issue, I don't think outer join is necessary,
so I change it to use inner join.

Fixes bug #1191653

Change-Id: Ifc9ecad91324ce28399431ea77fe0865b6d8e523

neutron/db/db_base_plugin_v2.py

index 7378c951f5877ecb3234ff817b41000b2d9d6527..d3998355f5ef9d5883ac3ba97377ed2b88dce8b6 100644 (file)
@@ -504,11 +504,10 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
         """Allocate a specific IP address on the subnet."""
         ip = int(netaddr.IPAddress(ip_address))
         range_qry = context.session.query(
-            models_v2.IPAvailabilityRange,
-            models_v2.IPAllocationPool).join(
+            models_v2.IPAvailabilityRange).join(
                 models_v2.IPAllocationPool).with_lockmode('update')
         results = range_qry.filter_by(subnet_id=subnet_id)
-        for (range, pool) in results:
+        for range in results:
             first = int(netaddr.IPAddress(range['first_ip']))
             last = int(netaddr.IPAddress(range['last_ip']))
             if first <= ip <= last:
@@ -527,7 +526,7 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
                     new_last = range['last_ip']
                     range['last_ip'] = str(netaddr.IPAddress(ip_address) - 1)
                     ip_range = models_v2.IPAvailabilityRange(
-                        allocation_pool_id=pool['id'],
+                        allocation_pool_id=range['allocation_pool_id'],
                         first_ip=new_first,
                         last_ip=new_last)
                     context.session.add(ip_range)