[openstack-dev] [Neutron ML2] Potential DB lock when developing new mechanism driver

Li Ma skywalker.nick at gmail.com
Wed Jun 25 03:33:09 UTC 2014

Hi all,

I'm developing a new mechanism driver. I'd like to access ml2-related tables in create_port_precommit and create_port_postcommit. However I find it hard to do that because the two functions are both inside an existed database transaction defined in create_port function of ml2/plugin.py.

The related code is as follows:

def create_port(self, context, port):
    session = context.session
    with session.begin(subtransactions=True):
    return result

As a result, I need to carefully deal with the database nested transaction issue to prevent from db lock when I develop my own mechanism driver. Right now, I'm trying to get the idea behind the scene. Is it possible to refactor it in order to make precommit and postcommit out of the db transaction? I think it is perfect for those who develop mechanism driver and do not know well about the functioning context of the whole ML2 plugin.

Li Ma

More information about the OpenStack-dev mailing list