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
This commit is contained in:
1
Authors
1
Authors
@@ -189,6 +189,7 @@ Stephanie Reese <reese.sm@gmail.com>
|
||||
Sumit Naiksatam <snaiksat@cisco.com>
|
||||
Takaaki Suzuki <suzuki@midokura.com>
|
||||
Thierry Carrez <thierry@openstack.org>
|
||||
TianTian Gao <gtt116@126.com>
|
||||
Tim Simpson <tim.simpson@rackspace.com>
|
||||
Todd Willey <todd@ansolabs.com>
|
||||
Tomoe Sugihara <tomoe@midokura.com>
|
||||
|
||||
@@ -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 import log as logging
|
||||
@@ -153,6 +155,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
|
||||
|
||||
@@ -1777,6 +1777,8 @@ class LibvirtConnection(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):
|
||||
@@ -2337,7 +2339,8 @@ class LibvirtConnection(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)
|
||||
|
||||
Reference in New Issue
Block a user