From 2ef0dcfac78468551aac8492269ad856c312dcb5 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 3 Jul 2012 14:50:11 -0700 Subject: Avoid lazy-loading errors on instance_type When instances are launched with a source group, the instance_type is not lazy_loaded in properly. The issue is intermittent because if another query has already loaded the instance with a joined instance_type or the instance has not yet been expunged from the session, then the load succeeds. Therefore this failure only appears under heavy load. Adding an explicit joindload fixes the issue. Change-Id: I450c598c31c416c7be341cbb8cd14e33c6bb2aec --- nova/db/sqlalchemy/api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index e6d7f88c7..93bce01c5 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -3538,9 +3538,9 @@ def security_group_rule_get(context, security_group_rule_id, session=None): def security_group_rule_get_by_security_group(context, security_group_id, session=None): return _security_group_rule_get_query(context, session=session).\ - filter_by(parent_group_id=security_group_id).\ - options(joinedload_all('grantee_group.instances')).\ - all() + filter_by(parent_group_id=security_group_id).\ + options(joinedload_all('grantee_group.instances.instance_type')).\ + all() @require_context -- cgit