Uploaded image for project: 'Apache Storm'
  1. Apache Storm
  2. STORM-2870

FileBasedEventLogger leaks non-daemon ExecutorService which prevents process to be finished

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

          private void setUpFlushTask() {
              ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
              Runnable task = new Runnable() {
                  @Override
                  public void run() {
                      try {
                          if(dirty) {
                              eventLogWriter.flush();
                              dirty = false;
                          }
                      } catch (IOException ex) {
                          LOG.error("Error flushing " + eventLogPath, ex);
                          throw new RuntimeException(ex);
                      }
                  }
              };
      
              scheduler.scheduleAtFixedRate(task, FLUSH_INTERVAL_MILLIS, FLUSH_INTERVAL_MILLIS, TimeUnit.MILLISECONDS);
      }
      

      The code block initializes ExecutorService locally, which served threads are not daemons so it can prevent JVM to be exit successfully.

      Moreover it should be considered as bad case: not labeling thread name. I observed the process hung and got jstack, but hard to know where is the root, because leaked thread has default thread name.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            kabhwan Jungtaek Lim
            kabhwan Jungtaek Lim
            Votes:
            0 Vote for this issue
            Watchers:
            1 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 - 2h 40m
                2h 40m

                Slack

                  Issue deployment