From 3539af3d96c3dcf64bb6a06af4be567d15b2a130 Mon Sep 17 00:00:00 2001 From: Cory Stone Date: Tue, 25 Aug 2015 19:05:36 -0500 Subject: [PATCH] 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 --- cinder/db/sqlalchemy/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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() -- 2.45.2