]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix query error on dhcp release port for postgresql
authorArmando Migliaccio <amigliaccio@nicira.com>
Thu, 31 Oct 2013 14:55:30 +0000 (07:55 -0700)
committerarmando-migliaccio <amigliaccio@nicira.com>
Fri, 1 Nov 2013 04:32:20 +0000 (21:32 -0700)
This is achieved by disabling eager loading and
hence by avoiding incurring in left outer joins
that cannot be applied because of a nullable
side.

Closes-bug: #1246788

Change-Id: I16bcc738a43609f715c2561413c6387f443bd99c

neutron/db/db_base_plugin_v2.py

index f7b0442f061b4478290c1691400558ab4444c6d1..58490bca656f7161a9be822a13f53dc70f900698 100644 (file)
@@ -1404,11 +1404,16 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
 
     def delete_ports(self, context, filters):
         with context.session.begin(subtransactions=True):
-            ports = self._get_ports_query(
-                context, filters=filters).with_lockmode('update')
-            if ports:
-                for port in ports:
-                    self.delete_port(context, port['id'])
+            # Disable eagerloads to avoid postgresql issues with outer joins
+            # and SELECT FOR UPDATE. This means that only filters for columns
+            # on the Port model will be effective, which is fine in nearly all
+            # the cases where filters are used
+            query = context.session.query(
+                models_v2.Port).enable_eagerloads(False)
+            ports = self._apply_filters_to_query(
+                query, models_v2.Port, filters).with_lockmode('update').all()
+            for port in ports:
+                self.delete_port(context, port['id'])
 
     def _delete_port(self, context, id):
         port = self._get_port(context, id)