Comment 3 for bug 1804271

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

Reviewed: https://review.openstack.org/619061
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=248750578a938a1eaa2e49004302d14ab7318c5b
Submitter: Zuul
Branch: master

commit 248750578a938a1eaa2e49004302d14ab7318c5b
Author: Matt Riedemann <email address hidden>
Date: Tue Nov 20 13:55:55 2018 -0500

    Remove GROUP BY clause from CellMapping.get_by_project_id

    Under postgresql, the GROUP BY clause in this query fails with:

      DBError: (psycopg2.ProgrammingError) column "instance_mappings.created_at"
      must appear in the GROUP BY clause or be used in an aggregate function

    And we're getting lucky with using this under mysql because we don't
    have the ONLY_FULL_GROUP_BY mode set (but we probably should).

    This change removes the GROUP BY clause and re-writes the query
    to avoid the joinedload() from the instance_mappings table and
    simply do a subquery to get the cell_ids and then do a simple
    IN query with the cell_mappings table. This fixes the GROUP BY
    issue and should also make the query more efficient since we
    won't have to load InstanceMappings ORM objects.

    Change-Id: Idc9b5ad019205f447c82a702dd3391fa5dd20228
    Closes-Bug: #1804271