DetachedInstanceError on subnet delete

Bug #1672701 reported by venkata anil
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
venkata anil

Bug Description

While trying to delete subnets, some failed with this trace

2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource [req-8a9aabc4-f02a-4533-aa09-e853daf82579 5227a890398042c5b769cd1ed632ec76 e8ba07a25a7d43509b342265c7ac124b - - -] delete failed
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource Traceback (most recent call last):
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/neutron/api/v2/resource.py", line 83, in resource
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource result = method(request=request, **args)
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/neutron/api/v2/base.py", line 532, in delete
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource return self._delete(request, id, **kwargs)
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/oslo_db/api.py", line 146, in wrapper
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource ectxt.value = e.inner_exc
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 204, in __exit__
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/oslo_db/api.py", line 136, in wrapper
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource return f(*args, **kwargs)
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/neutron/api/v2/base.py", line 554, in _delete
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource obj_deleter(request.context, id, **kwargs)
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/plugin.py", line 967, in delete_subnet
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource if a.port:
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 237, in __get__
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource return self.impl.get(instance_state(instance), dict_)
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 578, in get
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource value = self.callable_(state, passive)
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/strategies.py", line 502, in _load_for_state
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource (orm_util.state_str(state), self.key)
2017-03-09 17:23:56.953 3432 ERROR neutron.api.v2.resource DetachedInstanceError: Parent instance <IPAllocation at 0x573f7d0> is not bound to a Session; lazy load operation of attribute 'port' cannot proceed

complete log is here

Revision history for this message
venkata anil (anil-venkata) wrote :
Changed in neutron:
assignee: nobody → venkata anil (anil-venkata)
Revision history for this message
venkata anil (anil-venkata) wrote :

This is not reproducible on master because of Kevin's patch [1] but seen on all branches.
We can call get_port at [2] to fix it. It will be a one line change and fix for only branches. Should we go with this new fix for branches or backport Kevin's patch [1] ?

[1] https://github.com/openstack/neutron/commit/31fa23d84c9054fb4cfebccef953bf6839698a1d#diff-939db8d9176a76658a0886bd9382dccfR914
[2] https://github.com/openstack/neutron/blob/stable/ocata/neutron/plugins/ml2/plugin.py#L1156

Revision history for this message
Ihar Hrachyshka (ihar-hrachyshka) wrote :

I believe just replacing .port access with explicit get_port call will be a less invasive change than e.g. backporting the whole patch [1].

tags: added: db l3-ipam-dhcp
Changed in neutron:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/ocata)

Fix proposed to branch: stable/ocata
Review: https://review.openstack.org/445996

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/449095

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/ocata)

Reviewed: https://review.openstack.org/445996
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=b9242c348cbf44ef1bd061826067c2ec96b8d2f0
Submitter: Jenkins
Branch: stable/ocata

commit b9242c348cbf44ef1bd061826067c2ec96b8d2f0
Author: venkata anil <email address hidden>
Date: Wed Mar 15 14:57:38 2017 +0000

    Fix DetachedInstanceError on subnet delete

    While trying to delete subnets, some failed with DetachedInstanceError,
    because 'port' is not part of 'IPAllocation' object when accessed
    outside the DB session(in which 'IPAllocation' object was created).

    To avoid this error, we call get_port explicitly before using the port.
    This issue is not seen on master branch as recent code refactor[1] is
    also calling get_port there.

    [1] https://review.openstack.org/#/c/428774/

    Closes-bug: #1672701
    Change-Id: I924fa7e36ea9e45bf0ef3480972341a851bda86c

tags: added: in-stable-ocata
Revision history for this message
Ihar Hrachyshka (ihar-hrachyshka) wrote :

I believe API misbehavior like that for core resources like subnet are of High impact, bumped importance.

Changed in neutron:
importance: Medium → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/newton)

Reviewed: https://review.openstack.org/449095
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=20b9b8934331556e217e63b9a0dab6e71c2ef7c6
Submitter: Jenkins
Branch: stable/newton

commit 20b9b8934331556e217e63b9a0dab6e71c2ef7c6
Author: venkata anil <email address hidden>
Date: Wed Mar 15 14:57:38 2017 +0000

    Fix DetachedInstanceError on subnet delete

    While trying to delete subnets, some failed with DetachedInstanceError,
    because 'port' is not part of 'IPAllocation' object when accessed
    outside the DB session(in which 'IPAllocation' object was created).

    To avoid this error, we call get_port explicitly before using the port.
    This issue is not seen on master branch as recent code refactor[1] is
    also calling get_port there.

    [1] https://review.openstack.org/#/c/428774/

    Closes-bug: #1672701
    Change-Id: I924fa7e36ea9e45bf0ef3480972341a851bda86c
    (cherry picked from commit b9242c348cbf44ef1bd061826067c2ec96b8d2f0)

tags: added: in-stable-newton
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 9.3.0

This issue was fixed in the openstack/neutron 9.3.0 release.

Changed in neutron:
status: Confirmed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 10.0.1

This issue was fixed in the openstack/neutron 10.0.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.