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

YARN-6061. Add a customized uncaughtexceptionhandler for critical threads #182

Closed
wants to merge 8 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -824,25 +824,29 @@ public void handle(RMFatalEvent event) {
* Transition to standby in a new thread.
*/
public void handleTransitionToStandByInNewThread() {
new Thread() {
@Override
public void run() {
if (rmContext.isHAEnabled()) {
try {
// Transition to standby and reinit active services
LOG.info("Transitioning RM to Standby mode");
transitionToStandby(true);
EmbeddedElector elector = rmContext.getLeaderElectorService();
if (elector != null) {
elector.rejoinElection();
}
} catch (Exception e) {
LOG.fatal("Failed to transition RM to Standby mode.", e);
ExitUtil.terminate(1, e);
Thread standByTransitionThread = new Thread(new StandByTransitionThread());
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for not identifying this earlier. We should make this thread-safe in case this is triggered by two critical threads failing at the same time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, would it make sense to create an instance of the Runnable on transition to active, and start a new thread on a need-to basis. If all threads use a single instance of the Runnable, may be it is easier to coordinate?

standByTransitionThread.setName("StandByTransitionThread Handler");
standByTransitionThread.start();
}

private class StandByTransitionThread implements Runnable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming the Runnable a Thread sounds confusing. Can we change it to TransitionToStandbyRunnable or some such?

@Override
public void run() {
if (rmContext.isHAEnabled()) {
try {
// Transition to standby and reinit active services
LOG.info("Transitioning RM to Standby mode");
transitionToStandby(true);
EmbeddedElector elector = rmContext.getLeaderElectorService();
if (elector != null) {
elector.rejoinElection();
}
} catch (Exception e) {
LOG.fatal("Failed to transition RM to Standby mode.", e);
ExitUtil.terminate(1, e);
}
}
}.start();
}
}

@Private
Expand Down