-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
[SPARK-4282][YARN] Stopping flag in YarnClientSchedulerBackend should be volatile #3143
Conversation
Test build #23019 has started for PR 3143 at commit
|
Test build #23019 has finished for PR 3143 at commit
|
Test PASSed. |
Why not use proper synchronization / waiting instead, or a semaphore? |
Ah... embarrassing. Yes, we should use synchronization. |
Why does the thread interrupt itself after it's completed the while loop? There is nothing that would see this. |
Also, I'm not certain of the advantage of using proper synchronization over a volatile variable here, the latter seems sufficient to the task, unless you want to wait for the thread to terminate, which seems unnecessary since it's daemonic. |
This looked like busy-waiting to me, which seems like an antipattern compared to waiting on a condition variable / semaphore, but I guess we need to poll YARN to find out whether the application has exited. Sorry for the confusion. |
Right, I believe this is not busy-waiting, but a periodic task executing in a separate thread. Perhaps a ScheduledExecutorService would be clearer, but this seems like a reasonable use of volatile. |
I'm not too familiar with the YARN code, but it looks like the |
That sounds good, but do note that that wouldn't be quite the same semantics, as the current pattern allows someone calling sc.stop() to terminate this thread cleanly, independent of what YARN says. Perhaps this is not a useful distinction, however. |
It looks like |
SGTM |
@JoshRosen You mean we should call
|
I agree all we need is to make it volatile, no other synchronization is required. It sounds good to commonize the monitor logic inside of Client/ClientBase. Lets make sure to not have monitorApplication spin off an extra thread in cluster mode as it would just add extra overhead. If we want to get this into 1.2 I would rather just have this bug fix the volatile flag, then file a separate jira to do the other cleanup. |
@tgravescs That seems fine to me; you can go ahead and merge this, if you'd like, or I'll do it when I get back later this morning. |
+1, looks good. Filed SPARK-4346 to do the cleanup and commonization |
… be volatile In YarnClientSchedulerBackend, a variable "stopping" is used as a flag and it's accessed by some threads so it should be volatile. Author: Kousuke Saruta <[email protected]> Closes #3143 from sarutak/stopping-flag-volatile and squashes the following commits: 58fdcc9 [Kousuke Saruta] Marked stoppig flag as volatile (cherry picked from commit 7f37188) Signed-off-by: Thomas Graves <[email protected]>
1. YarnClientSchedulerBack.asyncMonitorApplication use Client.monitorApplication so that commonize the monitor logic 2. Support changing the yarn client monitor interval, see #5292 3. More details see discussion on #3143 Author: unknown <[email protected]> Author: Sephiroth-Lin <[email protected]> Closes #5305 from Sephiroth-Lin/SPARK-4346_3596 and squashes the following commits: 47c0014 [unknown] Edit conflicts 52b29fe [unknown] Interrupt thread when we call stop() d4298a1 [unknown] Unused, don't push aaacb42 [Sephiroth-Lin] don't wrap the entire block in the try ee2b2fd [Sephiroth-Lin] update 6483a2a [unknown] Catch exception 6b47ff7 [unknown] Update code 568f46f [unknown] YarnClientSchedulerBack.asyncMonitorApplication should be common with Client.monitorApplication
In YarnClientSchedulerBackend, a variable "stopping" is used as a flag and it's accessed by some threads so it should be volatile.