[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
Tue Jan 12 13:33:45 UTC 2016


I tried rollback but still it didn't work. This issue is reproduced
sometimes only when
1. neutron port created
2. enable fixed looping in conf, stop neutron and start
3. delete neutron port

and looping interval is very lesss say 20 secs.
source code where it fails:
--------------------------------------
def get_bnp_neutron_port(context, neutron_port_id):
    """Get bnp neutron port that matches neutron_port_id."""
    try:
        query = context.session.query(models.BNPNeutronPort)
        port_map = query.filter_by(neutron_port_id=neutron_port_id).one()
    except exc.NoResultFound:
        LOG.error(_LE('no port map found with id: %s'), port_map)
        return
    except Exception as e:
        LOG.error("BNP Exception: %s", e)
        context.session.rollback()
        return
    return port_map

trace:
-----------------------------
2016-01-12 07:00:54.421 ERROR
baremetal_network_provisioning.db.bm_nw_provision_db
[req-79c61136-2f15-40b6-a0c7-074848d87d6e admin
1395aaf0481f4bc9b8fbb8888e555fe1] BNP Exception: This se
ssion is in 'prepared' state; no further SQL can be emitted within this
transaction.
2016-01-12 07:00:54.421 ERROR oslo_db.sqlalchemy.exc_filters
[req-79c61136-2f15-40b6-a0c7-074848d87d6e admin
1395aaf0481f4bc9b8fbb8888e555fe1] DB exception wrapped.
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters Traceback
(most recent call last):
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters   File
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line
668, in _rollback_impl
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters
self.engine.dialect.do_rollback(self.connection)
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters   File
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/dialects/mysql/base.py",
line 2519, in do_rollback
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters
dbapi_connection.rollback()
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters   File
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 724,
in rollback
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters
self._read_ok_packet()
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters   File
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 698,
in _read_ok_packet
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters     pkt =
self._read_packet()
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters   File
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 895,
in _read_packet
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters
packet_header = self._read_bytes(4)
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters   File
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 912,
in _read_bytes
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters     data =
self._rfile.read(num_bytes)
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters RuntimeError:
reentrant call inside <_io.BufferedReader name=3>
2016-01-12 07:00:54.421 TRACE oslo_db.sqlalchemy.exc_filters
2016-01-12 07:00:54.433 ERROR neutron.plugins.ml2.managers
[req-79c61136-2f15-40b6-a0c7-074848d87d6e admin
1395aaf0481f4bc9b8fbb8888e555fe1] Mechanism driver 'hp' failed in
delete_port_pr
ecommit


On Mon, Jan 11, 2016 at 7:39 PM, Koteswar <koti.kelam at gmail.com> wrote:

> 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/20160112/f653d3be/attachment.html>


More information about the OpenStack-dev mailing list