From: Cedric Brandily Date: Tue, 26 Aug 2014 20:57:30 +0000 (+0200) Subject: Remove SELECT FOR UPDATE use in update_firewall X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2ce3525286eb5e0cf30c72a91f33dccb50e518b0;p=openstack-build%2Fneutron-build.git Remove SELECT FOR UPDATE use in update_firewall SELECT FOR UPDATE expression, which is triggered with the use of the SQLAlchemy Query object's with_lockmode('update') method, is detrimental to performance and scalability of the database performance code in Neutron due to the lock contention it produces. SELECT FOR UPDATE can be entirely avoided in update_firewall method with the use of single-shot UPDATE expressions. Change-Id: I333f726498192295116ca96ff5ca9012c36a6fd1 --- diff --git a/neutron/db/firewall/firewall_db.py b/neutron/db/firewall/firewall_db.py index 3460ea01b..3ed69e676 100644 --- a/neutron/db/firewall/firewall_db.py +++ b/neutron/db/firewall/firewall_db.py @@ -255,11 +255,10 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin): LOG.debug(_("update_firewall() called")) fw = firewall['firewall'] with context.session.begin(subtransactions=True): - fw_query = context.session.query( - Firewall).with_lockmode('update') - firewall_db = fw_query.filter_by(id=id).one() - firewall_db.update(fw) - return self._make_firewall_dict(firewall_db) + count = context.session.query(Firewall).filter_by(id=id).update(fw) + if not count: + raise firewall.FirewallNotFound(firewall_id=id) + return self.get_firewall(context, id) def delete_firewall(self, context, id): LOG.debug(_("delete_firewall() called"))