From: Cory Stone Date: Wed, 26 Aug 2015 00:05:36 +0000 (-0500) Subject: Dont eager load volume type specs on volume list X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3539af3d96c3dcf64bb6a06af4be567d15b2a130;p=openstack-build%2Fcinder-build.git Dont eager load volume type specs on volume list Some drivers need extra specs loaded on create and the session could be closed by the time they access them. However for a volume list, eager loading these attributes causes a severe performance penalty. Move the eager load to the single volume get case. Change-Id: I6fbf5508684a01a7df7930d4f1b4a47adeefe521 Closes-Bug: 1486289 --- diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index 868909892..c356c5cc2 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -1296,7 +1296,6 @@ def _volume_get_query(context, session=None, project_only=False): options(joinedload('volume_metadata')).\ options(joinedload('volume_admin_metadata')).\ options(joinedload('volume_type')).\ - options(joinedload('volume_type.extra_specs')).\ options(joinedload('volume_attachment')).\ options(joinedload('consistencygroup')) else: @@ -1304,7 +1303,6 @@ def _volume_get_query(context, session=None, project_only=False): project_only=project_only).\ options(joinedload('volume_metadata')).\ options(joinedload('volume_type')).\ - options(joinedload('volume_type.extra_specs')).\ options(joinedload('volume_attachment')).\ options(joinedload('consistencygroup')) @@ -1312,6 +1310,7 @@ def _volume_get_query(context, session=None, project_only=False): @require_context def _volume_get(context, volume_id, session=None): result = _volume_get_query(context, session=session, project_only=True).\ + options(joinedload('volume_type.extra_specs')).\ filter_by(id=volume_id).\ first()