Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-6891

Executions of background threads might pile up

    XMLWordPrintableJSON

Details

    Description

      The background threads used in FileStore are implemented by wrapping Runnable instances in SafeRunnable, and by handing the SafeRunnable instances over to a ScheduledExecutorService.

      The documentation of ScheduledExecutorService#scheduleAtFixedRate states that "if any execution of a task takes longer than its period, then subsequent executions may start late, but will not concurrently execute". This means that if an execution is delayed, the piled up executions might fire in rapid succession.

      This way of running the periodic background threads might not be ideal. For example, it doesn't make much sense to flush the File Store five times in a row. On the other hand, if the background tasks are coded with this caveat in mind, this issue might not be a problem at all. For example, flushing the File Store five times in a row might not be a problem if many of those executions don't do much and return quickly.

      Tasks piling up might be a problem when it comes to release the resource associated with the FileStore in a responsive way. Since the ScheduledExecutorService is gracefully shut down, it might take some time before all the scheduled background tasks are processed and the ScheduledExecutorService is ready to be terminated.

      Attachments

        1. example.txt
          13 kB
          Francesco Mari

        Activity

          People

            mduerig Michael Dürig
            frm Francesco Mari
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: