Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-16187

ExecutorUtil#awaitTermination shouldn't wait forever

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 9.1, main (10.0), 9.0.1
    • None
    • None

    Description

      While looking at some of the other thread leak issues, found that ExecutorUtil#awaitTermination is waiting basically forever:

      https://github.com/apache/solr/blob/main/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java#L98

      public static void awaitTermination(ExecutorService pool) {
          boolean shutdown = false;
          while (!shutdown) {
            try {
              // Wait a while for existing tasks to terminate
              shutdown = pool.awaitTermination(60, TimeUnit.SECONDS);
            } catch (InterruptedException ie) {
              // Preserve interrupt status
              Thread.currentThread().interrupt();
            }
          }
        }
      

      Instead it should be possible to wait and then if still not shutdown then interrupt the threads? ie: pool.shutdownNow() then another awaitTermination to at least limit the termination time to 2*60 seconds?

      This would at least have some bound to shutting stuff down.

      Attachments

        Issue Links

          Activity

            People

              krisden Kevin Risden
              krisden Kevin Risden
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h