You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/10/03 01:16:55 UTC

[GitHub] [druid] gianm commented on a change in pull request #10467: Fix bug in TimedShutoffInputSourceReader where a timeout does not close all registered closeable

gianm commented on a change in pull request #10467:
URL: https://github.com/apache/druid/pull/10467#discussion_r499102357



##########
File path: core/src/main/java/org/apache/druid/data/input/impl/TimedShutoffInputSourceReader.java
##########
@@ -68,8 +68,10 @@ public TimedShutoffInputSourceReader(InputSourceReader delegate, DateTime shutof
   )
   {
     final Closer closer = Closer.create();
-    closer.register(delegateIterator);
+    // We must register the shutdownNow method of the shutdown executor first. This will cause the shutdown executor
+    // to be closed last and ensure other resources which depend on it can close successfully.
     closer.register(exec::shutdownNow);

Review comment:
       Hmm, a few comments about this:
   
   1. It's kind of poor form to close an executor from within a thread running in that same executor, which is what's happening here. Switching the order is a bit better, but it's still sort of like the picture below.
   2. The record supplier's close function doesn't protect against multiple closes, and neither do Closers, so the record supplier might be closed multiple times or even concurrently. We should include something to ensure it will be OK if that happens.
   3. Any ideas about how to test this? We should have testing for this sort of bug.
   
   ---
   
   A photo of an executor being closed from a thread inside that same executor:
   
   ![image](https://user-images.githubusercontent.com/1214075/94980018-203ab780-04db-11eb-857b-16a72fb500cf.png)
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org