Repository navigation
Description
What happened + What you expected to happen
The GCS crashes on restart when GCS fault tolerance (external Redis) is on.
It happens when the actor table has an actor that meets all three conditions:
- Its state is
DEAD, with death causeOUT_OF_SCOPE. - It can still restart (
max_restarts=-1, or restarts are left). - Its job is still alive.
The GCS aborts in GcsActorManager::Initialize(). Each new GCS reads the same actor from Redis and aborts again. The loop stops only when the Redis keys are flushed.
gcs_actor.h:90: Check failed: actor_table_data_.state() != rpc::ActorTableData::DEAD
ray::gcs::GcsActor::GcsActor()
ray::gcs::GcsActorManager::Initialize()
ray::gcs::GcsServer::InitGcsActorManager()
ray::gcs::GcsServer::DoStart()
Expected: the GCS starts normally. The actor stays available for lineage reconstruction, the same as without a GCS restart.
Ray Data hits this with default settings. ActorPoolMapOperator sets max_restarts=-1 and max_task_retries=-1 on pool actors (actor_pool_map_operator.py#L833-L839). Pool actors go out of scope while their output blocks are still in use.
We hit this in production. The head container of a long-running cluster was OOM-killed. The new GCS crash-looped 200+ times over about 19 hours, until we flushed Redis.
Code path (master @ e65cf45):
- A restartable actor goes out of scope.
DestroyActormarks itDEADbut keeps it inregistered_actors_(gcs_actor_manager.cc#L1126-L1141).IsActorRestartablereturns true forOUT_OF_SCOPEifmax_restarts == -1or restarts are left (protobuf_utils.cc#L168-L179). - The GCS restarts.
OnInitializeActorShouldLoadlets thisDEADactor through, because its job is alive (gcs_actor_manager.cc#L165-L185). Initializecreates it with the task-spec constructor (gcs_actor_manager.cc#L1789-L1795). That constructor is "only for ALIVE actors". It checksstate != DEAD, so the GCS aborts (gcs_actor.h#L71-L90).
With max_restarts=0, the GCS restarts fine. Step 2 filters the actor out.
Two possible fixes:
- Allow restartable
DEADactors in that constructor. Other parts ofInitializemay also assume a live actor (e.g. node/worker bookkeeping), so they need a check too. - Or skip these actors on init and mark them permanently dead. They then can't be used for lineage reconstruction after a GCS restart.
Related: #66073 fixed a crash in the same init path, for actors without a task spec. In this case the task spec exists.
Versions / Dependencies
- Ray 2.60.1 (reproduced with the script below). First seen on 2.55.1. The code path is the same on master @ e65cf45.
- Python 3.12, Linux x86_64
- GCS FT via
RAY_REDIS_ADDRESS
Reproduction script
# Needs a local Redis for GCS fault tolerance, e.g. `redis-server --port 6379 --save "" &`
import os
import time
os.environ.setdefault("RAY_REDIS_ADDRESS", "127.0.0.1:6379")
import ray
from ray._private import ray_constants
# Same defaults Ray Data's ActorPoolMapOperator gives its pool actors.
@ray.remote(max_restarts=-1, max_task_retries=-1)
class Worker:
def produce(self):
return b"x" * (1 << 20) # lands in plasma, so the actor stays pinned as its lineage
ray.init()
node = ray._private.worker._global_node
actor = Worker.remote()
ref = actor.produce.remote()
ray.get(ref)
del actor # handle out of scope while `ref` is alive -> DEAD with OUT_OF_SCOPE (restartable)
time.sleep(5)
node.kill_gcs_server()
node.start_gcs_server()
time.sleep(10)
gcs = node.all_processes[ray_constants.PROCESS_TYPE_GCS_SERVER][0].process
print("GCS exit code after restart:", gcs.poll()) # None = alive. 2.60.1: 1, see gcs_server.1.errOn 2.60.1 this prints GCS exit code after restart: 1. logs/gcs_server.1.err shows the check failure above. Each further GCS restart fails the same way. With max_restarts=0, the GCS stays up.
Issue Severity
Medium: It is a significant difficulty but I can work around it.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn progress
Activity