Skip to content

Commit

Permalink
[Core]Fix NullPointerException cause by raylet id is empty when get a…
Browse files Browse the repository at this point in the history
…ctor info in java worker (#40560)

## Why are these changes needed?

Fix NullPointerException cause by raylet id is empty when get actor info in java worker.
Calling get actor info API before the Actor is successfully scheduled will result in a NullPointerException.
![image](https://github.com/ray-project/ray/assets/11072802/a25f4728-ca8a-4841-b912-4ca757437dc2)
  • Loading branch information
larrylian committed Oct 24, 2023
1 parent cf122d0 commit 94beb5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions java/runtime/src/main/java/io/ray/runtime/gcs/GcsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,19 @@ public List<ActorInfo> getAllActorInfo(JobId jobId, ActorState actorState) {
result -> {
try {
Gcs.ActorTableData info = Gcs.ActorTableData.parseFrom(result);
UniqueId nodeId = UniqueId.NIL;
if (!info.getAddress().getRayletId().isEmpty()) {
nodeId =
UniqueId.fromByteBuffer(
ByteBuffer.wrap(info.getAddress().getRayletId().toByteArray()));
}
actorInfos.add(
new ActorInfo(
ActorId.fromBytes(info.getActorId().toByteArray()),
ActorState.fromValue(info.getState().getNumber()),
info.getNumRestarts(),
new Address(
UniqueId.fromByteBuffer(
ByteBuffer.wrap(info.getAddress().getRayletId().toByteArray())),
info.getAddress().getIpAddress(),
info.getAddress().getPort()),
nodeId, info.getAddress().getIpAddress(), info.getAddress().getPort()),
info.getName()));
} catch (InvalidProtocolBufferException e) {
throw new RayException("Failed to parse actor info.", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private void destroyGlobalStateAccessor() {
private native List<byte[]> nativeGetAllNodeInfo(long nativePtr);

private native List<byte[]> nativeGetAllActorInfo(
long nativePtr, byte[] jobId, String actor_state_name);
long nativePtr, byte[] jobId, String actorStateName);

private native byte[] nativeGetActorInfo(long nativePtr, byte[] actorId);

Expand Down

0 comments on commit 94beb5e

Please sign in to comment.