#66565·ray

[Core] Late RESOURCE_VIEW messages can reinsert dead nodes into the raylet resource map

Author: hhhhjunCreated Sep 29, 2026Updated Sep 29, 2026
LabelsbugP0triageperformancecorestabilitycommunity-backlog

What happened + What you expected to happen

Summary

A late RESOURCE_VIEW message can recreate a dead node's entry in the raylet's local resource map after its DEAD notification has already been processed.

In a long-running cluster with frequent worker churn, we observed approximately 1,079 live nodes in GCS but 223,654 entries in the head raylet's resource map.

Sequence of events

  1. Raylet R receives resource information for worker node N.
  2. N dies, and R processes its DEAD notification through NodeManager::NodeRemoved().
  3. NodeRemoved() records N in failed_nodes_cache_ and removes its resource entry through ClusterResourceManager::RemoveNode().
  4. A delayed RESOURCE_VIEW message for N subsequently reaches NodeManager::ConsumeSyncMessage().
  5. ConsumeSyncMessage() does not check failed_nodes_cache_ before updating labels and resources.
  6. SetNodeLabels() inserts a new entry when N is missing, recreating the resource entry for a node already known to be dead.

The same issue can occur when DEAD arrives before the first resource message for N.

Expected behavior

Once a raylet has observed DEAD for NodeID N, subsequent resource messages for N must not recreate its resource entry.

However, resource messages for an unknown/new NodeID should still be accepted before its ALIVE notification arrives. Rejecting every node that is not currently known alive would break this valid ordering.

Impact

Obsolete entries can accumulate in the resource map under worker churn. SPREAD scheduling builds and sorts candidates from that map before filtering them, so an inflated map adds scheduling work.

During the captured incident, RequestWorkerLease handler statistics showed approximately 45 ms mean execution time and 1.4 s mean queueing time. These are production observations, not a controlled benchmark. We have not established that this issue caused every pending actor or insufficient-resource retry.

Proposed fix

In NodeManager::ConsumeSyncMessage(), reject RESOURCE_VIEW messages for NodeIDs already in failed_nodes_cache_ before calling SetNodeLabels() or modifying resource state.

This is separate from the GCS dead-node metadata cache controlled by maximum_gcs_dead_node_cached_count.

We implemented this guard locally. Validation passed 36 NodeManager tests and isolated task, Dashboard, and Serve smoke tests. The full upstream suite has not been run.

Relevant code

  • src/ray/raylet/node_manager.cc
    • NodeManager::NodeRemoved()
    • NodeManager::ConsumeSyncMessage()
  • src/ray/raylet/scheduling/cluster_resource_manager.cc
    • ClusterResourceManager::RemoveNode()
    • ClusterResourceManager::SetNodeLabels()
  • src/ray/raylet/scheduling/policy/spread_scheduling_policy.cc

Versions / Dependencies

  • Ray: mainline (upstream master).
  • Python: 3.12.
  • OS: Linux.
  • Deployment: Kubernetes, with a long-lived head and frequent worker replacement.
  • Workload: Ray Serve GPU actors using SPREAD scheduling.

The affected code path was also inspected at upstream commit: e430ec9ed0e1f9963d1a6b71ec1913eed0d98353

That commit pins the source inspection; it is not claimed to be the exact production build commit.

Reproduction script

This is a C++ regression test, not a standalone Python script.

Add it to src/ray/raylet/tests/node_manager_test.cc alongside the existing NodeManagerTest tests, then build and run the NodeManager test target.

The test exercises the actual GCS node-liveness callback and ConsumeSyncMessage() handler. It covers both RESOURCE_VIEW-before-DEAD and DEAD-before-RESOURCE_VIEW ordering.

On the unguarded implementation, a late resource message recreates the dead node's resource entry, violating the assertions. With the known-dead guard, the entry remains absent, while a new NodeID is still accepted before ALIVE.

This test was validated locally; it has not been rerun against the exact upstream commit listed above.

raylet-dead-node-reproduction.txt

Issue Severity

High: It blocks me from completing my task.