<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; "><div>Developers,</div><div><br></div><div>This topic has been discussed before but I do not remember if we have a good solution or not.</div><div>Basically, if concurrent API calls are sent to Neutron, all of them are sent to the plug-in level where two actions have to be made:</div><div><div><br></div><div>1. DB transaction – No just for data persistence but also to collect the information needed for the next action</div><div>2. Plug-in back-end implementation – In our case is a call to the python library than consequentially calls PLUMgrid REST GW (soon SAL)</div><div><br></div><div>For instance:</div><div><br></div><div><div>def create_port(self, context, port):</div><div> with context.session.begin(subtransactions=True):</div><div> # Plugin DB - Port Create and Return port</div><div> port_db = super(NeutronPluginPLUMgridV2, self).create_port(context,</div><div> port)</div><div> device_id = port_db["device_id"]</div><div> if port_db["device_owner"] == "network:router_gateway":</div><div> router_db = self._get_router(context, device_id)</div><div> else:</div><div> router_db = None</div><div> try:</div><div> LOG.debug(_("PLUMgrid Library: create_port() called"))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span># Back-end implementation</div><div> self._plumlib.create_port(port_db, router_db)</div><div> except Exception:</div><div> …</div></div><div><br></div><div>The way we have implemented at the plugin-level in Havana (even in Grizzly) is that both action are wrapped in the same "transaction" which automatically rolls back any operation done to its original state protecting mostly the DB of having any inconsistency state or left over data if the back-end part fails.=.</div><div>The problem that we are experiencing is when concurrent calls to the same API are sent, the number of operation at the plug-in back-end are long enough to make the next concurrent API call to get stuck at the DB transaction level, which creates a hung state for the Neutron Server to the point that all concurrent API calls will fail.</div></div><div><br></div><div>This can be fixed if we include some "locking" system such as calling:</div><div><br></div><div>from neutron.common import utile</div><div>…</div><div><br></div><div>@utils.synchronized('any-name', external=True)</div><div>def create_port(self, context, port):</div><div>…</div><div><br></div><div>Obviously, this will create a serialization of all concurrent calls which will ends up in having a really bad performance. Does anyone has a better solution?</div><div><br></div><div>Thanks,</div><div><br></div><div>Edgar</div></body></html>