[apci_aim] Remove use of with_lockmode in ml2plus

In certain cases of concurrent operations we are seeing an error
which suggests that a rolled back transaction is be reused. On debugging
it has been observed that the error manifests when the code path
executes the queries that are using with_lockmode in a couple of
places in the ml2 plugin component. Removing the with_lockmode usage
seems to prevent this issue and does not seem to be affecting the
correctness of behavior even in concurrent execution situations.

This patch removes the use of the with_lockmode in the identified place
when the ml2plus plugin configured.

Change-Id: If65c238cbf49a9cfd2546ca26d37ee721f6f986c
(cherry picked from commit 9d16f2cfa3)
This commit is contained in:
Sumit Naiksatam 2017-05-31 16:04:32 -07:00
parent 7e4345d5f4
commit 390118c5c6
1 changed files with 32 additions and 0 deletions

View File

@ -30,3 +30,35 @@ def get_extensions_path(service_plugins=None):
return extension_overrides.__path__[0] + ':' + path
extensions.get_extensions_path = get_extensions_path
from neutron.db import models_v2
from neutron.plugins.ml2 import db as ml2_db
from neutron.plugins.ml2 import models
from oslo_log import log as logging
from sqlalchemy.orm import exc
LOG = logging.getLogger(__name__)
# REVISIT: This method gets decorated in Pike for removal in Queens. So this
# patching might need to be changed in Pike and removed in Queens.
def patched_get_locked_port_and_binding(session, port_id):
"""Get port and port binding records for update within transaction."""
LOG.debug("Using patched_get_locked_port_and_binding")
try:
port = (session.query(models_v2.Port).
enable_eagerloads(False).
filter_by(id=port_id).
one())
binding = (session.query(models.PortBinding).
enable_eagerloads(False).
filter_by(port_id=port_id).
one())
return port, binding
except exc.NoResultFound:
return None, None
ml2_db.get_locked_port_and_binding = patched_get_locked_port_and_binding