Skip to content

[Core] Fix GetLocationFromOwner treating timeout_ms as microseconds - #65260

Open
LuciferYang wants to merge 1 commit into
ray-project:masterfrom
LuciferYang:fix-getlocation-timeout-unit
Open

[Core] Fix GetLocationFromOwner treating timeout_ms as microseconds#65260
LuciferYang wants to merge 1 commit into
ray-project:masterfrom
LuciferYang:fix-getlocation-timeout-unit

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Description

CoreWorker::GetLocationFromOwner wraps its int64_t timeout_ms in std::chrono::microseconds, so any positive timeout expires 1000x too early. A caller passing timeout_ms=10000 (meaning 10s) gives up after 10ms, well before a cross-worker RPC can complete, and gets a spurious Status::TimedOut.

The parameter name, the header contract (core_worker.h, "Timeout in milliseconds"), the error string ("... within N milliseconds"), and every other timeout_ms in the codebase mean milliseconds. This line is the only one treating the value as microseconds, and it has been this way since the API was added in #16130. The public ray.experimental.get_object_locations docstring separately said "micro seconds", which was also wrong, so this fixes both.

Only callers passing an explicit positive timeout_ms are affected. The Python API defaults to -1, which takes the infinite-wait branch, and every in-tree caller uses that default.

Related issues

Fixes #65254

Additional information

#54367 notes this API is expected to be removed once Data finishes migrating to get_local_object_locations (#53942, still open). I raised that in #65254 and nobody responded, and get_object_locations is still called in five Data paths today, so I'd rather fix the bug than leave it until the removal lands. Close this if you prefer to wait for the deletion.

I verified the change by inspection and built //src/ray/core_worker:core_worker_lib locally. I did not add a test: reaching the timeout branch needs an owner that never replies, and the wait uses std::promise::wait_for on the real steady_clock, which the repo's injected ClockInterface cannot fake, so any behavioral test would depend on wall-clock timing and be flaky. #54367 removed the previous test_get_locations_timeout for exactly that reason.

I used AI assistance to investigate and draft this change. I reviewed every changed line and ran the build myself.

GetLocationFromOwner wraps its int64_t timeout_ms in std::chrono::microseconds, so any positive timeout expires 1000x too early. A caller asking for a 10s timeout gives up after 10ms.

The parameter name, the header contract, the error string, and every other timeout_ms in the codebase mean milliseconds; this line is the only one treating it as microseconds. Use std::chrono::milliseconds, and fix the one Python docstring that also said "micro seconds".

Signed-off-by: yangjie01 <yangjie01@baidu.com>
@LuciferYang
LuciferYang requested a review from a team as a code owner August 6, 2026 16:02

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request corrects the unit of timeout_ms from microseconds to milliseconds in both the Python docstring for get_object_locations and the C++ implementation of CoreWorker::GetLocationFromOwner. I have no feedback to provide.

@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core docs An issue or change related to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_object_locations treats timeout_ms as microseconds, so positive timeouts expire 1000x early

1 participant