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

[fix] ScheduledExecutors use daemon threads, to avoid blocking shutdowns #989

Merged
merged 2 commits into from
Mar 26, 2019

Conversation

carrino
Copy link
Contributor

@carrino carrino commented Mar 19, 2019

Before this PR

This library leaves non-daemon threads behind so services never shut down

After this PR

==COMMIT_MSG==
ScheduledExecutors use daemon threads, so the JVM isn't prevented from shutting down
==COMMIT_MSG==

Possible downsides?

Very minimal downsides for uses who fire and forget requests and shut down their server and expect the library to keep the JVM alive and retry under the covers.

@carrino carrino requested a review from a team as a code owner March 19, 2019 20:16
@carrino
Copy link
Contributor Author

carrino commented Mar 19, 2019

#988

@@ -114,7 +114,7 @@
* Javadoc.
*/
private static final ScheduledExecutorService schedulingExecutor = Tracers.wrap(Executors.newScheduledThreadPool(
NUM_SCHEDULING_THREADS, Util.threadFactory("conjure-java-runtime/OkHttp Scheduler", false)));
NUM_SCHEDULING_THREADS, Util.threadFactory("conjure-java-runtime/OkHttp Scheduler", true)));
Copy link
Contributor

Choose a reason for hiding this comment

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

there are other executors in this class; you probably want to daemonize all of them!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe, but this is the one that is causing me troubles

Copy link
Contributor

Choose a reason for hiding this comment

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

Please either update all executors, or add comments describing why they need to use non-daemon threads

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why doesn't this apply to the cached executor which also uses non-daemon threads? If anything has made a remote call I imagine that would block shutdown for a full minute as well even if actions are not running.

If we haven't made calls using conjure-java-runtiem clients, it's odd that we would create this executor. Should creation of these executors be deferred until a client is created using memoized suppliers?

@carterkozak
Copy link
Contributor

Can you please update the title and message describing what has changed for a better commit log.

@carrino carrino changed the title make daemon thread ScheduledExecutors use daemon threads Mar 19, 2019
@carrino
Copy link
Contributor Author

carrino commented Mar 19, 2019

comment added

@iamdanfox
Copy link
Contributor

I think we've now accounted for all the executors constructed in this library.

Screenshot 2019-03-26 at 18 12 00

@iamdanfox iamdanfox changed the title ScheduledExecutors use daemon threads [fix] ScheduledExecutors use daemon threads Mar 26, 2019
@iamdanfox iamdanfox changed the title [fix] ScheduledExecutors use daemon threads [fix] ScheduledExecutors use daemon threads, to avoid blocking shutdowns Mar 26, 2019
@ferozco
Copy link
Contributor

ferozco commented Mar 26, 2019

👍

@bulldozer-bot bulldozer-bot bot merged commit 0b1abe2 into palantir:develop Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants