nfsantos commented on code in PR #1456:
URL: https://github.com/apache/jackrabbit-oak/pull/1456#discussion_r1601044885


##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/pipelined/PipelinedStrategy.java:
##########
@@ -545,16 +540,32 @@ public File createSortedStoreFile() throws IOException {
                 indexingReporter.addTiming("Build FFS (Dump+Merge)", 
FormattingUtils.formatToSeconds(elapsedSeconds));
 
                 LOG.info("[INDEXING_REPORT:BUILD_FFS]\n{}", 
indexingReporter.generateReport());
-            } catch (InterruptedException e) {
+            } catch (Throwable e) {
+                LOG.warn("Error dumping from MongoDB. Cancelling all tasks. 
Error: {}", e.toString());
+                // Cancel in order
+                cancelFuture(downloadFuture);
+                for (Future<?> transformTask : transformFutures) {
+                    cancelFuture(transformTask);
+                }
+                cancelFuture(sortBatchFuture);
+                cancelFuture(mergeSortFuture);
                 throw new RuntimeException(e);
             } finally {
                 // No longer need to monitor the size of the queues,
                 monitorFuture.cancel(true);
             }
             return flatFileStore.toFile();
         } finally {
-            threadPool.shutdown();
-            monitorThreadPool.shutdown();
+            LOG.info("Shutting down build FFS thread pool");
+            new ExecutorCloser(threadPool).close();
+            monitorThreadPool.shutdownNow();

Review Comment:
   It was a miss. I refactored the code so that the `monitorThreadPool` is no 
longer needed. The periodic logging that was being done by this thread pool is 
now done by the main thread, using a timeout on waiting for the other tasks to 
finish. This reduces the amount of code and eliminates one thread pool, and is 
also less brittle. 



-- 
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: dev-unsubscr...@jackrabbit.apache.org

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

Reply via email to