Repository navigation
[DO NOT MERGE][core][gcs] Provenance: node-death lost-wakeup hangs generator reconstruction (REP-64) - #64187
[DO NOT MERGE][core][gcs] Provenance: node-death lost-wakeup hangs generator reconstruction (REP-64)#64187jhasm wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces documentation, test scripts, and test files to analyze and reproduce a permanent hang during generator reconstruction (REP-64), alongside test-only C++ timing injection knobs and prototypes for two fix candidates (F3 and F5). Feedback on these changes highlights two key improvement opportunities: first, the periodic fallback mechanism in core_worker.cc (F5) should be optimized using an in-flight flag and a set of processed nodes to prevent overlapping GCS queries and redundant processing; second, the 0ms boost::asio::deadline_timer used to defer execution in gcs_node_manager.cc should be replaced with boost::asio::post for better efficiency.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
426ae2b to
77d1337
Compare
…cation timing Add test-only, environment-variable-gated instrumentation used to deterministically reproduce, isolate, and fix-validate a Ray-core node-death lost-wakeup that hangs dynamic-generator reconstruction. All knobs are inert unless the corresponding RAY_TESTING_* env var is set, so default behavior is identical to upstream. They are read via std::getenv only in the GCS / core worker so the raylet/core-worker config validator never sees them. RAY_TESTING_GCS_NODE_PUBLISH_DELAY_MS delay only the node-death publish RAY_TESTING_GCS_NODE_PERSIST_DELAY_MS delay the persist on_done (slow fsync) RAY_TESTING_GCS_NODE_PUBLISH_BEFORE_PERSIST F3: publish on the in-memory transition RAY_TESTING_GCS_ACTOR_PUBLISH_DELAY_MS delay only the actor-death publish RAY_TESTING_ENABLE_NODE_DEATH_FALLBACK F5: owner-side re-poll of GCS DEAD nodes These are reproduction instrumentation and must NOT ship in the product fix. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: Santosh Jha <[email protected]>
…ings A single process-isolated harness (in-memory GCS, no RocksDB) with one arm per claim proves the node-death lost-wakeup and validates two independent fixes: node_publish_delayed node channel is the load-bearing trigger -> HANG actor_publish_delayed actor channel self-heals -> FAST node_persist_delayed reproduces the real bug (slow fsync) -> HANG node_persist_delayed_f3 F3 publish-before-persist -> FAST node_publish_delayed_f5 F5 owner-side re-poll fallback -> FAST REP64.md: root cause (code-cited), the three fixes as one invariant trade-off, recommendation, and build/run instructions with expected verdicts. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: Santosh Jha <[email protected]>
77d1337 to
41e4814
Compare
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
Commenting to keep this PR from being closed |
…flag Per review feedback: the NODE/ACTOR soft-durability set is a fundamental correctness+performance property of the RocksDB GCS backend, not an operator-tunable knob. Replace the gcs_rocksdb_soft_durability_tables config flag with a documented, hardcoded constant (SoftDurableTables()) in rocksdb_store_client.cc, and drop the ctor param + member that plumbed it through. Behavior is unchanged (NODE, ACTOR remain soft-durable). Also document the follow-up: soft durability is a workaround for a publish-after-persist race rooted in the GCS core code (ray-project#64187); it should be revisited/removed once that root cause is fixed. Co-authored-by: Copilot <[email protected]> Signed-off-by: Santosh Jha <[email protected]>
…nce (REP-64) (#63657) Implements the embedded RocksDB storage backend for GCS fault tolerance proposed in [REP-64](ray-project/enhancements#64). Today, GCS fault tolerance requires an external Redis instance. This PR adds RocksDB as a second backend, selected via `RAY_gcs_storage=rocksdb` and `RAY_gcs_storage_path=<path-on-pvc>`. The recovery model is identical to Redis-backed FT — GCS restarts, reads state from local disk, workers reconnect — only the location of persisted state differs. KubeRay operator changes (the `gcsFaultToleranceOptions.backend: rocksdb` field that auto-manages PVCs) are explicitly out of scope here and will land in `ray-project/kuberay`. ## Why a new PR This is a streamlined version of the POC at #63032. That PR carries the full evidence dossier (phase reports, kill-9 harness, k8s test harness, microbench results — ~10K lines of supporting material) which served its purpose during design review. For the merge PR, only the production code is included; #63032 remains the reference for per-claim reproducibility evidence and the @andrewsykim review thread. ## What's in this PR | Commit | What | |---|---| | 1 | `bazel/rocksdb.BUILD` + `bazel/ray_deps_setup.bzl` — add RocksDB 9.11.2 as a third-party dependency (static-only, no compression / jemalloc / tools, built via `rules_foreign_cc`). | | 2 | `src/ray/gcs/store_client/rocksdb_store_client.{h,cc}` + 4 tests + `storage_microbench` binary. RocksDB I/O runs on a `boost::asio::thread_pool` (keeping the WAL fsync off the GCS event loop) with per-key `boost::asio::strand`s bucketed by `hash(table, key)` for submission-order ordering. `WriteOptions::sync = true` on every mutating call. | | 3 | Wire it into `GcsServer` (factory dispatch in `InitClusterStorageBackend` + `InitKVManager`, 3 new config flags, `node.py` session-name sidecar for restart recovery, raylet startup wait bumped 30 → 60s on rocksdb). | | 4 | `TEST_GCS_ROCKSDB=1` fixture toggle in `python/ray/tests/conftest.py` — existing cluster fixtures auto-dispatch. | | 5 | New postmerge buildkite jobs `:ray: core: rocksdb tests` + `:ray: core: out of disk rocksdb tests`, mirroring the Redis FT jobs. | | 6 | Docs: new K8s setup page (`kuberay-gcs-rocksdb-ft.md`) + an "Embedded RocksDB backend" section in `gcs.rst`. | | 7 | Review follow-ups: remove the inline execution path and the `gcs_rocksdb_async_offload` toggle so RocksDB I/O always offloads; make `GetNextJobIDSync` private (tests drive it through the public `AsyncGetNextJobID`); extract the rocksdb session-name marker logic in `node.py` into its own helper; collapse `storage_microbench` to a single `rocksdb` backend; make the soft-durable table set a hardcoded, documented constant (`SoftDurableTables()`) instead of the `gcs_rocksdb_soft_durability_tables` config flag, since it's a fixed design property rather than an operator knob. | Aggregate: **+2,973 / -20 across 26 files**. All commits signed off (DCO). ## REP-64 acceptance criteria 1. Release tests pass with `RAY_gcs_storage=rocksdb` — the new postmerge job runs the standard test suite under the rocksdb backend. 2. New postmerge CI job mirroring Redis GCS FT — ✓ commit 5. 3. Scale tests at parity with Redis — covered by the postmerge job's `//python/ray/tests/...` target set (includes `test_many_actors.py`). 4. Serve chaos passes — covered by the postmerge job. ## Tests C++ unit tests under `src/ray/gcs/store_client/tests/`: - `rocksdb_smoke_test` — Bazel-integration sanity (open / put / get). - `rocksdb_store_client_test` — RocksDb-specific scenarios: recovery across close+reopen, cluster-id marker fail-fast, pool-thread write roundtrip. - `rocksdb_parity_test` — runs the full `StoreClientTestBase` suite (same fixture as `in_memory_store_client_test` and `redis_store_client_test`). - `rocksdb_concurrency_test` — per-key strand correctness + JobID-counter atomicity under N-thread contention. Python integration coverage: the existing `//python/ray/tests/...` / `//python/ray/dag/...` / `//python/ray/autoscaler/v2/...` suites run under `TEST_GCS_ROCKSDB=1` via the new buildkite jobs. > The local k3d cluster recovery test harness from the POC branch was repeated on this branch. Results and reproduction instructions are in doc [REP-64 RocksDB GCS — Kubernetes Recovery: Evidence of Correctness & Reproduction Guide](https://docs.google.com/document/d/1sd6S1E5-kgOSbMjefjIkvkZztwsMeUikscOqbZHmUSA/edit?usp=sharing) ## Out of scope (follow-ons) - KubeRay operator support for `gcsFaultToleranceOptions.backend: rocksdb` — separate `ray-project/kuberay` PR. - PVC stale-data fail-fast via K8s downward API (`RAY_CLUSTER_ID` env-injected cluster-id marker) — `RocksDbStoreClient` already supports the check; needs the KubeRay-side plumbing. - Remove the soft-durability workaround. The soft-durability relaxation added here (skipping the per-write WAL fsync on the NODE/ACTOR death-notification tables, now a hardcoded `SoftDurableTables()` constant) works around a GCS-core object-reconstruction / task-resubmission race that RocksDB's fsync latency widens. That race was proven to be rooted in the GCS code (see #64187). A follow-on PR will fix the root cause in GCS and remove this workaround so every table keeps strict per-write fsync. - macOS / Windows support (targets currently gated on `@platforms//os:linux`). ## References - REP-64: ray-project/enhancements#64 - POC PR with full evidence dossier and design-review history: #63032 - Bug provenance: #64187 --------- Signed-off-by: Santosh Jha <[email protected]> Signed-off-by: Rueian <[email protected]> Signed-off-by: Edward Oakes <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Rueian <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Edward Oakes <[email protected]>
…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]>
…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]>
… 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]>
…bility (REP-64) (#64702) ## 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** (#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: #64187 - Introduced the workaround this PR removes: #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]>
…CI run Build ray-project#51041 never reached the rocksdb job: //src/ray/gcs:gcs_node_manager failed to compile, and every downstream target ("core: cpp tests", "core: python tests", "core: redis tests", test_exported_symbols_unix) reported FAILED TO BUILD off that one error. src/ray/gcs/gcs_node_manager.cc:762:24: error: lambda capture 'node_id' is not used [-Werror,-Wunused-lambda-capture] Cause: node_id used to be read inside on_done, by the PublishNodeInfoToPubsub(node_id, node_info_delta) call. The trace commit moved that call into the publish_node_death closure, which captures node_id itself, so the capture in on_done/complete became dead. The local toolchain here is gcc, which does not implement -Wunused-lambda-capture at all, so the local build was clean; CI uses clang-14, which rejects it. Drop the dead capture from both on_done and its inner complete lambda. Also fix the three self-inflicted lint failures from the same commit: - clang_format: reformat the new/edited GCS sources - pre_commit: black on test_rep64_rocksdb_delays.py - test_coverage: ci/pipeline/check-test-run.py requires every python/**/tests/test_*.py to be reachable from a py_test target. Register both REP-64 harnesses, tagged "manual" so CI never actually runs them -- they stall the store client and apply CPU/disk/memory pressure, and are driven by run_rep64*.sh directly. Verified locally: gcs_node_manager builds, pre-commit black/clang-format/ buildifier pass, and ci/pipeline/check-test-run.py exits clean. No behaviour change to the trace instrumentation itself. PROVENANCE ONLY (DO NOT MERGE). Co-authored-by: Copilot <[email protected]> Signed-off-by: Santosh Jha <[email protected]>
…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]>
…nce (REP-64) (ray-project#63657) Implements the embedded RocksDB storage backend for GCS fault tolerance proposed in [REP-64](ray-project/enhancements#64). Today, GCS fault tolerance requires an external Redis instance. This PR adds RocksDB as a second backend, selected via `RAY_gcs_storage=rocksdb` and `RAY_gcs_storage_path=<path-on-pvc>`. The recovery model is identical to Redis-backed FT — GCS restarts, reads state from local disk, workers reconnect — only the location of persisted state differs. KubeRay operator changes (the `gcsFaultToleranceOptions.backend: rocksdb` field that auto-manages PVCs) are explicitly out of scope here and will land in `ray-project/kuberay`. ## Why a new PR This is a streamlined version of the POC at ray-project#63032. That PR carries the full evidence dossier (phase reports, kill-9 harness, k8s test harness, microbench results — ~10K lines of supporting material) which served its purpose during design review. For the merge PR, only the production code is included; ray-project#63032 remains the reference for per-claim reproducibility evidence and the @andrewsykim review thread. ## What's in this PR | Commit | What | |---|---| | 1 | `bazel/rocksdb.BUILD` + `bazel/ray_deps_setup.bzl` — add RocksDB 9.11.2 as a third-party dependency (static-only, no compression / jemalloc / tools, built via `rules_foreign_cc`). | | 2 | `src/ray/gcs/store_client/rocksdb_store_client.{h,cc}` + 4 tests + `storage_microbench` binary. RocksDB I/O runs on a `boost::asio::thread_pool` (keeping the WAL fsync off the GCS event loop) with per-key `boost::asio::strand`s bucketed by `hash(table, key)` for submission-order ordering. `WriteOptions::sync = true` on every mutating call. | | 3 | Wire it into `GcsServer` (factory dispatch in `InitClusterStorageBackend` + `InitKVManager`, 3 new config flags, `node.py` session-name sidecar for restart recovery, raylet startup wait bumped 30 → 60s on rocksdb). | | 4 | `TEST_GCS_ROCKSDB=1` fixture toggle in `python/ray/tests/conftest.py` — existing cluster fixtures auto-dispatch. | | 5 | New postmerge buildkite jobs `:ray: core: rocksdb tests` + `:ray: core: out of disk rocksdb tests`, mirroring the Redis FT jobs. | | 6 | Docs: new K8s setup page (`kuberay-gcs-rocksdb-ft.md`) + an "Embedded RocksDB backend" section in `gcs.rst`. | | 7 | Review follow-ups: remove the inline execution path and the `gcs_rocksdb_async_offload` toggle so RocksDB I/O always offloads; make `GetNextJobIDSync` private (tests drive it through the public `AsyncGetNextJobID`); extract the rocksdb session-name marker logic in `node.py` into its own helper; collapse `storage_microbench` to a single `rocksdb` backend; make the soft-durable table set a hardcoded, documented constant (`SoftDurableTables()`) instead of the `gcs_rocksdb_soft_durability_tables` config flag, since it's a fixed design property rather than an operator knob. | Aggregate: **+2,973 / -20 across 26 files**. All commits signed off (DCO). ## REP-64 acceptance criteria 1. Release tests pass with `RAY_gcs_storage=rocksdb` — the new postmerge job runs the standard test suite under the rocksdb backend. 2. New postmerge CI job mirroring Redis GCS FT — ✓ commit 5. 3. Scale tests at parity with Redis — covered by the postmerge job's `//python/ray/tests/...` target set (includes `test_many_actors.py`). 4. Serve chaos passes — covered by the postmerge job. ## Tests C++ unit tests under `src/ray/gcs/store_client/tests/`: - `rocksdb_smoke_test` — Bazel-integration sanity (open / put / get). - `rocksdb_store_client_test` — RocksDb-specific scenarios: recovery across close+reopen, cluster-id marker fail-fast, pool-thread write roundtrip. - `rocksdb_parity_test` — runs the full `StoreClientTestBase` suite (same fixture as `in_memory_store_client_test` and `redis_store_client_test`). - `rocksdb_concurrency_test` — per-key strand correctness + JobID-counter atomicity under N-thread contention. Python integration coverage: the existing `//python/ray/tests/...` / `//python/ray/dag/...` / `//python/ray/autoscaler/v2/...` suites run under `TEST_GCS_ROCKSDB=1` via the new buildkite jobs. > The local k3d cluster recovery test harness from the POC branch was repeated on this branch. Results and reproduction instructions are in doc [REP-64 RocksDB GCS — Kubernetes Recovery: Evidence of Correctness & Reproduction Guide](https://docs.google.com/document/d/1sd6S1E5-kgOSbMjefjIkvkZztwsMeUikscOqbZHmUSA/edit?usp=sharing) ## Out of scope (follow-ons) - KubeRay operator support for `gcsFaultToleranceOptions.backend: rocksdb` — separate `ray-project/kuberay` PR. - PVC stale-data fail-fast via K8s downward API (`RAY_CLUSTER_ID` env-injected cluster-id marker) — `RocksDbStoreClient` already supports the check; needs the KubeRay-side plumbing. - Remove the soft-durability workaround. The soft-durability relaxation added here (skipping the per-write WAL fsync on the NODE/ACTOR death-notification tables, now a hardcoded `SoftDurableTables()` constant) works around a GCS-core object-reconstruction / task-resubmission race that RocksDB's fsync latency widens. That race was proven to be rooted in the GCS code (see ray-project#64187). A follow-on PR will fix the root cause in GCS and remove this workaround so every table keeps strict per-write fsync. - macOS / Windows support (targets currently gated on `@platforms//os:linux`). ## References - REP-64: ray-project/enhancements#64 - POC PR with full evidence dossier and design-review history: ray-project#63032 - Bug provenance: ray-project#64187 --------- Signed-off-by: Santosh Jha <[email protected]> Signed-off-by: Rueian <[email protected]> Signed-off-by: Edward Oakes <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Rueian <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Edward Oakes <[email protected]> Signed-off-by: 400Ping <[email protected]>
…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]>
…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]>
What this proves
test_dynamic_generator_reconstruction_nondeterministic[None-*]can hangpermanently because of a lost-wakeup in Ray core's node-death notification
path — independent of any storage backend.
The driver owning a dynamic generator's objects reacts to node death only from a
single pushed GCS pub/sub notification (
core_worker.ccon_node_change, DEADbranch). The GCS publishes it from inside the durable write's completion callback
(publish-after-persist), so a slow write delays the publish. The consumer has no
fallback (no timeout, no re-poll), so if that one push is delayed or lost, object
recovery never starts and
list(gen)blocks forever.Surfaced while adding a RocksDB GCS backend (REP-64) — RocksDB's strict per-write
fsyncmakes the publish slow enough to expose the latent core bug — but nothinghere uses RocksDB. Every arm runs on the in-memory GCS with the timing injected
deterministically, so the proof (and the fix) belong in Ray core.
Evidence — one harness, one arm per claim (in-memory GCS)
controlactor_publish_delayednode_publish_delayednode_persist_delayednode_persist_delayed_f3node_publish_delayed_f5A 5-min injected delay ≫ the 90s per-arm timeout, so each delayed arm models "this
notification never arrives", deterministically (no flakiness).
Fix options (full analysis in
REP64.md)Three fixes, each sacrificing exactly one property:
broadcast-after-durable ordering; safe for the terminal, re-derivable node-death
transition; not to be generalized to actors. Validated.
invariant; adds an owner-side poll; robust even to a dropped push. Validated.
Recommendation: F3 for the node channel as the minimal fix; add F5 if resilience to
a genuinely dropped (not merely slow) notification is wanted. Whether this lands in the
RocksDB PR or a follow-up is the open discussion this branch is meant to inform.
Contents (6 files, branched off vanilla upstream
606b434212)python/ray/tests/REP64.md— root cause (code-cited), fix trade-off, recommendation, reproduce steps.python/ray/tests/test_rep64_node_death_hang.py+run_rep64.sh— the harness (6 process-isolated arms).gcs_node_manager.cc,gcs_actor_manager.cc,core_worker.cc) — no behavior change unless aRAY_TESTING_*env var is set; reproductioninstrumentation only, must not ship in the product fix.
🤖 Generated with Claude Code