Skip to content
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

Merged
merged 7 commits into from
Jan 23, 2019

Conversation

jovany-wang
Copy link
Contributor

What do these changes do?

For actor tasks , we should not set current driver id to null.

Related issue number

N/A

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/11039/
Test PASSed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/11041/
Test FAILed.

Copy link
Contributor

@stephanie-wang stephanie-wang left a 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);
Copy link
Contributor

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?

Copy link
Contributor

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,
Copy link
Contributor

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?

Copy link
Contributor

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

@@ -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,
Copy link
Contributor

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);
Copy link
Contributor

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.

@jovany-wang
Copy link
Contributor Author

@raulchen @stephanie-wang
I have refined this PR with following logic:
In finally block we should not set any workerContext.
Because we will set it in the next turn of the while loop.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/11072/
Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/11073/
Test PASSed.

@raulchen raulchen merged commit 816406e into ray-project:master Jan 23, 2019
@jovany-wang jovany-wang deleted the fix-multi-threading branch February 20, 2019 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants