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
ThreadPool: make sure no leaking threads are left behind in case of initialization failure #11061
ThreadPool: make sure no leaking threads are left behind in case of initialization failure #11061
Conversation
I like it, LGTM |
|
||
TimeValue estimatedTimeInterval = settings.getAsTime("threadpool.estimated_time_interval", TimeValue.timeValueMillis(200)); | ||
this.estimatedTimeThread = new EstimatedTimeThread(EsExecutors.threadName(settings, "[timer]"), estimatedTimeInterval.millis()); | ||
this.estimatedTimeThread.start(); | ||
} | ||
|
||
public void setNodeSettingsService(NodeSettingsService nodeSettingsService) { | ||
nodeSettingsService.addListener(new ApplySettings()); |
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.
Should we add some safety that this method is called only once?
Left some suggestions but I like the change too! |
@jpountz I pushed some changes. Could you take another look? Thanks! |
@@ -91,13 +91,14 @@ | |||
|
|||
private final EstimatedTimeThread estimatedTimeThread; | |||
|
|||
private volatile boolean settingsListenerIsSet = false; |
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.
I don't think we need the volatile here?
LGTM, only one minor comment |
…nitialization failure Our ThreadPool constructor creates a couple of threads (scheduler and timer) which might not get shut down if the initialization of a node fails. A guice error might occur for example, which causes the InternalNode constructor to throw an exception. In this case the two threads are left behind, which is not a big problem when running es standalone as the error will be intercepted and the jvm will be stopped as a whole. It can become more of a problem though when running es in embedded mode, as we'll end up with lingering threads or testing an handling of initialization failures. Closes elastic#9107
389382f
to
573caca
Compare
Our ThreadPool constructor creates a couple of threads (scheduler and timer) which might not get shut down if the initialization of a node fails. A guice error might occur for example, which causes the InternalNode constructor to throw an exception. In this case the two threads are left behind, which is not a big problem when running es standalone as the error will be intercepted and the jvm will be stopped as a whole. It can become more of a problem though when running es in embedded mode, as we'll end up with lingering threads or testing an handling of initialization failures.
Closes #9107