Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
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.