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:

----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]