diff options
| author | TianTian Gao <gtt116@126.com> | 2012-09-04 12:01:41 +0800 |
|---|---|---|
| committer | TianTian Gao <gtt116@126.com> | 2012-09-05 13:00:58 +0800 |
| commit | be72921c6f38b8b71ffc474ceae58e67241dac22 (patch) | |
| tree | a954dd2812a8b24940eae4159a04d7e34d852883 | |
| parent | 51f5b8c28e37af4ab7c86e5b4ed8a3be0460fe32 (diff) | |
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
| -rw-r--r-- | nova/manager.py | 5 | ||||
| -rw-r--r-- | nova/virt/libvirt/driver.py | 5 |
2 files changed, 9 insertions, 1 deletions
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 diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index c9326e71b..203789f6f 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -1996,6 +1996,8 @@ class LibvirtDriver(driver.ComputeDriver): total += 1 else: total += len(vcpus[1]) + # NOTE(gtt116): give change to do other task. + greenthread.sleep(0) return total def get_memory_mb_used(self): @@ -2690,7 +2692,8 @@ class LibvirtDriver(driver.ComputeDriver): except exception.InstanceNotFound: # Instance was deleted during the check so ignore it pass - + # NOTE(gtt116): give change to do other task. + greenthread.sleep(0) # Disk available least size available_least_size = dk_sz_gb * (1024 ** 3) - instances_sz return (available_least_size / 1024 / 1024 / 1024) |
