From 187217d767ca41b742937fe183ba4a4c20e59185 Mon Sep 17 00:00:00 2001 From: Cedric Brandily Date: Tue, 26 Aug 2014 20:23:04 +0200 Subject: [PATCH] Remove SELECT FOR UPDATE use in delete_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 delete_firewall method with the use of single-shot DELETE expressions. Partial-Bug: #1364358 Change-Id: Ia8db73312f5dff6a5bd573694a60a798279834cb --- neutron/db/firewall/firewall_db.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/neutron/db/firewall/firewall_db.py b/neutron/db/firewall/firewall_db.py index 3460ea01b..16dbd6220 100644 --- a/neutron/db/firewall/firewall_db.py +++ b/neutron/db/firewall/firewall_db.py @@ -264,12 +264,11 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin): def delete_firewall(self, context, id): LOG.debug(_("delete_firewall() called")) with context.session.begin(subtransactions=True): - fw_query = context.session.query( - Firewall).with_lockmode('update') - firewall_db = fw_query.filter_by(id=id).one() # Note: Plugin should ensure that it's okay to delete if the # firewall is active - context.session.delete(firewall_db) + count = context.session.query(Firewall).filter_by(id=id).delete() + if not count: + raise firewall.FirewallNotFound(firewall_id=id) def get_firewall(self, context, id, fields=None): LOG.debug(_("get_firewall() called")) -- 2.45.2