Skip to content

Commit 21af0ce

Browse files
authored
Register function race (#9346)
1 parent c00742f commit 21af0ce

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

python/ray/import_thread.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,13 @@ def _process_key(self, key):
136136
ray_constants.DUPLICATE_REMOTE_FUNCTION_THRESHOLD)
137137

138138
if key.startswith(b"RemoteFunction"):
139-
with profiling.profile("register_remote_function"):
140-
(self.worker.function_actor_manager.
141-
fetch_and_register_remote_function(key))
139+
# TODO (Alex): There's a race condition here if the worker is
140+
# shutdown before the function finished registering (because core
141+
# worker's global worker is unset before shutdown and is needed
142+
# for profiling).
143+
# with profiling.profile("register_remote_function"):
144+
(self.worker.function_actor_manager.
145+
fetch_and_register_remote_function(key))
142146
elif key.startswith(b"FunctionsToRun"):
143147
with profiling.profile("fetch_and_run_function"):
144148
self.fetch_and_execute_function_to_run(key)

python/ray/remote_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class RemoteFunction:
4141
_num_return_vals: The default number of return values for invocations
4242
of this remote function.
4343
_max_calls: The number of times a worker can execute this function
44-
before executing.
44+
before exiting.
4545
_decorator: An optional decorator that should be applied to the remote
4646
function invocation (as opposed to the function execution) before
4747
invoking the function. The decorator must return a function that

python/ray/tests/test_advanced.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ def f():
202202
"ray.wait",
203203
"submit_task",
204204
"fetch_and_run_function",
205-
"register_remote_function",
205+
# TODO (Alex) :https://github.com/ray-project/ray/pull/9346
206+
# "register_remote_function",
206207
"custom_event", # This is the custom one from ray.profile.
207208
]
208209

src/ray/core_worker/core_worker.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,6 @@ void CoreWorkerProcess::EnsureInitialized() {
149149
CoreWorker &CoreWorkerProcess::GetCoreWorker() {
150150
EnsureInitialized();
151151
if (instance_->options_.num_workers == 1) {
152-
// TODO(mehrdadn): Remove this when the bug is resolved.
153-
// Somewhat consistently reproducible via
154-
// python/ray/tests/test_basic.py::test_background_tasks_with_max_calls
155-
// with -c opt on Windows.
156152
RAY_CHECK(instance_->global_worker_) << "global_worker_ must not be NULL";
157153
return *instance_->global_worker_;
158154
}

0 commit comments

Comments
 (0)