calculate_resource_count broken in sqlalchemy 1.4

Bug #1928085 reported by Brian Rosmaita
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Critical
Unassigned

Bug Description

Observed in master (xena development) with both 1.4.13 (proposed upper-constraint [0]) and 1.4.15 (most recent sqlalchemy release [1]), using oslo.db===8.6.0
[0] https://review.opendev.org/c/openstack/requirements/+/788339/7/upper-constraints.txt#150
[1] https://www.sqlalchemy.org/blog/2021/05/11/sqlalchemy-1.4.15-released

Error is: "sqlalchemy.exc.ArgumentError: Query has only expression-based entities"

12 of these in current tests with 3 variations:
sqlalchemy.exc.ArgumentError: Query has only expression-based entities - can't find property named "backup_metadata".
sqlalchemy.exc.ArgumentError: Query has only expression-based entities - can't find property named "snapshot_metadata".
sqlalchemy.exc.ArgumentError: Query has only expression-based entities - can't find property named "volume_metadata".

Think they're coming from here:
    File "/home/brosmait/repos/openstack/cinder/cinder/db/sqlalchemy/api.py", line 2387, in calculate_resource_count
    return query.with_entities(func.count()).scalar()

example failure:
cinder.tests.unit.api.v3.test_volumes.VolumeApiTest.test_list_volume_with_count_param_3

full test output: http://paste.openstack.org/show/805237/

Tags: sqlalchemy
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/cinder/+/790797

Changed in cinder:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.opendev.org/c/openstack/cinder/+/790797
Committed: https://opendev.org/openstack/cinder/commit/a3682eac340c48b0b7430443d52bf7af5af5cf86
Submitter: "Zuul (22348)"
Branch: master

commit a3682eac340c48b0b7430443d52bf7af5af5cf86
Author: Gorka Eguileor <email address hidden>
Date: Tue May 11 17:59:46 2021 +0200

    SQLA 1.4: Fix calculate_resource_count

    SQLAlchemy 1.4 is failing on method calculate_resource_count with error:

      sqlalchemy.exc.ArgumentError: Query has only expression-based entities
      - can't find property named "XYZ_metadata".

    Where XYZ is backup, snapshot, and volume.

    This is most likely caused by SQLAlchemy not knowing what to do with the
    joined loads once we replace the query using `with_entities`.

    This patch fixes this issues by not doing unnecessary joined loads when
    counting resources.

    Closes-Bug: #1928085
    Change-Id: I6b60106347aede024e5546f766453b4fec648cc2

Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 19.0.0.0b1

This issue was fixed in the openstack/cinder 19.0.0.0b1 development milestone.

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.