Skip to content

[core][gcs] Publish node death before persist; drop RocksDB soft-durability (REP-64) - #64702

Merged
edoakes merged 14 commits into
ray-project:masterfrom
jhasm:jhasm/rep-64-fix-node-death-lost-wakeup
Jul 29, 2026
Merged

edoakes merged 14 commits into
ray-project:masterfrom
jhasm:jhasm/rep-64-fix-node-death-lost-wakeup

Conversation

@jhasm

@jhasm jhasm commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Follow-up to #63657 (embedded RocksDB GCS backend, REP-64) that fixes the underlying pub/sub issue at its root and removes the temporary "soft-durability" workaround.

Root cause (proven in #64187)

GCS published the node-death notification from inside the node table write's completion callback — publish-after-persist. Owners of objects/tasks react to a node's death only from that single pushed pub/sub notification (core_worker.cc on_node_change, DEAD branch), and once subscribed there is no periodic owner-side re-poll. Gating the publish on the durable write therefore couples cluster-wide death detection to persist latency: under a slow backend (the RocksDB GCS with per-write fsync) the notification is delayed enough to strand object recovery and hang test_dynamic_generator_reconstruction_nondeterministic[None-*] in list(gen).

The provenance PR #64187 demonstrates this deterministically on the in-memory GCS (timing injected), confirming the bug is in Ray core and backend-agnostic.

Fix (F3 — publish node death before persist)

Publish node death on the in-memory DEAD transition, posted onto the GCS io_context and decoupled from the durable write. Applied to both node-death paths:

  • GcsNodeManager::InternalOnNodeFailure — health-check failure.
  • GcsNodeManager::HandleUnregisterNode — graceful unregistration.

Properties:

  • Relaxes broadcast-after-durable ordering only for the node channel. Safe because node death is a terminal, restart-re-derivable transition (re-established by health checks on GCS restart).
  • Not generalized to the actor channel. This is not because the actor channel has extra client-side self-healing that nodes lack — in fact the two are symmetric: both fetch current state on subscribe and re-fetch on GCS restart (AsyncResubscribe), and neither periodically re-polls an already-established subscription. The difference is durability semantics: actor state is not terminal and can legitimately change (e.g. RESTARTING → ALIVE) and must survive a GCS crash in durable order, so its publish must stay gated on persist. Node liveness is terminal and re-derivable, so relaxing the ordering is safe.
  • Keeps strict durability; smallest change that removes the proven cause at its source.

We deliberately did not add the optional owner-side fallback re-poll (F5 in #64187): the demonstrated failure is a slow publish, not a dropped one, and F5 would add a permanent periodic GCS poll to every owner for a hypothetical the pub/sub layer already makes unlikely. It remains an isolated future option if a genuinely dropped notification is ever observed.

Remove the soft-durability workaround

With the root cause fixed, all GCS tables use strict per-write WAL fsync (sync = true) again. Deletes SoftDurableTables() and simplifies RocksDbStoreClient::SyncWriteOptions() (now returns a const & to a shared constant, no per-write copy). The NODE/ACTOR relaxation is no longer needed.

How do we know this is safe?

The ordering guarantee (death is broadcast before, and independently of, the durable write) is covered end-to-end and at the unit level:

  • End-to-end regression — test_dynamic_generator_reconstruction_nondeterministic[None-*] (python/ray/tests/test_generators.py) is the exact scenario the bug hangs. It passes on the RocksDB GCS with strict fsync and no soft-durability, i.e. purely because of F3.
  • Deterministic unit ordering tests (gcs_node_manager_test.cc, new):
    • TestNodeFailurePublishesDeathBeforePersist — health-check path: after OnNodeFailure, running exactly one queued handler broadcasts DEAD while the persist-completion callback has not yet run.
    • TestUnregisterNodePublishesDeathBeforePersist — graceful-unregister path: the DEAD publish fires before the persist-completion callback (which is what writes the DEAD export event).
      Both fail against the old publish-after-persist behavior and pass with F3, so they lock in the fix.
  • Provenance proof ([DO NOT MERGE][core][gcs] Provenance: node-death lost-wakeup hangs generator reconstruction (REP-64) #64187) demonstrates the same lost-wakeup on the in-memory GCS with injected timing, independent of any storage backend.

Practically-possible scenarios and why they remain safe: (a) slow persist — publish is already decoupled; (b) GCS restart before persist — node death is re-derived by health checks and clients re-fetch on resubscribe; (c) dropped push (not observed) — out of scope for this PR and independently addressable via the F5 backstop without touching F3.

Related issue number

Checks

  • gcs_node_manager_test (incl. new ordering tests), node_manager_export_event_test pass
  • rocksdb_store_client_test, rocksdb_smoke_test pass
  • gcs_server_lib + rocksdb_store_client build cleanly
  • clang-format / black / ruff / pydoclint clean

…bility

Fixes the root-cause pub/sub issue proven in ray-project#64187 and removes the
soft-durability workaround shipped with the RocksDB GCS backend (ray-project#63657).

Root cause: GCS published the node-death notification from inside the node
table write's completion callback (publish-after-persist). Owners of
objects/tasks react to a node's death ONLY from that single pushed pub/sub
notification (core_worker.cc on_node_change, DEAD branch) with no owner-side
fallback, so gating the publish on the durable write couples cluster-wide death
detection to persist latency. Under a slow backend (the RocksDB GCS with
per-write fsync) the notification is delayed enough to strand object recovery
and hang dynamic-generator reconstruction.

Fix (F3): publish node death on the in-memory DEAD transition, posted onto the
GCS io_context and decoupled from the durable write. This relaxes
broadcast-after-durable ordering only for the node channel, which is safe
because node death is a terminal, restart-re-derivable transition (re-established
by health checks on GCS restart). It is not generalized to the actor channel,
whose state can resurrect across a GCS crash (and which already self-heals via
fetch-on-subscribe).

With the root cause fixed, remove the RocksDB soft-durability relaxation: all
GCS tables now use strict per-write WAL fsync (sync=true) again. Deletes
SoftDurableTables() and simplifies SyncWriteOptions().

Updates the test_dynamic_generator_reconstruction_nondeterministic comment to
reference the real fix.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
@jhasm
jhasm requested a review from a team as a code owner July 12, 2026 04:41

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request decouples GCS node-death notifications from the durable storage write, publishing them immediately upon the in-memory state transition to DEAD. This resolves a reconstruction race hang under slow durable backends like RocksDB. Consequently, the "soft-durability" workaround (skipping fsync) for certain tables in the RocksDB store client has been removed, restoring full synchronous fsync for all writes. The review feedback suggests optimizing SyncWriteOptions in RocksDbStoreClient by returning a const reference to a static rocksdb::WriteOptions instance to avoid unnecessary copy overhead on every write operation.

Avoid constructing a rocksdb::WriteOptions on every mutating GCS write. The
options are identical for all synchronous writes (sync=true), so return a
reference to a single thread-safe static instance instead of a fresh value.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 5d89fcb. Configure here.

Comment thread src/ray/gcs/gcs_node_manager.cc Resolved
jhasm and others added 2 commits July 12, 2026 05:05
…g tests

Address Cursor Bugbot: HandleUnregisterNode still published node death from
the NodeTable().Put completion callback, re-coupling graceful-unregistration
death detection to fsync latency. Apply the same publish-before-persist pattern
used in InternalOnNodeFailure (post the publish onto io_context, decoupled from
the durable write).

Add two GcsNodeManager unit tests that deterministically prove death is
broadcast before the durable write completes, for both the health-check
failure path (OnNodeFailure) and the graceful unregistration path
(HandleUnregisterNode).

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
Wrap OnNodeFailure call to satisfy clang-format 12.0.1 (microcheck lint).

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Jul 12, 2026
The on_done lambda captured node_id, but node_id stopped being used there
once the publish was moved ahead of the persist (F3). clang14 in CI builds
with -Werror,-Wunused-lambda-capture, failing the corebuild. Drop the capture.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
@rueian rueian self-assigned this Jul 13, 2026
}

TEST_F(GcsNodeManagerTest, TestNodeFailurePublishesDeathBeforePersist) {
// Regression test for the lost-wakeup fixed in #64187: a health-check node

@rueian rueian Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#64187 is probably not a correct reference. We never merged it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in 0081cde. You're right that #64187 was never merged; the fix actually lives in this PR. #64187 is the provenance/proof PR that demonstrates the lost-wakeup deterministically on the in-memory GCS (with injected timing), so I kept it only as an explicitly-labeled "root-cause proof, not merged" pointer and removed the misleading "fixed in #64187" wording from the test comment (and the secondary cross-reference in gcs_node_manager.cc). Happy to drop the #64187 mention entirely if you'd prefer no reference to an unmerged PR in the code.

Comment thread src/ray/gcs/gcs_node_manager.cc Outdated
// gate cluster-wide death detection on persist latency either. Posted onto
// io_context_ so it runs outside mutex_ (held here) yet independent of the
// persist completing.
boost::asio::post(io_context_, [this, node_id, node_info_delta]() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use io_context_.post.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0081cde — switched to io_context_.post(handler, "GcsNodeManager.PublishNodeDeathOnUnregister"). Using the instrumented member (instead of the boost::asio::post free function) restores the handler count/queueing/execution stats and a debug name, and matches the convention used elsewhere in gcs (e.g. gcs_placement_group_manager.cc, postable.h). Also dropped the now-unused <boost/asio/post.hpp> include.

Comment thread src/ray/gcs/gcs_node_manager.cc Outdated
//
// Posted onto io_context_ so it runs outside mutex_ (held by our caller
// OnNodeFailure) yet independent of the persist completing.
boost::asio::post(io_context_,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use io_context_.post.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0081cde — same change here, now io_context_.post(handler, "GcsNodeManager.PublishNodeDeathOnFailure").

…ance reference

- Replace boost::asio::post(io_context_, ...) with the instrumented
  io_context_.post(handler, name) member in both node-death publish sites
  (HandleUnregisterNode and InternalOnNodeFailure), matching the repo
  convention and restoring handler stats/naming. Drop the now-unused
  <boost/asio/post.hpp> include.
- Fix comments that referenced the unmerged provenance PR ray-project#64187: the
  regression test no longer claims the lost-wakeup was "fixed in ray-project#64187"
  (it is fixed in this PR); ray-project#64187 is now labeled as the unmerged
  root-cause proof where cited.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
@rueian

rueian commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

LGTM. Let's wait for tests to pass.

@rueian rueian added the go add ONLY when ready to merge, run all tests label Jul 28, 2026
@rueian
rueian enabled auto-merge (squash) July 28, 2026 00:16
@github-actions
github-actions Bot disabled auto-merge July 28, 2026 18:24
jhasm added a commit to jhasm/ray that referenced this pull request Jul 29, 2026
…acing

Tiers A-E showed the RocksDB delay surface does not reproduce the CI hang, so
vary the execution environment instead, holding the GCS configuration at exactly
what ray-project#64702 ships. Pressure is applied only during the death -> recovery phase.

Tier F (CPU / disk fsync contention) and tier G (memory pressure) add 10 arms.
Results: pressure makes the scenario slower but never wedged -- 1.6s baseline to
at worst ~16s, against a 90s arm timeout and the 180s pytest timeout the CI
tests exceeded. CPU is the dominant lever; disk fsync contention alone barely
registers, which further weakens any story resting on WAL fsync cost.

Notably F4 (soft-durability) is NOT protective: under identical pressure,
F4-on was no better than F4-off (F5 vs F3, G4 vs G3) and sometimes slower. That
independently undercuts keeping the workaround for any table.

Two whole-file replications on real RocksDB in the shipped config -- alone, and
concurrently with two other core test files to emulate --parallelism-per-worker
3 -- also passed the reconstruction tests.

Across seven tiers and ~60 process-isolated runs the only hanging configuration
remains A2 (node channel, publish gated behind a stalled write), which F3 fixes.

Since the failure only manifests in CI, add RAY_TESTING_REP64_TRACE=1, which
stamps each hop of the death path with a microsecond timestamp:

  REP64_TRACE gcs_inmemory_dead        gcs_node_manager.cc, DEAD transition
  REP64_TRACE gcs_publish_running      gcs_node_manager.cc, publish handler runs
  REP64_TRACE owner_received_node_dead core_worker.cc, on_node_change DEAD

Healthy local chain is ~0.5ms end to end, so a single CI run of the failing test
shows which hop is slow or which stamp never appears -- decisive, where local
reproduction has a demonstrated 0/60 hit rate.

Instrumentation only -- must not ship in a product fix.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
jhasm added a commit to jhasm/ray that referenced this pull request Jul 29, 2026
… CI job

Local reproduction of the ray-project#64702 rocksdb hang has a 0/60 hit rate across seven
tiers, so stop reproducing and measure where it actually happens: CI.

Wire three RAY_TESTING_* vars into the ":ray: core: rocksdb tests" step so that
job runs PR ray-project#64702's shipped configuration on top of this branch and stamps the
node-death path:

  RAY_TESTING_GCS_SOFT_DURABLE_TABLES=NONE      F4 removed, as ray-project#64702 does
  RAY_TESTING_GCS_NODE_PUBLISH_BEFORE_PERSIST=1 F3 node channel, as ray-project#64702 does
  RAY_TESTING_REP64_TRACE=1                     emit REP64_TRACE stamps

The trace is inert until a node actually dies, so it costs nothing on green runs
and captures automatically on the next failure. Together the stamps discriminate
between four distinct root causes in a single run: GCS never detected the death;
GCS detected but never ran the posted publish (F3's assumption violated);
published but never delivered to the owner (F3 cannot fix, F5 is designed for
it); or all three fast, meaning the hang is downstream of node death entirely.

src/ray/gcs/store_client/ is already a `rocksdb_tests` premerge trigger in
.buildkite/test.rules.txt, so this branch runs the job.

Also accept an explicit NONE sentinel for the soft-durable set, since an empty
env value does not survive every CI layer (bazel --test_env, docker -e)
reliably.

Verified locally with the exact CI variable combination: the four
reconstruction_nondeterministic variants pass and all three stamps are emitted.

PROVENANCE ONLY (DO NOT MERGE) -- the CI block must be deleted before any of
this lands as a product change.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
@edoakes
edoakes merged commit 72e28fd into ray-project:master Jul 29, 2026
3 checks passed
jhasm added a commit to jhasm/ray that referenced this pull request Jul 30, 2026
…a CI timeout

## Why are these changes needed?

`//python/ray/tests:test_generators` and
`//python/ray/dag:tests/experimental/test_compiled_graphs` are the two
worst offenders in the RocksDB GCS premerge job. Both are reported as
TIMEOUT/FLAKY at the *target* level, consuming the full Bazel budget on
every attempt, even though the underlying failure is a single test case.

Comparing premerge #70949, which ran the redis and rocksdb jobs on the
same commit, the suite totals are effectively identical (29,427s redis vs
29,644s rocksdb, +0.7%), so there is no general backend latency tax. The
damage is concentrated:

  target                                     redis    rocksdb  ratio
  //python/ray/dag:.../test_compiled_graphs  1193.6s  3600.2s  3.02  FLAKY
  //python/ray/tests:test_generators          416.7s   915.1s  2.20  TIMEOUT

Everything else is <=1.5x. And it is not a timing-margin problem: the
retry of the same rocksdb shard passed test_generators in 343.7s, i.e.
faster than redis. The distribution is bimodal, which points at a wedge
rather than a slowdown.

Reading the timeout dumps, both targets wedge on an unbounded wait that
has nothing to do with the assertion under test:

1. `Node._kill_process_type` waits with `timeout=None` whenever the caller
   passes `wait=True`, which `Cluster.remove_node` always does. SIGKILL
   cannot reap a process parked in uninterruptible sleep, and a process
   blocked in the fsync that the RocksDB GCS issues on every write is
   exactly that. So `ray_start_cluster` teardown blocks forever. In the
   failing test_generators attempt, pytest-timeout fired at 180s and
   teardown then absorbed the remaining ~700s until Bazel killed the
   target at 900s -- twice, because of `--flaky_test_attempts=2`. One
   test-case failure cost 30 minutes of CI and was reported as TIMEOUT
   instead of a clean FAILED-then-retry.

2. `run_string_as_driver` / `run_string_as_driver_stdout_stderr` call
   `proc.communicate()` with no timeout, so a driver that hangs during
   shutdown blocks the test forever. That is precisely what
   test_compiled_graphs::test_async_shutdown does, and it is the point
   where that target's timeout dump lands.

Neither wait is load-bearing: nothing depends on waiting *forever*, only
on waiting long enough.

## What this changes

- `Node._kill_process_type`: bound the post-SIGKILL wait at 30s even when
  `wait=True`, and log the pid and process type when it expires. Reaping
  is normally instantaneous, so this is inert in the healthy case; when it
  does expire, `Cluster.remove_node`'s existing `any_processes_alive()`
  assertion now reports a real error in seconds instead of hanging.
- `run_string_as_driver` and `run_string_as_driver_stdout_stderr`: add a
  `timeout` parameter defaulting to 300s. On expiry, kill the driver, log
  whatever it produced, and re-raise `TimeoutExpired`. 300s is well above
  the 180s pytest-timeout that already governs almost every caller, so no
  existing blocking driver should be affected. Pass `timeout=None` to
  restore the old behaviour.

This makes the failures bounded and attributable. It deliberately does
not attempt to fix the underlying test-case flake, which is still under
investigation and has not been reproduced outside CI (48/48 local runs of
the four `test_dynamic_generator_reconstruction_nondeterministic`
variants passed under both backends, with rocksdb showing no slowdown:
median 68.9s vs 70.2s for the in-memory GCS).

## Related issue number

Follow-up to ray-project#64702 (REP-64). Not a duplicate: no open PR touches these
two waits.

## Checks

- [x] I've signed off every commit (DCO).
- [x] I've made sure the tests are passing.

Tested locally:
  - `test_dynamic_generator_reconstruction_nondeterministic[None-False]`
    and `[None-True]` under `TEST_GCS_ROCKSDB=1`: 2 passed in 136.9s
  - `test_output.py -k test_disable_driver_logs_breakpoint`: 1 passed
  - direct exercise of all three `run_string_as_driver*` paths, including
    the new timeout path (kills the driver and raises `TimeoutExpired`)
  - `pre-commit run` clean on all three changed files

AI assistance (GitHub Copilot CLI) was used for the CI log analysis and to
draft these changes; every line was reviewed by me.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
edoakes pushed a commit that referenced this pull request Aug 3, 2026
…a CI timeout (#65109)

## Why are these changes needed?

`//python/ray/tests:test_generators` and
`//python/ray/dag:tests/experimental/test_compiled_graphs` are the two
worst offenders in the RocksDB GCS premerge job. Both are reported as
TIMEOUT/FLAKY at the *target* level, consuming the full Bazel budget on
every attempt, even though the underlying failure is a single test case.

Comparing premerge
[#70949](https://buildkite.com/ray-project/premerge/builds/70949), which
ran the redis and rocksdb jobs on the same commit, the suite totals are
effectively identical (**29,427s** redis vs **29,644s** rocksdb, +0.7%),
so there is no general backend latency tax. The damage is concentrated:

| target | redis | rocksdb | ratio | |
|---|---|---|---|---|
| `//python/ray/dag:.../test_compiled_graphs` | 1193.6s | 3600.2s |
3.02× | FLAKY |
| `//python/ray/tests:test_generators` | 416.7s | 915.1s | 2.20× |
TIMEOUT |
| `//python/ray/tests:test_multi_node_3` | 162.1s | 207.9s | 1.28× |
passing |

Everything else is ≤1.5×. And it is not a timing-margin problem: the
retry of the same rocksdb shard passed `test_generators` in **343.7s**,
i.e. *faster* than redis. The distribution is bimodal, which points at a
wedge rather than a slowdown.

Reading the timeout dumps, both targets wedge on an unbounded wait that
has nothing to do with the assertion under test:

1. `Node._kill_process_type` waits with `timeout=None` whenever the
caller passes `wait=True`, which `Cluster.remove_node` always does.
`SIGKILL` cannot reap a process parked in uninterruptible sleep, and a
process blocked in the `fsync` that the RocksDB GCS issues on every
write is exactly that. So `ray_start_cluster` teardown blocks forever.
In the failing `test_generators` attempt, pytest-timeout fired at 180s
and teardown then absorbed the remaining ~700s until Bazel killed the
target at 900s — twice, because of `--flaky_test_attempts=2`. One
test-case failure cost **30 minutes of CI** and was reported as TIMEOUT
instead of a clean FAILED-then-retry.

2. `run_string_as_driver` / `run_string_as_driver_stdout_stderr` call
`proc.communicate()` with no timeout, so a driver that hangs during
shutdown blocks the test forever. That is precisely what
`test_compiled_graphs::test_async_shutdown` does, and it is the point
where that target's timeout dump lands.

Neither wait is load-bearing: nothing depends on waiting *forever*, only
on waiting long enough.

## What this changes

- **`Node._kill_process_type`**: bound the post-SIGKILL wait at 30s even
when `wait=True`, and log the pid and process type when it expires.
Reaping is normally instantaneous, so this is inert in the healthy case;
when it does expire, `Cluster.remove_node`'s existing
`any_processes_alive()` assertion now reports a real error in seconds
instead of hanging.
- **`run_string_as_driver` / `run_string_as_driver_stdout_stderr`**: add
a `timeout` parameter defaulting to 300s. On expiry, kill the driver,
log whatever it produced, and re-raise `TimeoutExpired`. 300s is well
above the 180s pytest-timeout that already governs almost every caller,
so no existing blocking driver should be affected. Pass `timeout=None`
to restore the old behaviour.

This makes the failures **bounded and attributable**. It deliberately
does not attempt to fix the underlying test-case flake, which is still
under investigation and has not been reproduced outside CI — 48/48 local
runs of the four
`test_dynamic_generator_reconstruction_nondeterministic` variants passed
under both backends, with rocksdb showing no slowdown (median **68.9s**
vs **70.2s** for the in-memory GCS).

## Related issue number

Follow-up to #64702 (REP-64). Not a duplicate — I checked open PRs and
none touch these two waits.

## Checks

- [x] I've signed off every commit (DCO).
- [x] I've made sure the tests are passing.

Tested locally:
- `test_dynamic_generator_reconstruction_nondeterministic[None-False]`
and `[None-True]` under `TEST_GCS_ROCKSDB=1`: **2 passed in 136.9s**
- `test_output.py -k test_disable_driver_logs_breakpoint`: **1 passed**
- direct exercise of all three `run_string_as_driver*` paths, including
the new timeout path (kills the driver and raises `TimeoutExpired`)
- `pre-commit run` clean on all three changed files

AI assistance (GitHub Copilot CLI) was used for the CI log analysis and
to draft these changes; every line was reviewed by me.

---------

Signed-off-by: Santosh Jha <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Rueian <[email protected]>
goutamvenkat-anyscale pushed a commit to goutamvenkat-anyscale/ray that referenced this pull request Aug 3, 2026
…a CI timeout (ray-project#65109)

## Why are these changes needed?

`//python/ray/tests:test_generators` and
`//python/ray/dag:tests/experimental/test_compiled_graphs` are the two
worst offenders in the RocksDB GCS premerge job. Both are reported as
TIMEOUT/FLAKY at the *target* level, consuming the full Bazel budget on
every attempt, even though the underlying failure is a single test case.

Comparing premerge
[#70949](https://buildkite.com/ray-project/premerge/builds/70949), which
ran the redis and rocksdb jobs on the same commit, the suite totals are
effectively identical (**29,427s** redis vs **29,644s** rocksdb, +0.7%),
so there is no general backend latency tax. The damage is concentrated:

| target | redis | rocksdb | ratio | |
|---|---|---|---|---|
| `//python/ray/dag:.../test_compiled_graphs` | 1193.6s | 3600.2s |
3.02× | FLAKY |
| `//python/ray/tests:test_generators` | 416.7s | 915.1s | 2.20× |
TIMEOUT |
| `//python/ray/tests:test_multi_node_3` | 162.1s | 207.9s | 1.28× |
passing |

Everything else is ≤1.5×. And it is not a timing-margin problem: the
retry of the same rocksdb shard passed `test_generators` in **343.7s**,
i.e. *faster* than redis. The distribution is bimodal, which points at a
wedge rather than a slowdown.

Reading the timeout dumps, both targets wedge on an unbounded wait that
has nothing to do with the assertion under test:

1. `Node._kill_process_type` waits with `timeout=None` whenever the
caller passes `wait=True`, which `Cluster.remove_node` always does.
`SIGKILL` cannot reap a process parked in uninterruptible sleep, and a
process blocked in the `fsync` that the RocksDB GCS issues on every
write is exactly that. So `ray_start_cluster` teardown blocks forever.
In the failing `test_generators` attempt, pytest-timeout fired at 180s
and teardown then absorbed the remaining ~700s until Bazel killed the
target at 900s — twice, because of `--flaky_test_attempts=2`. One
test-case failure cost **30 minutes of CI** and was reported as TIMEOUT
instead of a clean FAILED-then-retry.

2. `run_string_as_driver` / `run_string_as_driver_stdout_stderr` call
`proc.communicate()` with no timeout, so a driver that hangs during
shutdown blocks the test forever. That is precisely what
`test_compiled_graphs::test_async_shutdown` does, and it is the point
where that target's timeout dump lands.

Neither wait is load-bearing: nothing depends on waiting *forever*, only
on waiting long enough.

## What this changes

- **`Node._kill_process_type`**: bound the post-SIGKILL wait at 30s even
when `wait=True`, and log the pid and process type when it expires.
Reaping is normally instantaneous, so this is inert in the healthy case;
when it does expire, `Cluster.remove_node`'s existing
`any_processes_alive()` assertion now reports a real error in seconds
instead of hanging.
- **`run_string_as_driver` / `run_string_as_driver_stdout_stderr`**: add
a `timeout` parameter defaulting to 300s. On expiry, kill the driver,
log whatever it produced, and re-raise `TimeoutExpired`. 300s is well
above the 180s pytest-timeout that already governs almost every caller,
so no existing blocking driver should be affected. Pass `timeout=None`
to restore the old behaviour.

This makes the failures **bounded and attributable**. It deliberately
does not attempt to fix the underlying test-case flake, which is still
under investigation and has not been reproduced outside CI — 48/48 local
runs of the four
`test_dynamic_generator_reconstruction_nondeterministic` variants passed
under both backends, with rocksdb showing no slowdown (median **68.9s**
vs **70.2s** for the in-memory GCS).

## Related issue number

Follow-up to ray-project#64702 (REP-64). Not a duplicate — I checked open PRs and
none touch these two waits.

## Checks

- [x] I've signed off every commit (DCO).
- [x] I've made sure the tests are passing.

Tested locally:
- `test_dynamic_generator_reconstruction_nondeterministic[None-False]`
and `[None-True]` under `TEST_GCS_ROCKSDB=1`: **2 passed in 136.9s**
- `test_output.py -k test_disable_driver_logs_breakpoint`: **1 passed**
- direct exercise of all three `run_string_as_driver*` paths, including
the new timeout path (kills the driver and raises `TimeoutExpired`)
- `pre-commit run` clean on all three changed files

AI assistance (GitHub Copilot CLI) was used for the CI log analysis and
to draft these changes; every line was reviewed by me.

---------

Signed-off-by: Santosh Jha <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Rueian <[email protected]>
Artimislyy pushed a commit to Artimislyy/ray that referenced this pull request Aug 11, 2026
…bility (REP-64) (ray-project#64702)

## Why are these changes needed?

Follow-up to ray-project#63657 (embedded RocksDB GCS backend, REP-64) that fixes
the underlying pub/sub issue at its root and removes the temporary
"soft-durability" workaround.

### Root cause (proven in ray-project#64187)

GCS published the node-death notification from **inside** the node table
write's completion callback — *publish-after-persist*. Owners of
objects/tasks react to a node's death **only** from that single pushed
pub/sub notification (`core_worker.cc` `on_node_change`, DEAD branch),
and once subscribed there is no periodic owner-side re-poll. Gating the
publish on the durable write therefore couples cluster-wide death
detection to persist latency: under a slow backend (the RocksDB GCS with
per-write `fsync`) the notification is delayed enough to strand object
recovery and hang
`test_dynamic_generator_reconstruction_nondeterministic[None-*]` in
`list(gen)`.

The provenance PR ray-project#64187 demonstrates this deterministically on the
**in-memory GCS** (timing injected), confirming the bug is in Ray core
and backend-agnostic.

### Fix (F3 — publish node death before persist)

Publish node death on the in-memory `DEAD` transition, posted onto the
GCS `io_context` and **decoupled** from the durable write. Applied to
**both** node-death paths:
- `GcsNodeManager::InternalOnNodeFailure` — health-check failure.
- `GcsNodeManager::HandleUnregisterNode` — graceful unregistration.

Properties:
- Relaxes broadcast-after-durable ordering **only for the node
channel**. Safe because node death is a terminal, restart-re-derivable
transition (re-established by health checks on GCS restart).
- **Not** generalized to the actor channel. This is *not* because the
actor channel has extra client-side self-healing that nodes lack — in
fact the two are symmetric: both fetch current state on subscribe and
re-fetch on GCS restart (`AsyncResubscribe`), and neither periodically
re-polls an already-established subscription. The difference is
durability semantics: actor state is **not** terminal and can
legitimately change (e.g. `RESTARTING` → `ALIVE`) and must survive a GCS
crash in durable order, so its publish must stay gated on persist. Node
liveness is terminal and re-derivable, so relaxing the ordering is safe.
- Keeps strict durability; smallest change that removes the proven cause
at its source.

We deliberately did **not** add the optional owner-side fallback re-poll
(F5 in ray-project#64187): the demonstrated failure is a *slow* publish, not a
*dropped* one, and F5 would add a permanent periodic GCS poll to every
owner for a hypothetical the pub/sub layer already makes unlikely. It
remains an isolated future option if a genuinely dropped notification is
ever observed.

### Remove the soft-durability workaround

With the root cause fixed, all GCS tables use strict per-write WAL
`fsync` (`sync = true`) again. Deletes `SoftDurableTables()` and
simplifies `RocksDbStoreClient::SyncWriteOptions()` (now returns a
`const &` to a shared constant, no per-write copy). The `NODE`/`ACTOR`
relaxation is no longer needed.

## How do we know this is safe?

The ordering guarantee (death is broadcast before, and independently of,
the durable write) is covered end-to-end and at the unit level:

- **End-to-end regression** —
`test_dynamic_generator_reconstruction_nondeterministic[None-*]`
(`python/ray/tests/test_generators.py`) is the exact scenario the bug
hangs. It passes on the RocksDB GCS with strict fsync and no
soft-durability, i.e. purely because of F3.
- **Deterministic unit ordering tests** (`gcs_node_manager_test.cc`,
new):
- `TestNodeFailurePublishesDeathBeforePersist` — health-check path:
after `OnNodeFailure`, running exactly one queued handler broadcasts
DEAD while the persist-completion callback has **not** yet run.
- `TestUnregisterNodePublishesDeathBeforePersist` — graceful-unregister
path: the DEAD publish fires before the persist-completion callback
(which is what writes the DEAD export event).
Both fail against the old publish-after-persist behavior and pass with
F3, so they lock in the fix.
- **Provenance proof** (ray-project#64187) demonstrates the same lost-wakeup on the
in-memory GCS with injected timing, independent of any storage backend.

Practically-possible scenarios and why they remain safe: (a) slow
persist — publish is already decoupled; (b) GCS restart before persist —
node death is re-derived by health checks and clients re-fetch on
resubscribe; (c) dropped push (not observed) — out of scope for this PR
and independently addressable via the F5 backstop without touching F3.

## Related issue number

- Root-cause analysis / proof: ray-project#64187
- Introduced the workaround this PR removes: ray-project#63657

## Checks

- [x] `gcs_node_manager_test` (incl. new ordering tests),
`node_manager_export_event_test` pass
- [x] `rocksdb_store_client_test`, `rocksdb_smoke_test` pass
- [x] `gcs_server_lib` + `rocksdb_store_client` build cleanly
- [x] clang-format / black / ruff / pydoclint clean

---------

Signed-off-by: Santosh Jha <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Rueian <[email protected]>
Artimislyy pushed a commit to Artimislyy/ray that referenced this pull request Aug 11, 2026
…a CI timeout (ray-project#65109)

## Why are these changes needed?

`//python/ray/tests:test_generators` and
`//python/ray/dag:tests/experimental/test_compiled_graphs` are the two
worst offenders in the RocksDB GCS premerge job. Both are reported as
TIMEOUT/FLAKY at the *target* level, consuming the full Bazel budget on
every attempt, even though the underlying failure is a single test case.

Comparing premerge
[#70949](https://buildkite.com/ray-project/premerge/builds/70949), which
ran the redis and rocksdb jobs on the same commit, the suite totals are
effectively identical (**29,427s** redis vs **29,644s** rocksdb, +0.7%),
so there is no general backend latency tax. The damage is concentrated:

| target | redis | rocksdb | ratio | |
|---|---|---|---|---|
| `//python/ray/dag:.../test_compiled_graphs` | 1193.6s | 3600.2s |
3.02× | FLAKY |
| `//python/ray/tests:test_generators` | 416.7s | 915.1s | 2.20× |
TIMEOUT |
| `//python/ray/tests:test_multi_node_3` | 162.1s | 207.9s | 1.28× |
passing |

Everything else is ≤1.5×. And it is not a timing-margin problem: the
retry of the same rocksdb shard passed `test_generators` in **343.7s**,
i.e. *faster* than redis. The distribution is bimodal, which points at a
wedge rather than a slowdown.

Reading the timeout dumps, both targets wedge on an unbounded wait that
has nothing to do with the assertion under test:

1. `Node._kill_process_type` waits with `timeout=None` whenever the
caller passes `wait=True`, which `Cluster.remove_node` always does.
`SIGKILL` cannot reap a process parked in uninterruptible sleep, and a
process blocked in the `fsync` that the RocksDB GCS issues on every
write is exactly that. So `ray_start_cluster` teardown blocks forever.
In the failing `test_generators` attempt, pytest-timeout fired at 180s
and teardown then absorbed the remaining ~700s until Bazel killed the
target at 900s — twice, because of `--flaky_test_attempts=2`. One
test-case failure cost **30 minutes of CI** and was reported as TIMEOUT
instead of a clean FAILED-then-retry.

2. `run_string_as_driver` / `run_string_as_driver_stdout_stderr` call
`proc.communicate()` with no timeout, so a driver that hangs during
shutdown blocks the test forever. That is precisely what
`test_compiled_graphs::test_async_shutdown` does, and it is the point
where that target's timeout dump lands.

Neither wait is load-bearing: nothing depends on waiting *forever*, only
on waiting long enough.

## What this changes

- **`Node._kill_process_type`**: bound the post-SIGKILL wait at 30s even
when `wait=True`, and log the pid and process type when it expires.
Reaping is normally instantaneous, so this is inert in the healthy case;
when it does expire, `Cluster.remove_node`'s existing
`any_processes_alive()` assertion now reports a real error in seconds
instead of hanging.
- **`run_string_as_driver` / `run_string_as_driver_stdout_stderr`**: add
a `timeout` parameter defaulting to 300s. On expiry, kill the driver,
log whatever it produced, and re-raise `TimeoutExpired`. 300s is well
above the 180s pytest-timeout that already governs almost every caller,
so no existing blocking driver should be affected. Pass `timeout=None`
to restore the old behaviour.

This makes the failures **bounded and attributable**. It deliberately
does not attempt to fix the underlying test-case flake, which is still
under investigation and has not been reproduced outside CI — 48/48 local
runs of the four
`test_dynamic_generator_reconstruction_nondeterministic` variants passed
under both backends, with rocksdb showing no slowdown (median **68.9s**
vs **70.2s** for the in-memory GCS).

## Related issue number

Follow-up to ray-project#64702 (REP-64). Not a duplicate — I checked open PRs and
none touch these two waits.

## Checks

- [x] I've signed off every commit (DCO).
- [x] I've made sure the tests are passing.

Tested locally:
- `test_dynamic_generator_reconstruction_nondeterministic[None-False]`
and `[None-True]` under `TEST_GCS_ROCKSDB=1`: **2 passed in 136.9s**
- `test_output.py -k test_disable_driver_logs_breakpoint`: **1 passed**
- direct exercise of all three `run_string_as_driver*` paths, including
the new timeout path (kills the driver and raises `TimeoutExpired`)
- `pre-commit run` clean on all three changed files

AI assistance (GitHub Copilot CLI) was used for the CI log analysis and
to draft these changes; every line was reviewed by me.

---------

Signed-off-by: Santosh Jha <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Rueian <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…bility (REP-64) (ray-project#64702)

## Why are these changes needed?

Follow-up to ray-project#63657 (embedded RocksDB GCS backend, REP-64) that fixes
the underlying pub/sub issue at its root and removes the temporary
"soft-durability" workaround.

### Root cause (proven in ray-project#64187)

GCS published the node-death notification from **inside** the node table
write's completion callback — *publish-after-persist*. Owners of
objects/tasks react to a node's death **only** from that single pushed
pub/sub notification (`core_worker.cc` `on_node_change`, DEAD branch),
and once subscribed there is no periodic owner-side re-poll. Gating the
publish on the durable write therefore couples cluster-wide death
detection to persist latency: under a slow backend (the RocksDB GCS with
per-write `fsync`) the notification is delayed enough to strand object
recovery and hang
`test_dynamic_generator_reconstruction_nondeterministic[None-*]` in
`list(gen)`.

The provenance PR ray-project#64187 demonstrates this deterministically on the
**in-memory GCS** (timing injected), confirming the bug is in Ray core
and backend-agnostic.

### Fix (F3 — publish node death before persist)

Publish node death on the in-memory `DEAD` transition, posted onto the
GCS `io_context` and **decoupled** from the durable write. Applied to
**both** node-death paths:
- `GcsNodeManager::InternalOnNodeFailure` — health-check failure.
- `GcsNodeManager::HandleUnregisterNode` — graceful unregistration.

Properties:
- Relaxes broadcast-after-durable ordering **only for the node
channel**. Safe because node death is a terminal, restart-re-derivable
transition (re-established by health checks on GCS restart).
- **Not** generalized to the actor channel. This is *not* because the
actor channel has extra client-side self-healing that nodes lack — in
fact the two are symmetric: both fetch current state on subscribe and
re-fetch on GCS restart (`AsyncResubscribe`), and neither periodically
re-polls an already-established subscription. The difference is
durability semantics: actor state is **not** terminal and can
legitimately change (e.g. `RESTARTING` → `ALIVE`) and must survive a GCS
crash in durable order, so its publish must stay gated on persist. Node
liveness is terminal and re-derivable, so relaxing the ordering is safe.
- Keeps strict durability; smallest change that removes the proven cause
at its source.

We deliberately did **not** add the optional owner-side fallback re-poll
(F5 in ray-project#64187): the demonstrated failure is a *slow* publish, not a
*dropped* one, and F5 would add a permanent periodic GCS poll to every
owner for a hypothetical the pub/sub layer already makes unlikely. It
remains an isolated future option if a genuinely dropped notification is
ever observed.

### Remove the soft-durability workaround

With the root cause fixed, all GCS tables use strict per-write WAL
`fsync` (`sync = true`) again. Deletes `SoftDurableTables()` and
simplifies `RocksDbStoreClient::SyncWriteOptions()` (now returns a
`const &` to a shared constant, no per-write copy). The `NODE`/`ACTOR`
relaxation is no longer needed.

## How do we know this is safe?

The ordering guarantee (death is broadcast before, and independently of,
the durable write) is covered end-to-end and at the unit level:

- **End-to-end regression** —
`test_dynamic_generator_reconstruction_nondeterministic[None-*]`
(`python/ray/tests/test_generators.py`) is the exact scenario the bug
hangs. It passes on the RocksDB GCS with strict fsync and no
soft-durability, i.e. purely because of F3.
- **Deterministic unit ordering tests** (`gcs_node_manager_test.cc`,
new):
- `TestNodeFailurePublishesDeathBeforePersist` — health-check path:
after `OnNodeFailure`, running exactly one queued handler broadcasts
DEAD while the persist-completion callback has **not** yet run.
- `TestUnregisterNodePublishesDeathBeforePersist` — graceful-unregister
path: the DEAD publish fires before the persist-completion callback
(which is what writes the DEAD export event).
Both fail against the old publish-after-persist behavior and pass with
F3, so they lock in the fix.
- **Provenance proof** (ray-project#64187) demonstrates the same lost-wakeup on the
in-memory GCS with injected timing, independent of any storage backend.

Practically-possible scenarios and why they remain safe: (a) slow
persist — publish is already decoupled; (b) GCS restart before persist —
node death is re-derived by health checks and clients re-fetch on
resubscribe; (c) dropped push (not observed) — out of scope for this PR
and independently addressable via the F5 backstop without touching F3.

## Related issue number

- Root-cause analysis / proof: ray-project#64187
- Introduced the workaround this PR removes: ray-project#63657

## Checks

- [x] `gcs_node_manager_test` (incl. new ordering tests),
`node_manager_export_event_test` pass
- [x] `rocksdb_store_client_test`, `rocksdb_smoke_test` pass
- [x] `gcs_server_lib` + `rocksdb_store_client` build cleanly
- [x] clang-format / black / ruff / pydoclint clean

---------

Signed-off-by: Santosh Jha <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Rueian <[email protected]>
Signed-off-by: 400Ping <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…a CI timeout (ray-project#65109)

## Why are these changes needed?

`//python/ray/tests:test_generators` and
`//python/ray/dag:tests/experimental/test_compiled_graphs` are the two
worst offenders in the RocksDB GCS premerge job. Both are reported as
TIMEOUT/FLAKY at the *target* level, consuming the full Bazel budget on
every attempt, even though the underlying failure is a single test case.

Comparing premerge
[#70949](https://buildkite.com/ray-project/premerge/builds/70949), which
ran the redis and rocksdb jobs on the same commit, the suite totals are
effectively identical (**29,427s** redis vs **29,644s** rocksdb, +0.7%),
so there is no general backend latency tax. The damage is concentrated:

| target | redis | rocksdb | ratio | |
|---|---|---|---|---|
| `//python/ray/dag:.../test_compiled_graphs` | 1193.6s | 3600.2s |
3.02× | FLAKY |
| `//python/ray/tests:test_generators` | 416.7s | 915.1s | 2.20× |
TIMEOUT |
| `//python/ray/tests:test_multi_node_3` | 162.1s | 207.9s | 1.28× |
passing |

Everything else is ≤1.5×. And it is not a timing-margin problem: the
retry of the same rocksdb shard passed `test_generators` in **343.7s**,
i.e. *faster* than redis. The distribution is bimodal, which points at a
wedge rather than a slowdown.

Reading the timeout dumps, both targets wedge on an unbounded wait that
has nothing to do with the assertion under test:

1. `Node._kill_process_type` waits with `timeout=None` whenever the
caller passes `wait=True`, which `Cluster.remove_node` always does.
`SIGKILL` cannot reap a process parked in uninterruptible sleep, and a
process blocked in the `fsync` that the RocksDB GCS issues on every
write is exactly that. So `ray_start_cluster` teardown blocks forever.
In the failing `test_generators` attempt, pytest-timeout fired at 180s
and teardown then absorbed the remaining ~700s until Bazel killed the
target at 900s — twice, because of `--flaky_test_attempts=2`. One
test-case failure cost **30 minutes of CI** and was reported as TIMEOUT
instead of a clean FAILED-then-retry.

2. `run_string_as_driver` / `run_string_as_driver_stdout_stderr` call
`proc.communicate()` with no timeout, so a driver that hangs during
shutdown blocks the test forever. That is precisely what
`test_compiled_graphs::test_async_shutdown` does, and it is the point
where that target's timeout dump lands.

Neither wait is load-bearing: nothing depends on waiting *forever*, only
on waiting long enough.

## What this changes

- **`Node._kill_process_type`**: bound the post-SIGKILL wait at 30s even
when `wait=True`, and log the pid and process type when it expires.
Reaping is normally instantaneous, so this is inert in the healthy case;
when it does expire, `Cluster.remove_node`'s existing
`any_processes_alive()` assertion now reports a real error in seconds
instead of hanging.
- **`run_string_as_driver` / `run_string_as_driver_stdout_stderr`**: add
a `timeout` parameter defaulting to 300s. On expiry, kill the driver,
log whatever it produced, and re-raise `TimeoutExpired`. 300s is well
above the 180s pytest-timeout that already governs almost every caller,
so no existing blocking driver should be affected. Pass `timeout=None`
to restore the old behaviour.

This makes the failures **bounded and attributable**. It deliberately
does not attempt to fix the underlying test-case flake, which is still
under investigation and has not been reproduced outside CI — 48/48 local
runs of the four
`test_dynamic_generator_reconstruction_nondeterministic` variants passed
under both backends, with rocksdb showing no slowdown (median **68.9s**
vs **70.2s** for the in-memory GCS).

## Related issue number

Follow-up to ray-project#64702 (REP-64). Not a duplicate — I checked open PRs and
none touch these two waits.

## Checks

- [x] I've signed off every commit (DCO).
- [x] I've made sure the tests are passing.

Tested locally:
- `test_dynamic_generator_reconstruction_nondeterministic[None-False]`
and `[None-True]` under `TEST_GCS_ROCKSDB=1`: **2 passed in 136.9s**
- `test_output.py -k test_disable_driver_logs_breakpoint`: **1 passed**
- direct exercise of all three `run_string_as_driver*` paths, including
the new timeout path (kills the driver and raises `TimeoutExpired`)
- `pre-commit run` clean on all three changed files

AI assistance (GitHub Copilot CLI) was used for the CI log analysis and
to draft these changes; every line was reviewed by me.

---------

Signed-off-by: Santosh Jha <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Rueian <[email protected]>
Signed-off-by: 400Ping <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…bility (REP-64) (ray-project#64702)

## Why are these changes needed?

Follow-up to ray-project#63657 (embedded RocksDB GCS backend, REP-64) that fixes
the underlying pub/sub issue at its root and removes the temporary
"soft-durability" workaround.

### Root cause (proven in ray-project#64187)

GCS published the node-death notification from **inside** the node table
write's completion callback — *publish-after-persist*. Owners of
objects/tasks react to a node's death **only** from that single pushed
pub/sub notification (`core_worker.cc` `on_node_change`, DEAD branch),
and once subscribed there is no periodic owner-side re-poll. Gating the
publish on the durable write therefore couples cluster-wide death
detection to persist latency: under a slow backend (the RocksDB GCS with
per-write `fsync`) the notification is delayed enough to strand object
recovery and hang
`test_dynamic_generator_reconstruction_nondeterministic[None-*]` in
`list(gen)`.

The provenance PR ray-project#64187 demonstrates this deterministically on the
**in-memory GCS** (timing injected), confirming the bug is in Ray core
and backend-agnostic.

### Fix (F3 — publish node death before persist)

Publish node death on the in-memory `DEAD` transition, posted onto the
GCS `io_context` and **decoupled** from the durable write. Applied to
**both** node-death paths:
- `GcsNodeManager::InternalOnNodeFailure` — health-check failure.
- `GcsNodeManager::HandleUnregisterNode` — graceful unregistration.

Properties:
- Relaxes broadcast-after-durable ordering **only for the node
channel**. Safe because node death is a terminal, restart-re-derivable
transition (re-established by health checks on GCS restart).
- **Not** generalized to the actor channel. This is *not* because the
actor channel has extra client-side self-healing that nodes lack — in
fact the two are symmetric: both fetch current state on subscribe and
re-fetch on GCS restart (`AsyncResubscribe`), and neither periodically
re-polls an already-established subscription. The difference is
durability semantics: actor state is **not** terminal and can
legitimately change (e.g. `RESTARTING` → `ALIVE`) and must survive a GCS
crash in durable order, so its publish must stay gated on persist. Node
liveness is terminal and re-derivable, so relaxing the ordering is safe.
- Keeps strict durability; smallest change that removes the proven cause
at its source.

We deliberately did **not** add the optional owner-side fallback re-poll
(F5 in ray-project#64187): the demonstrated failure is a *slow* publish, not a
*dropped* one, and F5 would add a permanent periodic GCS poll to every
owner for a hypothetical the pub/sub layer already makes unlikely. It
remains an isolated future option if a genuinely dropped notification is
ever observed.

### Remove the soft-durability workaround

With the root cause fixed, all GCS tables use strict per-write WAL
`fsync` (`sync = true`) again. Deletes `SoftDurableTables()` and
simplifies `RocksDbStoreClient::SyncWriteOptions()` (now returns a
`const &` to a shared constant, no per-write copy). The `NODE`/`ACTOR`
relaxation is no longer needed.

## How do we know this is safe?

The ordering guarantee (death is broadcast before, and independently of,
the durable write) is covered end-to-end and at the unit level:

- **End-to-end regression** —
`test_dynamic_generator_reconstruction_nondeterministic[None-*]`
(`python/ray/tests/test_generators.py`) is the exact scenario the bug
hangs. It passes on the RocksDB GCS with strict fsync and no
soft-durability, i.e. purely because of F3.
- **Deterministic unit ordering tests** (`gcs_node_manager_test.cc`,
new):
- `TestNodeFailurePublishesDeathBeforePersist` — health-check path:
after `OnNodeFailure`, running exactly one queued handler broadcasts
DEAD while the persist-completion callback has **not** yet run.
- `TestUnregisterNodePublishesDeathBeforePersist` — graceful-unregister
path: the DEAD publish fires before the persist-completion callback
(which is what writes the DEAD export event).
Both fail against the old publish-after-persist behavior and pass with
F3, so they lock in the fix.
- **Provenance proof** (ray-project#64187) demonstrates the same lost-wakeup on the
in-memory GCS with injected timing, independent of any storage backend.

Practically-possible scenarios and why they remain safe: (a) slow
persist — publish is already decoupled; (b) GCS restart before persist —
node death is re-derived by health checks and clients re-fetch on
resubscribe; (c) dropped push (not observed) — out of scope for this PR
and independently addressable via the F5 backstop without touching F3.

## Related issue number

- Root-cause analysis / proof: ray-project#64187
- Introduced the workaround this PR removes: ray-project#63657

## Checks

- [x] `gcs_node_manager_test` (incl. new ordering tests),
`node_manager_export_event_test` pass
- [x] `rocksdb_store_client_test`, `rocksdb_smoke_test` pass
- [x] `gcs_server_lib` + `rocksdb_store_client` build cleanly
- [x] clang-format / black / ruff / pydoclint clean

---------

Signed-off-by: Santosh Jha <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Rueian <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…a CI timeout (ray-project#65109)

## Why are these changes needed?

`//python/ray/tests:test_generators` and
`//python/ray/dag:tests/experimental/test_compiled_graphs` are the two
worst offenders in the RocksDB GCS premerge job. Both are reported as
TIMEOUT/FLAKY at the *target* level, consuming the full Bazel budget on
every attempt, even though the underlying failure is a single test case.

Comparing premerge
[#70949](https://buildkite.com/ray-project/premerge/builds/70949), which
ran the redis and rocksdb jobs on the same commit, the suite totals are
effectively identical (**29,427s** redis vs **29,644s** rocksdb, +0.7%),
so there is no general backend latency tax. The damage is concentrated:

| target | redis | rocksdb | ratio | |
|---|---|---|---|---|
| `//python/ray/dag:.../test_compiled_graphs` | 1193.6s | 3600.2s |
3.02× | FLAKY |
| `//python/ray/tests:test_generators` | 416.7s | 915.1s | 2.20× |
TIMEOUT |
| `//python/ray/tests:test_multi_node_3` | 162.1s | 207.9s | 1.28× |
passing |

Everything else is ≤1.5×. And it is not a timing-margin problem: the
retry of the same rocksdb shard passed `test_generators` in **343.7s**,
i.e. *faster* than redis. The distribution is bimodal, which points at a
wedge rather than a slowdown.

Reading the timeout dumps, both targets wedge on an unbounded wait that
has nothing to do with the assertion under test:

1. `Node._kill_process_type` waits with `timeout=None` whenever the
caller passes `wait=True`, which `Cluster.remove_node` always does.
`SIGKILL` cannot reap a process parked in uninterruptible sleep, and a
process blocked in the `fsync` that the RocksDB GCS issues on every
write is exactly that. So `ray_start_cluster` teardown blocks forever.
In the failing `test_generators` attempt, pytest-timeout fired at 180s
and teardown then absorbed the remaining ~700s until Bazel killed the
target at 900s — twice, because of `--flaky_test_attempts=2`. One
test-case failure cost **30 minutes of CI** and was reported as TIMEOUT
instead of a clean FAILED-then-retry.

2. `run_string_as_driver` / `run_string_as_driver_stdout_stderr` call
`proc.communicate()` with no timeout, so a driver that hangs during
shutdown blocks the test forever. That is precisely what
`test_compiled_graphs::test_async_shutdown` does, and it is the point
where that target's timeout dump lands.

Neither wait is load-bearing: nothing depends on waiting *forever*, only
on waiting long enough.

## What this changes

- **`Node._kill_process_type`**: bound the post-SIGKILL wait at 30s even
when `wait=True`, and log the pid and process type when it expires.
Reaping is normally instantaneous, so this is inert in the healthy case;
when it does expire, `Cluster.remove_node`'s existing
`any_processes_alive()` assertion now reports a real error in seconds
instead of hanging.
- **`run_string_as_driver` / `run_string_as_driver_stdout_stderr`**: add
a `timeout` parameter defaulting to 300s. On expiry, kill the driver,
log whatever it produced, and re-raise `TimeoutExpired`. 300s is well
above the 180s pytest-timeout that already governs almost every caller,
so no existing blocking driver should be affected. Pass `timeout=None`
to restore the old behaviour.

This makes the failures **bounded and attributable**. It deliberately
does not attempt to fix the underlying test-case flake, which is still
under investigation and has not been reproduced outside CI — 48/48 local
runs of the four
`test_dynamic_generator_reconstruction_nondeterministic` variants passed
under both backends, with rocksdb showing no slowdown (median **68.9s**
vs **70.2s** for the in-memory GCS).

## Related issue number

Follow-up to ray-project#64702 (REP-64). Not a duplicate — I checked open PRs and
none touch these two waits.

## Checks

- [x] I've signed off every commit (DCO).
- [x] I've made sure the tests are passing.

Tested locally:
- `test_dynamic_generator_reconstruction_nondeterministic[None-False]`
and `[None-True]` under `TEST_GCS_ROCKSDB=1`: **2 passed in 136.9s**
- `test_output.py -k test_disable_driver_logs_breakpoint`: **1 passed**
- direct exercise of all three `run_string_as_driver*` paths, including
the new timeout path (kills the driver and raises `TimeoutExpired`)
- `pre-commit run` clean on all three changed files

AI assistance (GitHub Copilot CLI) was used for the CI log analysis and
to draft these changes; every line was reviewed by me.

---------

Signed-off-by: Santosh Jha <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Rueian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants