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