homatthew commented on code in PR #3871:
URL: https://github.com/apache/gobblin/pull/3871#discussion_r1470505601


##########
gobblin-core/src/main/java/org/apache/gobblin/writer/PartitionedDataWriter.java:
##########
@@ -172,17 +172,23 @@ public DataWriter<D> load(final GenericRecord key)
                 new CloseOnFlushWriterWrapper<D>(new Supplier<DataWriter<D>>() 
{
                   @Override
                   public DataWriter<D> get() {
+                    Future<DataWriter<D>> future = null;
                     try {
                       log.info(String.format("Adding one more writer to 
loading cache of existing writer "
                           + "with size = %d", partitionWriters.size()));
-                      Future<DataWriter<D>> future = 
createWriterPool.submit(() -> createPartitionWriter(key));
+                      future = createWriterPool.submit(() -> 
createPartitionWriter(key));
                       state.setProp(CURRENT_PARTITIONED_WRITERS_COUNTER, 
partitionWriters.size() + 1);
                       return future.get(writeTimeoutInterval, 
TimeUnit.SECONDS);
                     } catch (ExecutionException | InterruptedException e) {
                       throw new RuntimeException("Error creating writer", e);
                     } catch (TimeoutException e) {
                       throw new RuntimeException(String.format("Failed to 
create writer due to timeout. The operation timed out after %s seconds.", 
writeTimeoutInterval), e);
                     }
+                    finally {
+                      if (future != null && !future.isDone()) {
+                        future.cancel(true);

Review Comment:
   Does this have the intended effect? In the issues you were seeing, did we 
see threads that are sleeping / waiting on IO, which need to be interrupted via 
cancel?
   
   I am asking this because if the thread needs to actively check if it's being 
requested to cancel (unless it's actively waiting / sleeping).
   
   Read the below to see what I am describing
   https://stackoverflow.com/questions/28043225/future-cancel-does-not-work



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to