Skip to content

[25.08] Docs: Ray release - #3

Merged
anisha-amd merged 4 commits into
release/2.48.0.post0from
docs/25.08
Mar 27, 2026
Merged

anisha-amd merged 4 commits into
release/2.48.0.post0from
docs/25.08

Conversation

@anisha-amd

Copy link
Copy Markdown

No description provided.

@amd-jnovotny amd-jnovotny 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.

Just the comments from docs/26.02

vickytsang pushed a commit that referenced this pull request Mar 2, 2026
ray-project#61034)

Currently, there is a chance that a worker can crash on the `getenv`
syscall from the otel lazy initialization. We found the race is between
`setenv` on the user thread (`setenv(RBLN_DEVICES)`) and `getenv` on the
worker internal thread. However, we can't forbid `setenv` on a user's
thread; the only thing we can do is not call `getenv` once the user's
thread starts.

Here is the backtrace of the crash we found by intercepting the
`getenv`:

```
[getenv_preload] setenv name=RBLN_DEVICES value= overwrite=1
[getenv_preload] setenv backtrace:
  #0 /home/ray/getenv_trace_preload.so(setenv+0x73) [0x748a77ea870b]
  ray-project#1 ray::IDLE(+0x224d5b) [0x59f10aeead5b]
  #2 ray::IDLE(+0x13dfc3) [0x59f10ae03fc3]
  #3 ray::IDLE(_PyEval_EvalFrameDefault+0x313) [0x59f10adf3703]
  #4 ray::IDLE(+0x184bfd) [0x59f10ae4abfd]
  #5 ray::IDLE(+0x19da04) [0x59f10ae63a04]
  #6 ray::IDLE(_PyEval_EvalFrameDefault+0x115a) [0x59f10adf454a]
  #7 ray::IDLE(_PyFunction_Vectorcall+0x6c) [0x59f10ae03dfc]
  #8 ray::IDLE(_PyEval_EvalFrameDefault+0x49ae) [0x59f10adf7d9e]
  #9 ray::IDLE(_PyFunction_Vectorcall+0x6c) [0x59f10ae03dfc]
  #10 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x9a9333) [0x748a76270333]
  #11 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(_ZNSt17_Function_handlerIFN3ray6StatusERKNS0_3rpc7AddressENS2_8TaskTypeESsRKNS0_4core11RayFunctionERKSt13unordered_mapISsdSt4hashISsESt8equal_toISsESaISt4pairIKSsdEEERKSt6vectorISt10shared_ptrINS0_9RayObjectEESaISQ_EERKSN_INS2_15ObjectReferenceESaISV_EERSH_S10_PSN_ISG_INS0_8ObjectIDESQ_ESaIS12_EES15_PSN_ISG_IS11_bESaIS16_EERSO_INS0_17LocalMemoryBufferEEPbPSsS1E_RKSN_INS0_16ConcurrencyGroupESaIS1F_EESsbbblRKSt8optionalISsEEPFS1_S5_S6_SsSA_SM_SU_SZ_SsSsS15_S15_S19_S1C_S1D_S1E_S1E_S1J_SsbbblS1L_EE9_M_invokeERKSt9_Any_dataS5_OS6_OSsSA_SM_SU_SZ_S10_S10_OS15_S1X_OS19_S1C_OS1D_OS1E_S20_S1J_S1W_ObS21_S21_OlS1N_+0x1ab) [0x748a761786ab]
  #12 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(_ZN3ray4core10CoreWorker11ExecuteTaskERKNS_17TaskSpecificationESt8optionalISt13unordered_mapISsSt6vectorISt4pairIldESaIS9_EESt4hashISsESt8equal_toISsESaIS8_IKSsSB_EEEEPS7_IS8_INS_8ObjectIDESt10shared_ptrINS_9RayObjectEEESaISP_EESS_PS7_IS8_ISL_bESaIST_EEPN6google8protobuf16RepeatedPtrFieldINS_3rpc20ObjectReferenceCountEEEPbPSsS15_+0x1166) [0x748a76320a96]
  #13 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(_ZNSt17_Function_handlerIFN3ray6StatusERKNS0_17TaskSpecificationESt8optionalISt13unordered_mapISsSt6vectorISt4pairIldESaIS9_EESt4hashISsESt8equal_toISsESaIS8_IKSsSB_EEEEPS7_IS8_INS0_8ObjectIDESt10shared_ptrINS0_9RayObjectEEESaISP_EESS_PS7_IS8_ISL_bESaIST_EEPN6google8protobuf16RepeatedPtrFieldINS0_3rpc20ObjectReferenceCountEEEPbPSsS15_ESt5_BindIFMNS0_4core10CoreWorkerEFS1_S4_SK_SS_SS_SW_S13_S14_S15_S15_EPS19_St12_PlaceholderILi1EES1D_ILi2EES1D_ILi3EES1D_ILi4EES1D_ILi5EES1D_ILi6EES1D_ILi7EES1D_ILi8EES1D_ILi9EEEEE9_M_invokeERKSt9_Any_dataS4_OSK_OSS_S1U_OSW_OS13_OS14_OS15_S1Y_+0x87) [0x748a762e8647]
  ray-project#14 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0xb5186d) [0x748a7641886d]
  ray-project#15 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0xb557c5) [0x748a7641c7c5]
  ray-project#16 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x103e3eb) [0x748a769053eb]
  ray-project#17 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x1034f0b) [0x748a768fbf0b]
  ray-project#18 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0xb6f21b) [0x748a7643621b]
  ray-project#19 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x15893cb) [0x748a76e503cb]
  ray-project#20 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x158ad69) [0x748a76e51d69]
  ray-project#21 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x158b472) [0x748a76e52472]
  ray-project#22 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(_ZN3ray4core10CoreWorker20RunTaskExecutionLoopEv+0x132) [0x748a762e4252]
  ray-project#23 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(_ZN3ray4core21CoreWorkerProcessImpl26RunWorkerTaskExecutionLoopEv+0x41) [0x748a76336bd1]
  ray-project#24 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x8a45c1) [0x748a7616b5c1]
  ray-project#25 ray::IDLE(_PyEval_EvalFrameDefault+0x6fb) [0x59f10adf3aeb]
  ray-project#26 ray::IDLE(_PyFunction_Vectorcall+0x6c) [0x59f10ae03dfc]
  ray-project#27 ray::IDLE(_PyEval_EvalFrameDefault+0x6fb) [0x59f10adf3aeb]
  ray-project#28 ray::IDLE(+0x1d5cac) [0x59f10ae9bcac]
  ray-project#29 ray::IDLE(PyEval_EvalCode+0x85) [0x59f10ae9bbf5]
  ray-project#30 ray::IDLE(+0x20732a) [0x59f10aecd32a]
  ray-project#31 ray::IDLE(+0x201d13) [0x59f10aec7d13]
  ray-project#32 ray::IDLE(+0x976be) [0x59f10ad5d6be]
  ray-project#33 ray::IDLE(_PyRun_SimpleFileObject+0x1bb) [0x59f10aec23db]
  ray-project#34 ray::IDLE(_PyRun_AnyFileObject+0x44) [0x59f10aec1f74]
  ray-project#35 ray::IDLE(Py_RunMain+0x371) [0x59f10aebf3e1]
  ray-project#36 ray::IDLE(Py_BytesMain+0x37) [0x59f10ae8f447]
  ray-project#37 /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x748a77baad90]
  ray-project#38 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x748a77baae40]
  ray-project#39 ray::IDLE(+0x1c930e) [0x59f10ae8f30e]

[getenv_preload] getenv name=OTEL_CPP_EXPORTER_OTLP_METRICS_RETRY_BACKOFF_MULTIPLIER
[getenv_preload] backtrace:
  #0 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x10a9d17) [0x7321ce3c9d17]
  ray-project#1 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x10abe2b) [0x7321ce3cbe2b]
  #2 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x1050ffc) [0x7321ce370ffc]
  #3 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x104f4d7) [0x7321ce36f4d7]
  #4 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x1045833) [0x7321ce365833]
  #5 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0xa6c760) [0x7321cdd8c760]
  #6 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0xe69d9a) [0x7321ce189d9a]
  #7 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(_ZN3ray3rpc14ClientCallImplINS0_16HealthCheckReplyEE15OnReplyReceivedEv+0x165) [0x7321ce18c005]
  #8 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(_ZNSt17_Function_handlerIFvvEZN3ray3rpc17ClientCallManager29PollEventsFromCompletionQueueEiEUlvE_E9_M_invokeERKSt9_Any_data+0x15) [0x7321cdd8e475]
  #9 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x103e3eb) [0x7321ce35e3eb]
  #10 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x1034f0b) [0x7321ce354f0b]
  #11 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0xb6f21b) [0x7321cde8f21b]
  #12 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x15893cb) [0x7321ce8a93cb]
  #13 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x158ad69) [0x7321ce8aad69]
  ray-project#14 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0x158b472) [0x7321ce8ab472]
  ray-project#15 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0xa6bb54) [0x7321cdd8bb54]
  ray-project#16 /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so(+0xba2250) [0x7321cdec2250]
  ray-project#17 /lib/x86_64-linux-gnu/libc.so.6(+0x94ac3) [0x7321cf66eac3]
  ray-project#18 /lib/x86_64-linux-gnu/libc.so.6(+0x1268d0) [0x7321cf7008d0]

*** SIGSEGV received at time=1770862205 on cpu 1 ***
PC: @     0x748a77bc5c1d  (unknown)  getenv
    @     0x748a77bc3520  (unknown)  (unknown)
{"asctime":"2026-02-11 18:10:05,910","levelname":"E","message":"*** SIGSEGV received at time=1770862205 on cpu 1 ***","filename":"logging.cc","lineno":474}
{"asctime":"2026-02-11 18:10:05,910","levelname":"E","message":"PC: @     0x748a77bc5c1d  (unknown)  getenv","filename":"logging.cc","lineno":474}
{"asctime":"2026-02-11 18:10:05,910","levelname":"E","message":"    @     0x748a77bc3520  (unknown)  (unknown)","filename":"logging.cc","lineno":474}
Fatal Python error: Segmentation fault
```

According to the backtrace, we can identify that it is the
`OtlpGrpcMetricExporterOptions`, [which called
`getenv(OTEL_CPP_EXPORTER_OTLP_METRICS_RETRY_BACKOFF_MULTIPLIER)`](https://github.com/open-telemetry/opentelemetry-cpp/blob/13ad05a6f431efb76995cffb1225d26b45374749/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc#L47),
getting initialized by calling `InitOpenTelemetryExporter` in the
`metrics_agent_client_->WaitForServerReady()` callback, that causes the
issue.

This PR moves `OtlpGrpcMetricExporterOptions` into
`OpenTelemetryMetricRecorder` (so that we keep otel details
encapsulated) and moves its initialization early to `stats::Init()`, to
force the `OtlpGrpcMetricExporterOptions` to be initialized early, so
that we don't call `getenv` afterward.

---------

Signed-off-by: Rueian Huang <[email protected]>
vickytsang pushed a commit that referenced this pull request Mar 2, 2026
…opy_me__upb_internal_use_only) (ray-project#61147)

We found that if the version of python profobuf library mismatches with
the raylet's, the ray client python server will hit segment fault with
this trace:

```
* thread #12, name = 'python3.11', stop reason = signal SIGSEGV: address not mapped to object (fault address=0x16)
  * frame #0: 0x0000733c1ea38a59 _raylet.so`_upb_Arena_SlowMalloc_dont_copy_me__upb_internal_use_only + 41
    frame ray-project#1: 0x0000733c1ea366ad _raylet.so`_upb_Array_Realloc_dont_copy_me__upb_internal_use_only + 285
    frame #2: 0x0000733c1c54517b _message.cpython-311-x86_64-linux-gnu.so`_upb_Decoder_DecodeMessage + 3835
    frame #3: 0x0000733c1c545f0c _message.cpython-311-x86_64-linux-gnu.so`upb_Decoder_Decode + 108
    frame #4: 0x0000733c1c543ff9 _message.cpython-311-x86_64-linux-gnu.so`upb_Decode + 201
    frame #5: 0x0000733c1c52907d _message.cpython-311-x86_64-linux-gnu.so`PyUpb_Message_MergeFromString + 237
    frame #6: 0x0000733c1c5293c4 _message.cpython-311-x86_64-linux-gnu.so`PyUpb_Message_FromString + 36
    frame #7: 0x0000568134f2d81a python3.11`cfunction_vectorcall_O(func=0x0000733c15c0b560, args=0x0000733c20200480, nargsf=<unavailable>, kwnames=<unavailable>) at methodobject.c:514:24
    frame #8: 0x0000568135270620 python3.11
```

We can see from the trace that the python profobuf library
(`message.cpython-311-x86_64-linux-gnu.so`) tried to decode a message
with a function `_upb_Array_Realloc_dont_copy_me__upb_internal_use_only`
from `_raylet.so`, which is apparently not ideal. Ideally, the python
profobuf library should not use a function from `_raylet.so`.

That happens because the current exporting rule `*ray*internal*`
accidentally matches
`_upb_Array_Realloc_dont_copy_me__upb_internal_use_only`, so we have it
exposed globally from raylet:

<img width="1162" height="169" alt="image"
src="https://github.com/user-attachments/assets/f40ae524-9675-454d-8cce-f6c43d2d901c"
/>

The problematic rule `*ray*internal*` aims to export `ray::internal`
only, so this PR makes the pattern strict and does not expose
_upb_Arena_SlowMalloc_dont_copy_me__upb_internal_use_only.

Signed-off-by: Rueian Huang <[email protected]>
vickytsang pushed a commit that referenced this pull request Mar 2, 2026
## Description
grpc 1.57.1 will call `GetEnv("GRPC_EXPERIMENTAL_PICKFIRST_LB_CONFIG")`
on every grpc channel establishment for parsing load-balancing policy.
This causes race conditions between user tasks as they are allowed to do
setenv at anytime. This PR upgrades the grpc lib to 1.58.0 to get rid of
the `GetEnv("GRPC_EXPERIMENTAL_PICKFIRST_LB_CONFIG")`.

```
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=11, threadid=129183804413504) at ./nptl/pthread_kill.c:44
ray-project#1  __pthread_kill_internal (signo=11, threadid=129183804413504) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=129183804413504, signo=signo@entry=11) at ./nptl/pthread_kill.c:89
#3  0x00007580a7545476 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
#4  <signal handler called>
#5  __pthread_kill_implementation (no_tid=0, signo=11, threadid=129183804413504) at ./nptl/pthread_kill.c:44
#6  __pthread_kill_internal (signo=11, threadid=129183804413504) at ./nptl/pthread_kill.c:78
#7  __GI___pthread_kill (threadid=129183804413504, signo=signo@entry=11) at ./nptl/pthread_kill.c:89
#8  0x00007580a7545476 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
#9  <signal handler called>
#10 __GI_getenv (name=0x7580a6a078c2 "PC_EXPERIMENTAL_PICKFIRST_LB_CONFIG") at ./stdlib/getenv.c:84
#11 0x00007580a67e8b8a in grpc_core::GetEnv(char const*) () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
#12 0x00007580a649601f in grpc_core::ShufflePickFirstEnabled() () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
#13 0x00007580a64960ed in grpc_core::json_detail::FinishedJsonObjectLoader<grpc_core::(anonymous namespace)::PickFirstConfig, 1ul, void>::LoadInto(grpc_core::experimental::Json const&, grpc_core::JsonArgs const&, void*, grpc_core::ValidationErrors*) const () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#14 0x00007580a6787384 in grpc_core::json_detail::LoadWrapped::LoadInto(grpc_core::experimental::Json const&, grpc_core::JsonArgs const&, void*, grpc_core::ValidationErrors*) const ()
   from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#15 0x00007580a6497b07 in grpc_core::(anonymous namespace)::PickFirstFactory::ParseLoadBalancingConfig(grpc_core::experimental::Json const&) const ()
   from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#16 0x00007580a67c18a7 in grpc_core::LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(grpc_core::experimental::Json const&) const ()
   from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#17 0x00007580a66ad9b8 in grpc_core::ClientChannel::OnResolverResultChangedLocked(grpc_core::Resolver::Result) () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#18 0x00007580a66ae452 in grpc_core::ClientChannel::ResolverResultHandler::ReportResult(grpc_core::Resolver::Result) ()
   from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#19 0x00007580a63bc603 in grpc_core::PollingResolver::OnRequestCompleteLocked(grpc_core::Resolver::Result) () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#20 0x00007580a63bcb2d in std::_Function_handler<void (), grpc_core::PollingResolver::OnRequestComplete(grpc_core::Resolver::Result)::{lambda()ray-project#1}>::_M_invoke(std::_Any_data const&)
    () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#21 0x00007580a67cbf46 in grpc_core::WorkSerializer::WorkSerializerImpl::Run(std::function<void ()>, grpc_core::DebugLocation const&) ()
   from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#22 0x00007580a67cc0ea in grpc_core::WorkSerializer::Run(std::function<void ()>, grpc_core::DebugLocation const&) ()
   from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#23 0x00007580a63bd117 in grpc_core::PollingResolver::OnRequestComplete(grpc_core::Resolver::Result) () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#24 0x00007580a63b3f86 in grpc_core::(anonymous namespace)::AresClientChannelDNSResolver::AresRequestWrapper::OnHostnameResolved(void*, absl::lts_20230802::Status) ()
   from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#25 0x00007580a67c44c4 in grpc_core::ExecCtx::Flush() () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#26 0x00007580a63408a2 in grpc_core::ExecCtx::~ExecCtx() () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#27 0x00007580a6740343 in grpc_call_start_batch () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#28 0x00007580a5e281e9 in grpc::internal::CallOpSet<grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpSendMessage, grpc::internal::CallOpRecvInitialMetadata, grpc::internal::CallOpRecvMessage<google::protobuf::MessageLite>, grpc::internal::CallOpClientSendClose, grpc::internal::CallOpClientRecvStatus>::ContinueFillOpsAfterInterception() ()
   from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#29 0x00007580a5e2d809 in grpc::internal::BlockingUnaryCallImpl<google::protobuf::MessageLite, google::protobuf::MessageLite>::BlockingUnaryCallImpl(grpc::ChannelInterface*, grpc::inte--Type <RET> for more, q to quit, c to continue without paging--c
rnal::RpcMethod const&, grpc::ClientContext*, google::protobuf::MessageLite const&, google::protobuf::MessageLite*) () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#30 0x00007580a62d76ea in opentelemetry::proto::collector::metrics::v1::MetricsService::Stub::Export(grpc::ClientContext*, opentelemetry::proto::collector::metrics::v1::ExportMetricsServiceRequest const&, opentelemetry::proto::collector::metrics::v1::ExportMetricsServiceResponse*) () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#31 0x00007580a62ca40c in opentelemetry::v1::exporter::otlp::OtlpGrpcClient::DelegateExport(opentelemetry::proto::collector::metrics::v1::MetricsService::StubInterface*, std::unique_ptr<grpc::ClientContext, std::default_delete<grpc::ClientContext> >&&, std::unique_ptr<google::protobuf::Arena, std::default_delete<google::protobuf::Arena> >&&, opentelemetry::proto::collector::metrics::v1::ExportMetricsServiceRequest&&, opentelemetry::proto::collector::metrics::v1::ExportMetricsServiceResponse*) () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#32 0x00007580a62c23ed in opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporter::Export(opentelemetry::v1::sdk::metrics::ResourceMetrics const&) () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#33 0x00007580a62c0334 in (anonymous namespace)::OpenTelemetryMetricExporter::Export(opentelemetry::v1::sdk::metrics::ResourceMetrics const&) () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#34 0x00007580a62e5fdf in opentelemetry::v1::sdk::metrics::PeriodicExportingMetricReader::CollectAndExportOnce()::{lambda()ray-project#1}::operator()() const::{lambda(opentelemetry::v1::sdk::metrics::ResourceMetrics&)ray-project#1}::operator()(opentelemetry::v1::sdk::metrics::ResourceMetrics&) const () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#35 0x00007580a62ee7a6 in opentelemetry::v1::sdk::metrics::MetricReader::Collect(opentelemetry::v1::nostd::function_ref<bool (opentelemetry::v1::sdk::metrics::ResourceMetrics&)>) () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#36 0x00007580a62e5085 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<opentelemetry::v1::sdk::metrics::PeriodicExportingMetricReader::CollectAndExportOnce()::{lambda()ray-project#1}> > >::_M_run() () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#37 0x00007580a6997be0 in execute_native_thread_routine () from /home/ray/anaconda3/lib/python3.10/site-packages/ray/_raylet.so
ray-project#38 0x00007580a7597ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
ray-project#39 0x00007580a76298d0 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
```

Signed-off-by: Rueian Huang <[email protected]>
@github-actions

Copy link
Copy Markdown

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

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.

@github-actions github-actions Bot added the stale label Mar 18, 2026
@anisha-amd

Copy link
Copy Markdown
Author

pending release

@github-actions github-actions Bot added unstale and removed stale labels Mar 19, 2026
@anisha-amd
anisha-amd merged commit ce0ce6b into release/2.48.0.post0 Mar 27, 2026
vickytsang pushed a commit that referenced this pull request Nov 12, 2026
…ompatible with passive setup (ray-project#66635)

## Description
Under the Active-Passive GCS architecture
(`RAY_ENABLE_GCS_LEADER_ELECTION=true`), a passive GCS instance rejects
all mutating RPCs with `StatusCode::GcsPassive`. Previously, Python head
processes (`ray start --head`, Dashboard, Autoscaler, Log Monitor,
Reporter) assumed they were always talking to an active GCS.
Consequently, starting a passive head led to fatal crashes, 60-second
startup hangs, log-bombing, or state divergence upon failover.

This PR makes all Python head components resilient to passive GCS write
refusals. Passive heads can now boot cleanly, idle safely without
split-brain side effects, suppress repetitive error logging, and
seamlessly replay critical cluster state upon promotion to leader.

All changes are gated behind `RAY_ENABLE_GCS_LEADER_ELECTION` (default
`False`), ensuring zero behavioral impact when leader election is
disabled.

### Key Changes (by Subsystem)

#### 1. Core Exception & Centralized Passive Utilities
* **Dedicated Exception (`GcsPassiveError`)**: Subclasses `RpcError` to
distinguish expected passive GCS write refusals from fatal network
partitions or GCS crashes without relying on fragile error string
parsing.
* **Consolidated Utilities (`ray._private.gcs_passive_utils`)**:
* `is_refused_by_passive_gcs(exc, latch=None)`: Unified predicate for
passive refusal detection.
* `PassiveLatch`: Edge-triggered latch that logs transitions entering
and exiting passive mode once, eliminating per-second log spam across
loops.
* `wait_until_gcs_leader()`: Async loop gating utility that suspends
processing until the node is promoted.
* Passive-safe KV helpers (`put_kv_passive_safe`,
`async_put_kv_passive_safe`, `del_kv_passive_safe`,
`async_del_kv_passive_safe`): Unified sync/async helpers handling
passive refusals and latch transitions cleanly.

#### 2. Head Node Bootstrap & Process Supervision (`ray start --head`)
* **Survive Passive Write Rejections**: `_write_cluster_info_to_kv()`
catches `GcsPassiveError` and allows node initialization to continue
without writing initial cluster info.
* **Eliminate 60s Startup Timeout**: `start_api_server()` skips polling
for `DASHBOARD_ADDRESS` when GCS is passive and returns `process_info`
immediately. This prevents a 60-second stall and avoids dropping the
dashboard from KubeRay’s `dead_processes()` liveness supervisor.
* **Skip Dead Writes**: Passive nodes skip writing `webui:url` to GCS
since the URL is deferred until promotion.

#### 3. Dashboard Head, Agents & Promotion Replay Contract
* **Dashboard Agent Survival**: Dashboard Agent retries registering its
node-specific address rather than crashing on passive refusal
(preventing the fate-shared Raylet on the passive head from dying).
* **Dashboard Head Promotion Loop**: Dashboard Head defers publishing
its address and waits for leadership in `_register_addresses_loop()`
(leveraging existing `_gcs_check_alive()` cache without extra RPCs).
* **Explicit Promotion Replay Contract (`HEAD_PROMOTION_REPLAY_KEYS`)**:
Defined in `dashboard/consts.py` to enumerate all keys that must be
replayed upon promotion (`DASHBOARD_ADDRESS`, `webui:url`,
`session_name`, `CLUSTER_METADATA`, `tracing_startup_hook`, and bulk
extra usage tags).
* **Agent Log Muting**: `EventAgent` and `ReporterAgent` use
`PassiveLatch` to mute repetitive registration failures while waiting
for promotion.

#### 4. NodeHead Subprocess
* **Pause Subscriptions on Passive**: Uses `wait_until_gcs_leader()` to
pause node and actor update subscriptions until promoted.
* **State Consistency**: Records `_registered_head_node_id` only *after*
the KV put succeeds to prevent poisoned in-memory state on write
rejections.
* **Passive-Safe Address Cleanup**: Dead node agent address cleanup
(`_delete_agent_addresses`) ignores passive GCS refusals.
* **Fault Isolation**: Catches per-node update errors in `_update_nodes`
so a single malformed entry does not terminate the subscription loop.

#### 5. Autoscaler Monitors (v1 & v2)
* **Pause autoscaler on Passive**
* **Safe Startup**: Catches passive rejections during
`AutoscalerMetricsAddress` registration and `DEBUG_AUTOSCALING_ERROR`
cleanup.
* **Split-Brain Prevention**: Reconcile loops in both v1 and v2 check
`is_gcs_leader()` before each pass, remaining idle while passive. This
prevents passive heads from issuing unauthorized node launches or
terminations to cloud providers.
* **Promotion Takeover**: On promotion, atomically rewrites
`AutoscalerMetricsAddress` and clears stale error status so `ray status`
reflects the newly active autoscaler.

#### 6. Log Monitor
* **Log-Storm Suppression**: Catches `GcsPassiveError` on rejected log
publish batches and uses `PassiveLatch` to log state transitions once.
* **Continuous File Consumption**: Continues advancing file read offsets
while passive instead of parking. This avoids costly `is_gcs_leader()`
polling and prevents massive re-reading/publishing log storms upon
promotion.

#### 7. Usage Stats & Telemetry
* **Silence Passive Telemetry**: Restricts `UsageStatsHead` reporting to
active leaders, preventing duplicate empty telemetry reports under the
same session ID.
* **Graceful Metadata Read**: `get_cluster_metadata()` returns `None`
instead of raising `AttributeError` when the key has not yet been
written, allowing early joining workers to connect safely.

###GCS `internal_kv` Key Handling Strategies

Because different cluster state keys have distinct consistency
requirements and lifecycles, mutating operations on GCS `internal_kv`
are categorized into explicit synchronization strategies:

| Key | Namespace | Strategy | Passive Startup Behavior | Promotion
Behavior | Design Rationale & Considerations |
| :--- | :--- | :--- | :--- | :--- | :--- |
| **`session_name`** | `KV_NAMESPACE_SESSION`<br>(`"session"`) | **Write
When Absent**<br>(`overwrite=False`) |
`Node._write_cluster_info_to_kv()` catches write refusal and skips;
startup continues. | Replayed by `DashboardHead` with `overwrite=False`.
| **Idempotent recovery**: Cluster must have exactly one immutable
session name. If the previous leader already wrote it, promotion will
not overwrite it; if the previous leader crashed before writing it, this
closes the gap so workers can join. |
| **`CLUSTER_METADATA`** | `KV_NAMESPACE_CLUSTER`<br>(`"cluster"`) |
**Deferred Overwrite**<br>(`overwrite=True`) | `Node` catches write
refusal and skips. Readers return `None` instead of raising
`AttributeError`. | Replayed by `DashboardHead` with `overwrite=True`;
`ReporterHead` stops permanently caching it. | **Supports rolling
upgrades**: Passive head may be upgraded before taking over. Overwriting
ensures joining workers validate version compatibility against the
promoted head rather than a decommissioned predecessor. |
| **`DASHBOARD_ADDRESS`** | `KV_NAMESPACE_DASHBOARD`<br>(`"dashboard"`)
| **Deferred to Promotion**<br>(`overwrite=True`) | `DashboardHead`
defers registration; `start_api_server()` skips polling and returns
`process_info` immediately. | Replayed by `DashboardHead` with
`overwrite=True`. | **Eliminates 60s hang & preserves supervision**:
Avoids burning `RAY_DASHBOARD_STARTUP_TIMEOUT_S`. Returning valid
`process_info` prevents KubeRay's `dead_processes()` monitor from losing
track of the spawned dashboard. |
| **`webui:url`** | `KV_NAMESPACE_DASHBOARD`<br>(`"dashboard"`) | **Skip
& Deferred**<br>(`overwrite=True`) | `Node` skips writing `webui:url`
upon detecting a passive GCS. | Replayed by `DashboardHead` with
`overwrite=True`. | **Avoids deterministic write failure**: Uses the
explicit passive rejection signal from the preceding write rather than
relying on delayed leadership caches. |
| **`DashboardMetricsAddress`** | `None` (default) | **Deferred to
Promotion**<br>(`overwrite=True`) | `DashboardHead` catches write
refusal and suppresses registration. | Replayed by `DashboardHead` with
`overwrite=True`. | **Metrics routing**: Ensures metrics collectors
(e.g. Prometheus) only scrape the currently active dashboard instance. |
| **`tracing_startup_hook`** | `KV_NAMESPACE_TRACING`<br>(`"tracing"`) |
**Deferred to Promotion**<br>(`overwrite=True`) | `Node` skips initial
registration if GCS is passive. | Replayed by `DashboardHead` with
`overwrite=True` (if configured on startup). | **Distributed tracing
continuity**: Drivers read this key to determine whether to enable
tracing; must be republished by the promoted head. |
| **`extra_usage_tag_*`**<br>(e.g. `AUTOSCALER_VERSION`) |
`KV_NAMESPACE_USAGE_STATS`<br>(`"usage_stats"`) | **In-Memory Buffering
& Bulk Replay** | Buffered in in-memory dictionary; individual GCS write
failures log at debug level and degrade silently. |
`async_put_recorded_extra_usage_tags()` bulk replays all buffered tags
upon promotion. | **Telemetry completeness**: Overcomes process-level
memoization where tags recorded during passive would otherwise be marked
"already recorded" and never re-sent. |
| **`AutoscalerMetricsAddress`** | `None` (default) | **Deferred to
Promotion**<br>(`overwrite=True`) | Monitor startup catches rejection;
`PassiveLatch` mutes repeat logs. | Replayed once on promotion rising
edge with `overwrite=True`. | **Endpoints consistency**: Ensures `ray
status` and monitoring tools query the active autoscaler rather than the
dead predecessor. |
| **`DEBUG_AUTOSCALING_ERROR`** | `None` (default) | **Deferred Cleanup
/ Safe Overwrite** | Startup deletion skips on passive; failure handler
uses passive-safe write. | Deleted in `_resume_after_promotion()` upon
taking over. | **Prevents false death alerts**: Avoids falsely reporting
the autoscaler as dead during passive; clears stale errors left by the
dead leader upon promotion. |
| **`DEBUG_AUTOSCALING_STATUS`** | `None` (default) | **Leader-Only
Loop** | Loop checks `is_gcs_leader()` before each pass; completely
idles while passive. | Reconcile loop activates and publishes periodic
resource metrics. | **Split-brain prevention**: Autoscaler mutates cloud
provider resources (outside GCS gating); loop must never execute while
in passive. |
|
**`DASHBOARD_AGENT_ADDR_NODE_ID_PREFIX*`<br>`DASHBOARD_AGENT_ADDR_IP_PREFIX*`**
| `KV_NAMESPACE_DASHBOARD`<br>(`"dashboard"`) | **Retry In-Place Until
OK**<br>(Node-scoped, **no replay**) | `DashboardAgent` catches refusal
and retries registration in background until accepted. | **No replay
needed** (key describes this specific node, not cluster leadership). |
**Prevents node crash**: Dashboard Agent is fate-shared with Raylet.
Agent must survive write refusals on passive nodes without taking down
the host. |
| **Dead node agent addresses** |
`KV_NAMESPACE_DASHBOARD`<br>(`"dashboard"`) | **Tolerant
Deletion**<br>(Refusal safely ignored) | `NodeHead` calls
`async_internal_kv_del`; passive refusals are caught and ignored. | **No
replay needed** (active leader already performed cleanup; rejoining
agent will overwrite). | **Stateless passive**: Avoids maintaining a
dead-node cleanup queue across promotion. |
| **`head_node_id`** | `KV_NAMESPACE_JOB`<br>(`"job"`) |
**Commit-After-Write**<br>(`overwrite=True`) | Written by `NodeHead`
when head node becomes ALIVE. | Maintained by current active head. |
**Memory state hygiene**: In-memory `_registered_head_node_id` is only
committed after the KV put succeeds, preventing poisoned state on write
failure. |

---

### Test Plan

#### 1. Layered Unit Test Suite
Covers isolated passive rejection handling, latches, loop gating, KV
helpers, and promotion replay across all modified components.

####2. Manual test: Single-head cluster (Zero Regression) 
Tested standard single-head cluster behavior with default settings
(RAY_ENABLE_GCS_LEADER_ELECTION off):
1. Cluster Startup and verify clean startup and all components are
healthy.
2. Submit a job and verify success.
3. Logs are clean and no passive warning.

####3. Manual test: Standby Behavior Verification
Started a dual-head local cluster with Node A as active leader and Node
B as passive standby
1. Verify both head nodes remained alive
2. Verify the components behavior on passive head 
3. Verify no log spamming


## Related issues
ray-project#63643

---------

Signed-off-by: Yuchen Zhou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants