mirror of
https://github.com/wassname/ray.git
synced 2026-07-09 20:29:55 +08:00
Implement resource deadlock detection for new scheduler (#12961)
This commit is contained in:
@@ -414,7 +414,7 @@ def init_error_pubsub():
|
||||
return p
|
||||
|
||||
|
||||
def get_error_message(pub_sub, num, error_type=None, timeout=5):
|
||||
def get_error_message(pub_sub, num, error_type=None, timeout=20):
|
||||
"""Get errors through pub/sub."""
|
||||
start_time = time.time()
|
||||
msgs = []
|
||||
|
||||
@@ -17,7 +17,8 @@ import ray.ray_constants as ray_constants
|
||||
from ray.exceptions import RayTaskError
|
||||
from ray.cluster_utils import Cluster
|
||||
from ray.test_utils import (wait_for_condition, SignalActor, init_error_pubsub,
|
||||
get_error_message, Semaphore)
|
||||
get_error_message, Semaphore,
|
||||
new_scheduler_enabled)
|
||||
|
||||
|
||||
def test_failed_task(ray_start_regular, error_pubsub):
|
||||
@@ -632,11 +633,12 @@ def test_export_large_objects(ray_start_regular, error_pubsub):
|
||||
assert errors[0].type == ray_constants.PICKLING_LARGE_OBJECT_PUSH_ERROR
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="TODO detect resource deadlock")
|
||||
def test_warning_for_resource_deadlock(error_pubsub, shutdown_only):
|
||||
p = error_pubsub
|
||||
# Check that we get warning messages for infeasible tasks.
|
||||
ray.init(num_cpus=1)
|
||||
@pytest.mark.skipif(
|
||||
new_scheduler_enabled(), reason="Supposed to deadlock, but it doesn't")
|
||||
def test_warning_all_tasks_blocked(shutdown_only):
|
||||
ray.init(
|
||||
num_cpus=1, _system_config={"debug_dump_period_milliseconds": 500})
|
||||
p = init_error_pubsub()
|
||||
|
||||
@ray.remote(num_cpus=1)
|
||||
class Foo:
|
||||
@@ -646,7 +648,7 @@ def test_warning_for_resource_deadlock(error_pubsub, shutdown_only):
|
||||
@ray.remote
|
||||
def f():
|
||||
# Creating both actors is not possible.
|
||||
actors = [Foo.remote() for _ in range(2)]
|
||||
actors = [Foo.remote() for _ in range(3)]
|
||||
for a in actors:
|
||||
ray.get(a.f.remote())
|
||||
|
||||
@@ -657,6 +659,46 @@ def test_warning_for_resource_deadlock(error_pubsub, shutdown_only):
|
||||
assert errors[0].type == ray_constants.RESOURCE_DEADLOCK_ERROR
|
||||
|
||||
|
||||
def test_warning_actor_waiting_on_actor(shutdown_only):
|
||||
ray.init(
|
||||
num_cpus=1, _system_config={"debug_dump_period_milliseconds": 500})
|
||||
p = init_error_pubsub()
|
||||
|
||||
@ray.remote(num_cpus=1)
|
||||
class Actor:
|
||||
pass
|
||||
|
||||
a = Actor.remote() # noqa
|
||||
b = Actor.remote() # noqa
|
||||
|
||||
errors = get_error_message(p, 1, ray_constants.RESOURCE_DEADLOCK_ERROR)
|
||||
assert len(errors) == 1
|
||||
assert errors[0].type == ray_constants.RESOURCE_DEADLOCK_ERROR
|
||||
|
||||
|
||||
def test_warning_task_waiting_on_actor(shutdown_only):
|
||||
ray.init(
|
||||
num_cpus=1, _system_config={"debug_dump_period_milliseconds": 500})
|
||||
p = init_error_pubsub()
|
||||
|
||||
@ray.remote(num_cpus=1)
|
||||
class Actor:
|
||||
pass
|
||||
|
||||
a = Actor.remote() # noqa
|
||||
|
||||
@ray.remote(num_cpus=1)
|
||||
def f():
|
||||
print("f running")
|
||||
time.sleep(999)
|
||||
|
||||
ids = [f.remote()] # noqa
|
||||
|
||||
errors = get_error_message(p, 1, ray_constants.RESOURCE_DEADLOCK_ERROR)
|
||||
assert len(errors) == 1
|
||||
assert errors[0].type == ray_constants.RESOURCE_DEADLOCK_ERROR
|
||||
|
||||
|
||||
def test_warning_for_infeasible_tasks(ray_start_regular, error_pubsub):
|
||||
p = error_pubsub
|
||||
# Check that we get warning messages for infeasible tasks.
|
||||
|
||||
@@ -9,7 +9,7 @@ import pytest
|
||||
|
||||
import ray
|
||||
import ray.cluster_utils
|
||||
from ray.test_utils import wait_for_condition, new_scheduler_enabled
|
||||
from ray.test_utils import wait_for_condition
|
||||
from ray.internal.internal_api import global_gc
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -166,9 +166,9 @@ def test_global_gc_when_full(shutdown_only):
|
||||
gc.enable()
|
||||
|
||||
|
||||
@pytest.mark.skipif(new_scheduler_enabled(), reason="hangs")
|
||||
def test_global_gc_actors(shutdown_only):
|
||||
ray.init(num_cpus=1)
|
||||
ray.init(
|
||||
num_cpus=1, _system_config={"debug_dump_period_milliseconds": 500})
|
||||
|
||||
try:
|
||||
gc.disable()
|
||||
@@ -179,8 +179,7 @@ def test_global_gc_actors(shutdown_only):
|
||||
return "Ok"
|
||||
|
||||
# Try creating 3 actors. Unless python GC is triggered to break
|
||||
# reference cycles, this won't be possible. Note this test takes 20s
|
||||
# to run due to the 10s delay before checking of infeasible tasks.
|
||||
# reference cycles, this won't be possible.
|
||||
for i in range(3):
|
||||
a = A.remote()
|
||||
cycle = [a]
|
||||
|
||||
Reference in New Issue
Block a user