-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Java] Fix setCurrentTask()
in multi threading
#3821
Conversation
Test PASSed. |
Test FAILed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Left a couple questions.
// For normal task, we should set current task id to null as well. | ||
runtime.getWorkerContext().setCurrentTask(null, null, null); | ||
} | ||
|
||
Thread.currentThread().setContextClassLoader(oldLoader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I'm not clear on what classLoader
is, but it seems like you could get rid of this line and pass in oldLoader
in the setCurrentTask
lines above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephanie-wang classLoader
is used to tell JVM where and how to load a class into memory. We use different class loaders for different drivers. So different drivers can have classes with the same name without conflicts.
@jovany-wang classLoader
should be set and reset in the same way as the driver id.
@@ -63,18 +63,15 @@ public UniqueId getCurrentTaskId() { | |||
* Set the current task which is being executed by the current worker. Note, this method can only | |||
* be called from the main thread. | |||
*/ | |||
public void setCurrentTask(TaskSpec task, ClassLoader classLoader) { | |||
public void setCurrentTask(UniqueId currentTaskId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set currentTaskId
to UniqueId.NIL
if it's null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but maybe it's more clear to just pass in UniqueId.NIL
java/runtime/src/main/java/org/ray/runtime/AbstractRayRuntime.java
Outdated
Show resolved
Hide resolved
@@ -63,18 +63,15 @@ public UniqueId getCurrentTaskId() { | |||
* Set the current task which is being executed by the current worker. Note, this method can only | |||
* be called from the main thread. | |||
*/ | |||
public void setCurrentTask(TaskSpec task, ClassLoader classLoader) { | |||
public void setCurrentTask(UniqueId currentTaskId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but maybe it's more clear to just pass in UniqueId.NIL
// For normal task, we should set current task id to null as well. | ||
runtime.getWorkerContext().setCurrentTask(null, null, null); | ||
} | ||
|
||
Thread.currentThread().setContextClassLoader(oldLoader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephanie-wang classLoader
is used to tell JVM where and how to load a class into memory. We use different class loaders for different drivers. So different drivers can have classes with the same name without conflicts.
@jovany-wang classLoader
should be set and reset in the same way as the driver id.
@raulchen @stephanie-wang |
Test PASSed. |
Test PASSed. |
What do these changes do?
For actor tasks , we should not set current driver id to null.
Related issue number
N/A