From cc6940b42e56a80bcc472231417f25d44f29ccb2 Mon Sep 17 00:00:00 2001 From: TianTian Gao Date: Tue, 4 Sep 2012 12:01:41 +0800 Subject: [PATCH] Yield to another greenthread when some time-consuming task finished. Partially addresses bug #1045152 On a heavily loaded compute node, it can be observed that periodic tasks take so long to run that the report_state() looping call can be blocked from running long enough that the scheduler thinks the host is dead. Reduce the chance of this happening by yielding to another greenthread after each periodic task has completed and each loop in some methods that has linear relationship with the number of instances. Change-Id: If2b125708da8298b20497e2e08e52280c102f1e1 --- nova/manager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nova/manager.py b/nova/manager.py index c6711aadb..275d98b61 100644 --- a/nova/manager.py +++ b/nova/manager.py @@ -53,6 +53,8 @@ This module provides Manager, a base class for managers. """ +import eventlet + from nova.db import base from nova import flags from nova.openstack.common import log as logging @@ -171,6 +173,9 @@ class Manager(base.Base): try: task(self, context) + # NOTE(tiantian): After finished a task, allow manager to + # do other work (report_state, processing AMPQ request etc.) + eventlet.sleep(0) except Exception as e: if raise_on_error: raise