Skip to content

[docs] Revamp Ray core fault tolerance guide - #27573

Merged
ericl merged 18 commits into
ray-project:masterfrom
stephanie-wang:doc-up
Jan 27, 2023
Merged

ericl merged 18 commits into
ray-project:masterfrom
stephanie-wang:doc-up

Conversation

@stephanie-wang

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Changes:

  1. Move all fault tolerance docs under a common heading. The organization is now "User guide" > "Fault tolerance" > "Task | Actor | Object fault tolerance".
  2. Update description of lineage reconstruction semantics.
  3. Add subsections for handling misbehaving tasks and actors.
  4. Move the "Understanding ObjectLostErrors" from troubleshooting page to "Object fault tolerance" page.
  5. Clarify how to destroy actors.

@iycheng also added a component failures page, but I left it hidden for now. We should address this in a follow-up PR, but it is an advanced topic.

Related issue number

Closes #27047.

Checks

@stephanie-wang
stephanie-wang requested a review from a team as a code owner August 5, 2022 19:23

You can experiment with this behavior by running the following code.

.. code-block:: python

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.

Lets move the code to doc_code folder


# After the actor has been restarted 5 times, all subsequent methods will
# raise a `RayActorError`.
for _ in range(10):

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.

This code is actually wrong, see #26875

Signed-off-by: Stephanie Wang <[email protected]>
Signed-off-by: Stephanie Wang <[email protected]>

@jjyao jjyao 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.

I'm wondering if we can have another page putting these things together and tells people how to write fault tolerant Ray application.

Current task, actor, object pages are more explanatory, people need to read through all of them and figure out themselves how to apply those things to make their application fault tolerant. Probably we should have a page that's more actionable and practical.

For example, if your application is a task DAG, set max_retries and make sure root objects are owned by the driver, ....

We can brainstorm more on this.

Comment thread doc/source/ray-core/fault-tolerance.rst Resolved
Comment on lines +52 to +53
For at-least-once actors, the system will still guarantee execution ordering
according to the initial submission order. For example, any tasks submitted

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.

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.

I think it's okay to not mention this since synchronous and single-threaded is the default.

Comment on lines +62 to +66
that have critical state, it is best to take periodic checkpoints and either
manually restart the actor or automatically restart the actor with at-most-once
semantics. If the actor’s exact state at the time of failure is needed, the
application is responsible for resubmitting all tasks since the last
checkpoint.

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.

We need an example to show people how to do 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.

There's no canonical example for this since it's application-dependent. I simplified this text to make it less specific.

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.

Probably we can add one checkpointing example in the Examples section.

automatically recover the value by :ref:`re-executing <fault-tolerance-tasks>`
the task that previously created the value. Arguments to the task are
recursively reconstructed through the same mechanism.

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.

We need an example to demonstrate lineage reconstruction so people can see it in action.

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.

I don't think we need that. Also, there isn't an easy way to show a node dying in a standalone script without using internal APIs to simulate a cluster.

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.

I feel even an pure text example (with diagram) without runnable code can help people understand: something similar to the summit talk slide example. But we can leave it as it is for now and add examples later if it's needed based on user feedback.

-----------------------------

The owner of an object can die because of node or worker process failure.
Currently, **Ray does not support recovery from owner failure**. In this case, Ray

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.

We should mention the implication of this: this means if possible we should write the problem in a way that driver is the owner for root objects so they fate-share with the driver.

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.

Let's save this for a follow-up that adds general recommendations.

reachable. This is a generic error thrown when lineage reconstruction is
disabled and all copies of the object are lost from the cluster.

.. _`lineage reconstruction`: https://docs.ray.io/en/master/ray-core/actors/fault-tolerance.html

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.

This link is removed as part of this PR.

- ``ReferenceCountingAssertionError``: The object has already been deleted,
so it cannot be retrieved. Ray implements automatic memory management through
distributed reference counting, so this error should not happen in general.
However, there is a `known edge case`_ that can produce this error.

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.

You can have the link inline here

text <link>

@stephanie-wang

Copy link
Copy Markdown
Contributor Author

I'm wondering if we can have another page putting these things together and tells people how to write fault tolerant Ray application.

Current task, actor, object pages are more explanatory, people need to read through all of them and figure out themselves how to apply those things to make their application fault tolerant. Probably we should have a page that's more actionable and practical.

For example, if your application is a task DAG, set max_retries and make sure root objects are owned by the driver, ....

We can brainstorm more on this.

Let's do this in a follow-up.

Signed-off-by: Stephanie Wang <[email protected]>
@stale

stale Bot commented Sep 26, 2022

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

  • If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@stale stale Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Sep 26, 2022
@stale

stale Bot commented Oct 12, 2022

Copy link
Copy Markdown

Hi again! The issue will be closed because there has been no more activity in the 14 days since the last message.

Please feel free to reopen or open a new issue if you'd still like it to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for opening the issue!

@stale stale Bot closed this Oct 12, 2022
@stale stale Bot removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Nov 10, 2022
@stephanie-wang stephanie-wang assigned jjyao and unassigned fishbone Nov 10, 2022
jjyao added 5 commits December 8, 2022 12:16
Signed-off-by: Jiajun Yao <[email protected]>
Signed-off-by: Jiajun Yao <[email protected]>
Signed-off-by: Jiajun Yao <[email protected]>
Signed-off-by: Jiajun Yao <[email protected]>
@jjyao jjyao assigned ericl and stephanie-wang and unassigned jjyao Dec 9, 2022
Comment thread doc/source/ray-core/fault-tolerance.rst Resolved

@ericl ericl 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.

Could we also move Environment Dependencies up one row in the TOC? That way the order will be:

  • Tasks (section)
  • Actors (section)
  • Objects (section)
  • Env Deps
  • Scheduling (section)
  • Fault Tolerance (section)

@ericl ericl 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.

Could we also move Environment Dependencies up one row in the TOC? That way the order will be:

  • Tasks (section)
  • Actors (section)
  • Objects (section)
  • Env Deps
  • Scheduling (section)
  • Fault Tolerance (section)

@@ -0,0 +1,69 @@
.. _fault-tolerance-internal-system:

Advanced topic: Ray system failure model

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.

@stephanie-wang I think this page could use a general editing pass.

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.

Discussed with @stephanie-wang offline, this page is removed from this PR and will be added in a follow-up.

Signed-off-by: Jiajun Yao <[email protected]>
@stale

stale Bot commented Jan 15, 2023

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

  • If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@stale stale Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jan 15, 2023
@jjyao jjyao removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jan 19, 2023

@ericl ericl 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.

The structure of the content looks good. My main request is (like with the scheduling refactor), that we make this discoverable with links from the main task/actor sections. Could we add 2-3 links each from the main tasks/actors/objects content to the appropriate fault tolerance sections?

@ericl

ericl commented Jan 26, 2023

Copy link
Copy Markdown
Contributor

Also, how about combining the sections into "Scheduling and Fault Tolerance"? The sections are quite small right now. The fault tolerance pages can be appended to the end of the scheduling guides.

Signed-off-by: Jiajun Yao <[email protected]>
@jjyao

jjyao commented Jan 27, 2023

Copy link
Copy Markdown
Contributor

Also, how about combining the sections into "Scheduling and Fault Tolerance"? The sections are quite small right now. The fault tolerance pages can be appended to the end of the scheduling guides.

I think fault tolerance is an important and complex topic to be its own section. The fault tolerance page is small now but we plan to expand it in the follow-up PRs: we plan to add "How to write fault tolerant Ray applications" (#27573 (comment)).

@ericl
ericl merged commit 2a7dd31 into ray-project:master Jan 27, 2023
edoakes pushed a commit to edoakes/ray that referenced this pull request Mar 22, 2023
The structure of the content looks good. My main request is (like with the scheduling refactor), that we make this discoverable with links from the main task/actor sections. Could we add 2-3 links each from the main tasks/actors/objects content to the appropriate fault tolerance sections?

_Originally posted by @ericl in ray-project#27573 (review)

Co-authored-by: Yi Cheng <[email protected]>
Co-authored-by: Jiajun Yao <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 7, 2026
…66791)

## Why are these changes needed?

The Ray Core style-pass stack, #66642 through #66677, flagged
pre-existing claims that looked inconsistent with the source, and kept
them as written. This PR corrects the ones that current source settles.
Each one either lags a deliberate code change or never matched the code.
None traces to a code regression, so for each one the source describes
the intended behavior.

It's stacked on #66790, the mechanical fixes for the same pages, which
is stacked on #66677.

**For Core reviewers:** these corrections change what the docs say, so
please confirm them. Each item cites the source it rests on, at master
`5cf675f`, and the history of the disagreement. Items marked **confirm**
carry a specific point to check.

### Top-level pages

- `head-node-memory-management.md`: the note claimed KubeRay ignores
memory and CPU requests, but KubeRay uses the CPU request when the CPU
limit is absent (`ray-operator/controllers/ray/common/pod.go`). Per
review, the note now states the general rule without naming resource
types: set requests equal to limits, because KubeRay configures Ray's
logical resources from the limits. The note was wrong from the start, in
#58695.
- `handling-dependencies.md`, the paths and URIs rules: a local path can
also be a file, such as a local archive for `working_dir` or a `.whl`
for `py_modules`, as the page's own API reference says. Remote URIs can
be `.zip`, `.tar.gz`, `.tgz`, or `.tar.xz` archives, per
`python/ray/_private/runtime_env/packaging.py`. Remote tar archives
arrived in #62813, first released in 2.56.0, and #65742. **Confirm**
that the single top-level directory rule applies to tar archives too.
- `handling-dependencies.md`: `image_uri` is a `str`
(`python/ray/runtime_env/runtime_env.py`), not a `dict`. #49752 carried
`(dict)` over from the `container` field.
- `ray-generator.md`: `ObjectRefGenerator` isn't a Python generator and
doesn't fully implement the generator interface: `send`, `throw`, and
`close` raise `NotImplementedError`
(`python/ray/_private/object_ref_generator.py`). The sentence now says
only that you can iterate with a `for` loop.
- `tips-for-first-time.md`: the first value `ray.wait()` returns is a
list of ready refs (`python/ray/_private/worker.py`), as the page's API
table and sample, which indexes `done_id[0]`, already show.
- `resource-isolation-with-cgroupv2.md`: the default minimum reserved
system memory is `500 * (1024**2)`
(`python/ray/_private/ray_constants.py`). The listing wrote `0.5 *
1024**3`, which is 512 MiB, beside a `#500MiB` comment.
- `type-hint.md`: the `ActorProxy` handle sample called `func.remote()`
on an undecorated function and omitted its `actor` argument and its
imports. It now decorates `func`, passes the handle, and imports what it
uses. **Confirm** that passing the handle into a task is the intended
illustration.

### Tasks, actors, and objects

- `tasks/nested-tasks.md`: Ray pickles and exports a remote function on
its first `.remote()` call, in `RemoteFunction._remote()`
(`python/ray/remote_function.py`), not at definition. Export has been
lazy since before the note was written, in Ray 0.7. **Confirm** that
cloudpickle captures `f` at that point, or say if the note should go.
- `actors/concurrency-group-api.md`: the Java sample set both groups to
a maximum concurrency of 1, while the prose and the Python sample say 2
for `io` and 4 for `compute`. The Java sample now matches. This is a
code change in an untested `java` block.
- `objects/serialization.md`: drops "Most Python distributions default
to Pickle protocol 3". No supported Python does: `python/setup.py`
requires 3.10 or later, where the default is 4 or 5. The sentence went
stale when Ray dropped Python 3.7 in 2.9.0.
- `actors/index.md`: `ray.cancel` defaults `recursive` to `True`
(`python/ray/_private/worker.py`), and always has, so recursive
cancellation is the default and `recursive=False` opts out.
- `tasks/dynamic-generators.md`: adds the caveat from the page's own
sample, `doc_code/generator.py` (`__dynamic_generator_pass_start__`),
which says to avoid passing the generator because the extra `ray.get`
blocks the driver.

### Design patterns

- `patterns/ray-get-too-many-objects.md`: fetching too many objects "can
lead to" failure rather than "leads to" it, matching the next paragraph
and the sample's "if NUM_TASKS is large enough".
- `patterns/out-of-band-object-ref-serialization.md`: the pin lasts for
the lifetime of the worker that serialized the ref.
`python/ray/_private/serialization.py` adds a never-removed local
reference in the serializing process. The object is also gone if its
owner dies. **Confirm** the borrower case: when the serializer isn't the
owner, the owner cleans up a failed borrower's references
(`src/ray/core_worker/reference_counter.cc`). An automated review on
#66667 said the deserializing worker holds the pin instead. The source
comment at the pin site says the serializing worker does.

### Fault tolerance and scheduling

- `scheduling/index.md`: `k` is the larger of
`RAY_scheduler_top_k_absolute` and the rounded-down product of the node
count and `RAY_scheduler_top_k_fraction`
(`src/ray/raylet/scheduling/policy/hybrid_scheduling_policy.cc`). With
the defaults, that's 20% of nodes, rounded down, and at least 1.
- `scheduling/placement-group.md`: PACK is a soft policy, as the same
paragraph says, so Ray "tries to" put both bundles on one node. Only
STRICT_PACK requires it.
- `scheduling/ray-oom-prevention.md`: the policy ranks workers, and
`LeaseSpecification::IsRetriable()`
(`src/ray/common/lease/lease_spec.cc`) treats any nonzero `max_retries`
or `max_restarts`, including `-1`, as retryable.
- `fault-tolerance/objects.md`: `RAY_TASK_MAX_RETRIES` overrides only
the default `max_retries` for remote functions, when the option isn't
set (`python/ray/remote_function.py`). Tasks that set `max_retries`, and
actor tasks with `max_task_retries`, still reconstruct. The "entirely"
wording came in #27573, after #25189 introduced the variable as a
default override.
- `fault-tolerance/actors.md`: `ActorUnavailableError` retries apply to
any nonzero `max_task_retries`. `-1` retries without limit
(`src/ray/core_worker/task_manager.cc`, and the `max_task_retries`
docstring in `python/ray/actor.py`), as L21 of the same page already
counts it.
- `fault-tolerance/index.md`: a task pinned by a node-specific custom
resource "can't be retried on other nodes", the wording of the example's
own comment in `doc_code/fault_tolerance_tips.py`, rather than "won't be
retried".
- `scheduling/resources.md`: the whole-number rule above 1 is enforced
for GPUs (`python/ray/includes/task_options_utils.pxi`), while
`neuron_cores` rejects any fractional value
(`python/ray/_private/accelerators/neuron.py`) and TPU accepts only 1,
2, 4, or 8 (`python/ray/_private/accelerators/tpu.py`).
- `scheduling/memory-management.md`: on macOS, Ray caps the default
object store at 2 GiB (`MAC_DEGRADED_PERF_MMAP_SIZE_LIMIT` in
`python/ray/_private/ray_constants.py`) and raises an error for a larger
requested size unless `RAY_ENABLE_MAC_LARGE_OBJECT_STORE=1`
(`python/ray/_private/services.py`). The cap arrived in #21224.
- `scheduling/placement-group.md`: no code reads `NVIDIA_GPU_CLIQUE`.
The variable supplies the value of the `ray.io/gpu-domain` label, which
is what the feature acts on, as the example below the sentence shows.

### Compiled Graph, Ray Direct Transport, and internals

- `direct-transport/index.md`: both the Gloo and NCCL examples call
`create_collective_group`, so the difference worth listing is
`backend="nccl"` against `backend="torch_gloo"`
(`doc_code/direct_transport_gloo.py` and `direct_transport_nccl.py`).
- `internals/task-lifecycle.md`: for a normal task, the executor's
raylet pulls remote arguments before it grants the lease
(`src/ray/raylet/local_lease_manager.cc`,
`lease_dependency_manager.cc`), as a later step on the same page says.
The executor reads them from the local store.
- `internals/port-service-discovery.md`: the raylet spawns worker
processes, and the core worker inside each one is a C++ library. #66677
restores the original wording, and this states it precisely.
- `internals/object-spilling.md`:
- Spill selection isn't LRU. `TryToSpillObjects` walks
`pinned_objects_`, an unordered `absl::flat_hash_map`
(`src/ray/raylet/local_object_manager.h`). LRU is the Plasma eviction
policy for secondary copies, which the page covers separately.
- Proactive spilling starts when the fraction of primary bytes is at
least the threshold, `>=` in `src/ray/raylet/node_manager.cc`, as the
page's trigger table says.
- `object_spilling_threshold` is a fraction of object store capacity,
the configured size, not of available memory (`node_manager.cc`,
`ObjectManager::GetMemoryCapacity()`).
- `max_io_workers` limits each IO worker type separately
(`TryStartIOWorkers` in `src/ray/raylet/worker_pool.cc`), as the worker
pool section of the page already says.
- `internals/metric-exporter.md`: C++ metrics register in their
`ray::stats` constructors when OpenTelemetry is on
(`src/ray/stats/metric.h`), not lazily on first use. Recording an
unregistered name fails a `RAY_CHECK`
(`src/ray/observability/open_telemetry_metric_recorder.cc`). "Lazy
registration" becomes "Idempotent registration", which is what that
bullet describes.

## Related issue number

None. Not a duplicate: I searched open PRs touching `doc/source/core/`
and `doc/source/ray-core/`. Open PRs editing these pages are this stack,
#66464 (Compiled Graph deprecation, on lines this PR doesn't touch), and
#66550 (label selector operators, on lines this PR doesn't touch).

Questions from the style pass that need a Core decision rather than a
source check aren't in this PR. Examples are the `DAGNode.execute()`
deprecation framing, the DEFAULT scheduling strategy's locality wording,
the official KubeRay support scope for GCS fault tolerance, and the Ray
event exporter baseline. They're tracked separately for Core
engineering.

## Checks

- Docs-only: every change is in a `.md` file under `doc/source/core/`,
so no library tests run. The two sample edits, in `type-hint.md` and
`concurrency-group-api.md`, are untested `python` and `java` blocks.
- Every cited claim was re-checked on master `5cf675f`, and the
disagreement's history was traced through release tags to rule out a
code regression.
- `vale` on the 26 changed files from the repo root: four alerts removed
and one added, `Google.Parens` on `image_uri (str)`, which matches the
field-type format of its sibling entries.
- `codespell` on the changed files: clean.
- `doc/.claude/skills/ray-soft-wrap/scripts/softwrap.py --check` on the
changed files: clean.
- `pre-commit`: passed.
- Full `-W` doc build: relying on the Read the Docs preview.

AI assistance (Claude Code) was used to research and draft these edits.
Draft until the submitter has reviewed every changed line and a Core
reviewer has confirmed the claims.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core] Revamp fault tolerance user guide doc

4 participants