[openstack-dev] [neutron] InvalidRequestError: This session is in 'prepared' state; no further SQL can be emitted within this transaction.

Koteswar koti.kelam at gmail.com
Mon Jan 11 14:09:59 UTC 2016


thanks a lot. I will try this.

On Mon, Jan 11, 2016 at 7:26 PM, Mike Bayer <mbayer at redhat.com> wrote:

>
>
> On 01/11/2016 03:58 AM, Koteswar wrote:
> > Hi All,
> >
> >
> >
> > In my mechanism driver, I am reading/writing into sql db in a fixed
> > interval looping call. Sometimes I get the following error when I stop
> > and start neutron server
> >
> > InvalidRequestError: This session is in 'prepared' state; no further SQL
> > can be emitted within this transaction.
> >
> >
> >
> > I am using context.session.query() for add, delete, update and get.
> > Please help me if any one resolved an issue like this.
>
> the stack trace is unfortunately re-thrown from the ml2.managers code
> without retaining the original traceback; use this form to reraise with
> original tb:
>
>     exc_info = sys.exc_info()
>     raise type(e), e, exc_info[2]
>
> There's likely helpers somewhere in oslo that do this.
>
> The cause of this error is that a transaction commit is failing, the
> error is being caught and this same Session is being used again without
> rollback called first.   The code below illustrates the problem and how
> to solve.
>
> from sqlalchemy import create_engine
> from sqlalchemy.orm import Session
>
>
> e = create_engine("sqlite://")
>
> s = Session(e)
>
>
> conn = s.connection()
>
>
> def boom():
>     raise Exception("sqlite commit failed")
>
> # "break" connection.commit(),
> # so that the commit fails
> conn.connection.commit = boom
> try:
>     # fail
>     s.commit()
> except Exception, e:
>     # uncomment this to fix the error
>     # s.rollback()
>     pass
> finally:
>     boom = False
>
>
> # prepared state error
> s.connection()
>
> >
> >
> >
> > Full trace is as follows:
> >
> > 2016-01-06 15:33:21.799 [01;31mERROR neutron.plugins.ml2.managers
> > [[01;36mreq-d940a1b6-253a-43d2-b5ff-6c784c8a520f [00;36madmin
> > 83b5358da62a407f88155f447966356f[01;31m] [01;35m[01;31mMechanism driver
> > 'hp' failed in create_port_precommit[00m
> >
> > [01;31m2016-01-06 15:33:21.799 TRACE neutron.plugins.ml2.managers
> > [01;35m[00mTraceback (most recent call last):
> >
> > [01;31m2016-01-06 15:33:21.799 TRACE neutron.plugins.ml2.managers
> > [01;35m[00m  File "/opt/stack/neutron/neutron/plugins/ml2/managers.py",
> > line 394, in _call_on_drivers
> >
> > [01;31m2016-01-06 15:33:21.799 TRACE neutron.plugins.ml2.managers
> > [01;35m[00m    getattr(driver.obj, method_name)(context)
> >
> > [01;31m2016-01-06 15:33:21.799 TRACE neutron.plugins.ml2.managers
> > [01;35m[00m  File
> >
> "/usr/local/lib/python2.7/dist-packages/baremetal_network_provisioning/ml2/mechanism_hp.py",
> > line 67, in create_port_precommit
> >
> > [01;31m2016-01-06 15:33:21.799 TRACE neutron.plugins.ml2.managers
> > [01;35m[00m    raise e
> >
> > [01;31m2016-01-06 15:33:21.799 TRACE neutron.plugins.ml2.managers
> > [01;35m[00mInvalidRequestError: This session is in 'prepared' state; no
> > further SQL can be emitted within this transaction.
> >
> > [01;31m2016-01-06 15:33:21.799 TRACE neutron.plugins.ml2.managers
> > [01;35m[00m
> >
> > 2016-01-06 15:33:21.901 [01;31mERROR neutron.api.v2.resource
> > [[01;36mreq-d940a1b6-253a-43d2-b5ff-6c784c8a520f [00;36madmin
> > 83b5358da62a407f88155f447966356f[01;31m] [01;35m[01;31mcreate failed[00m
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00mTraceback (most recent call last):
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File "/opt/stack/neutron/neutron/api/v2/resource.py", line
> > 83, in resource
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    result = method(request=request, **args)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File
> > "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in
> > wrapper
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    ectxt.value = e.inner_exc
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File
> > "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line
> > 195, in __exit__
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    six.reraise(self.type_, self.value, self.tb)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File
> > "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in
> > wrapper
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    return f(*args, **kwargs)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File "/opt/stack/neutron/neutron/api/v2/base.py", line 516,
> > in create
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    obj = do_create(body)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File "/opt/stack/neutron/neutron/api/v2/base.py", line 498,
> > in do_create
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    request.context, reservation.reservation_id)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File
> > "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line
> > 195, in __exit__
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    six.reraise(self.type_, self.value, self.tb)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File "/opt/stack/neutron/neutron/api/v2/base.py", line 491,
> > in do_create
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    return obj_creator(request.context, **kwargs)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File
> > "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in
> > wrapper
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    ectxt.value = e.inner_exc
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File
> > "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line
> > 195, in __exit__
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    six.reraise(self.type_, self.value, self.tb)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File
> > "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in
> > wrapper
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    return f(*args, **kwargs)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py",
> > line 1040, in create_port
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    result, mech_context = self._create_port_db(context, port)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py",
> > line 1032, in _create_port_db
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    self.mechanism_manager.create_port_precommit(mech_context)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File "/opt/stack/neutron/neutron/plugins/ml2/managers.py",
> > line 590, in create_port_precommit
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    self._call_on_drivers("create_port_precommit", context)
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m  File "/opt/stack/neutron/neutron/plugins/ml2/managers.py",
> > line 405, in _call_on_drivers
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00m    method=method_name
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource
> > [01;35m[00mMechanismDriverError: create_port_precommit failed.
> >
> > [01;31m2016-01-06 15:33:21.901 TRACE neutron.api.v2.resource [01;35m[00m
> >
> >
> >
> > Regards,
> >
> > Koteswar
> >
> >
> >
> >
> __________________________________________________________________________
> > OpenStack Development Mailing List (not for usage questions)
> > Unsubscribe:
> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
> >
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20160111/31feef3c/attachment.html>


More information about the OpenStack-dev mailing list