From ecb1f61412cbeb074ebd8ba5a123e2a55821c148 Mon Sep 17 00:00:00 2001 From: Wenhao Xu Date: Wed, 6 Feb 2013 19:49:38 +0800 Subject: Fix lazy load 'system_metadata' failed problem. When using lazy load of SQLAlchemy, parent instance may have a problem not bouding to a session object and fail the lazy loading system_metadata. Using joinedload to eagly load the system_metadata in _instance_get_all_query to fix the problem. Fixes: bug 1117232 Change-Id: Id24ca534f6eb57167aee22aca12c1274c90baf3c --- nova/db/sqlalchemy/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index e6d2d3459..6aa4d96da 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1702,7 +1702,8 @@ def _instance_get_all_query(context, project_only=False): options(joinedload('info_cache')).\ options(joinedload('security_groups')).\ options(joinedload('metadata')).\ - options(joinedload('instance_type')) + options(joinedload('instance_type')).\ + options(joinedload('system_metadata')) @require_admin_context -- cgit