]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Get rid of additional db contention on fetching VIP
authorKevin Benton <blak111@gmail.com>
Thu, 20 Mar 2014 07:24:50 +0000 (00:24 -0700)
committerEugene Nikanorov <enikanorov@mirantis.com>
Thu, 20 Mar 2014 19:27:24 +0000 (23:27 +0400)
This fix gets rid of fetching related record from ports table
that could potentially be blocked by concurrent operation
This is to prevent it from updating the
vip table while a port SQL lock is in place, which
vip entries have a reference to.

Partial-Bug: 1283522
Change-Id: Ic64cc268ff4817a31971734a44671c744047231b

neutron/db/loadbalancer/loadbalancer_db.py

index cbff0ed0dbcc8af79e4bb0401e8c0bb4f8f9a471..06ec0723c3c62dc4e743efff28617ff02ec39614 100644 (file)
@@ -192,7 +192,16 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase,
     def update_status(self, context, model, id, status,
                       status_description=None):
         with context.session.begin(subtransactions=True):
-            v_db = self._get_resource(context, model, id)
+            if issubclass(model, Vip):
+                try:
+                    v_db = (self._model_query(context, model).
+                            filter(model.id == id).
+                            options(orm.noload('port')).
+                            one())
+                except exc.NoResultFound:
+                    raise loadbalancer.VipNotFound(vip_id=id)
+            else:
+                v_db = self._get_resource(context, model, id)
             if v_db.status != status:
                 v_db.status = status
             # update status_description in two cases: