Sqlalchemy errors with subnet and group snapshot models

Bug #1862833 reported by Carlos Eduardo
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Shared File Systems Service (Manila)
Fix Released
High
Goutham Pacha Ravi

Bug Description

Some manila or python-manilaclient jobs are broken, since some share network subnet and share group tests are constantly failing. In both cases, the issue seems database related.

All the failing tests have something in common in the exception, which is a database lazy loaded entity, as shown in the below example exception.

Captured traceback:
~~~~~~~~~~~~~~~~~~~
     Traceback (most recent call last):
       File "/home/zuul/src/opendev.org/openstack/manila/manila/tests/api/v2/test_share_network_subnets.py", line 463, in test_list_subnet
         result = self.controller.index(req, self.share_network['id'])
       File "/home/zuul/src/opendev.org/openstack/manila/manila/api/openstack/wsgi.py", line 1068, in version_select
         return func.func(self, *args, **kwargs)
       File "/home/zuul/src/opendev.org/openstack/manila/manila/api/openstack/wsgi.py", line 1162, in wrapper
         return f(self, req, *args, **kwargs)
       File "/home/zuul/src/opendev.org/openstack/manila/manila/api/v2/share_network_subnets.py", line 56, in index
         req, share_network.get('share_network_subnets'))
       File "/home/zuul/src/opendev.org/openstack/manila/manila/api/views/share_network_subnets.py", line 33, in build_share_network_subnets
         for share_network_subnet in share_network_subnets]}
       File "/home/zuul/src/opendev.org/openstack/manila/manila/api/views/share_network_subnets.py", line 33, in <listcomp>
         for share_network_subnet in share_network_subnets]}
       File "/home/zuul/src/opendev.org/openstack/manila/manila/api/views/share_network_subnets.py", line 40, in _build_share_network_subnet_view
         'share_network_name': share_network_subnet.share_network['name'],
       File "/home/zuul/src/opendev.org/openstack/manila/.tox/py36/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 282, in __get__
         return self.impl.get(instance_state(instance), dict_)
       File "/home/zuul/src/opendev.org/openstack/manila/.tox/py36/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 710, in get
         value = self.callable_(state, passive)
       File "/home/zuul/src/opendev.org/openstack/manila/.tox/py36/lib/python3.6/site-packages/sqlalchemy/orm/strategies.py", line 710, in _load_for_state
         % (orm_util.state_str(state), self.key)
     sqlalchemy.orm.exc.DetachedInstanceError: Parent instance <ShareNetworkSubnet at 0x7fee3100d2b0> is not bound to a Session; lazy load operation of attribute 'share_network' cannot proceed (Background on this error at: http://sqlalche.me/e/bhk3)

Tags: db
Changed in manila:
status: New → Confirmed
importance: Undecided → High
milestone: none → ussuri-2
description: updated
Revision history for this message
Carlos Eduardo (silvacarlose) wrote :

Earlier in this morning, we've started searching for possible changes in SQLAlchemy, which is used by manila and is a requirement while running the tests.
We suspect that the problem may have started after the SQLAlchemy 1.3.13 release. I have tested in an environment which uses SQLAlchemy in a older version (1.3.10) and it worked just fine.

[1] https://docs.sqlalchemy.org/en/13/changelog/changelog_13.html#change-1.3.13

tags: added: db
summary: - Some manila jobs are failing due to unit test issues
+ Sqlalchemy errors with subnet and group snapshot models
Changed in manila:
assignee: nobody → Goutham Pacha Ravi (gouthamr)
status: Confirmed → In Progress
Revision history for this message
Goutham Pacha Ravi (gouthamr) wrote :

Fix proposed to branch: master
Review: https://review.opendev.org/#/c/707282/

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to manila (master)

Reviewed: https://review.opendev.org/707282
Committed: https://git.openstack.org/cgit/openstack/manila/commit/?id=ef6b9a0c72a0e47d7345286911a3d882ee1f1909
Submitter: Zuul
Branch: master

commit ef6b9a0c72a0e47d7345286911a3d882ee1f1909
Author: Goutham Pacha Ravi <email address hidden>
Date: Tue Feb 11 17:04:44 2020 -0800

    Fix database loading for some resources

    Whenever we use share network subnets, we'd
    always need the associated share networks; so
    'joined' loading them makes sense rather than
    lazy loading. Same is true for Share Group
    Snapshots, since share group attributes are
    relevant in contexts that snapshots are
    referenced.

    Fix the ORM relationship loading technique
    and queries appropriately. Also convert share
    network name into a property of the share
    network subnet class.

    Co-Authored-By: Carlos Eduardo <email address hidden>
    Closes-Bug: #1862833
    Change-Id: I8c29760479f9c874d618e2c15ebab75bffeb3cbb

Changed in manila:
status: In Progress → Fix Released
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.