-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-6867: [FlightRPC][Java] clean up default executor #5634
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
Conversation
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.
If server.shutdown() fails, we will leak resources (fail to invoke AutoCloseables.close)?
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.
We could, but server.shutdown doesn't throw any checked exceptions. I can move it into a finally block though.
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.
Er, no, I can't, since I don't want to shut down the executor before the server itself shuts down.
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.
why shutdownNow and not shutdown?
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 was worried about it blocking but on reflection, if we make it to closing the executor, the gRPC server should be shut down and everything should be terminated. I've changed it and updated the comment to explain.
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.
it seems like it would be clearer to remove the ternary operator combine the resources cleanup into one if/then block?
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.
Yes, consolidated them.
At the very least you should be able to test for the post condition that the executor passed in is terminated after a call to close. |
Yes, I've added two tests to cover the two cases. Apologies for the delay, I got tied up at work. |
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.
can't you try shutting down here and verify it does shutdown?
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.
No, there's no accessible reference to the actual executor to confirm it afterwards.
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 could plumb one through, but it'd be adding references specifically for testing.
(Sorry for the delay again, October was quite the busy month.)
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.
What do you think about making resources less generic and take the reference to ExecutorService in the class instead of list of AutoCloseable? Then make awaitTermination rely on both the server and the executor (if its not null). That way you don't need anything specifically visible for testing.
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.
That makes sense. I've updated the PR.
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 think you could avoid exposing this if you added this to awaitTermination as well (but that is a little tricky to do correctly). I'm OK if you don't want to do it.
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.
Hmm, how would that work in the test? We'd shut down the executor in awaitTermination and wait?
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 would have thought we shutdown the executorservice in shutdown
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.
Er, right. I can do that, but I still don't see how that'd let us avoid exposing it in test.
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 think it tests the behavior implicitly vs explicitly as the way you have it now. Like I said I'm fine with either approach.
|
+1 merging. |
|
Thank you! Apologies this dragged out so long. |
We were feeding gRPC an executor, but neglecting to shut it down, which caused the JVM to hang at shutdown when running inside IntelliJ. The gRPC documentation requires that we shut down executors ourselves: https://grpc.github.io/grpc-java/javadoc/io/grpc/ServerBuilder.html#executor-java.util.concurrent.Executor- Not too sure how to write a unit test for this - it clearly doesn't occur inside the Maven/JUnit unit test runner. Travis: https://travis-ci.com/lihalite/arrow/builds/131648977 Closes apache#5634 from lihalite/arrow-6867 and squashes the following commits: 60a4201 <David Li> ARROW-6867: clean up default executor Authored-by: David Li <li.davidm96@gmail.com> Signed-off-by: Micah Kornfield <emkornfield@gmail.com>
We were feeding gRPC an executor, but neglecting to shut it down, which caused the JVM to hang at shutdown when running inside IntelliJ. The gRPC documentation requires that we shut down executors ourselves: https://grpc.github.io/grpc-java/javadoc/io/grpc/ServerBuilder.html#executor-java.util.concurrent.Executor-
Not too sure how to write a unit test for this - it clearly doesn't occur inside the Maven/JUnit unit test runner.
Travis: https://travis-ci.com/lihalite/arrow/builds/131648977