[ https://issues.apache.org/jira/browse/OAK-6891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16381776#comment-16381776 ]
Francesco Mari commented on OAK-6891: ------------------------------------- [~mduerig], {{scheduleWithFixedDelay}} seems a better way to implement the maintenance tasks. > Executions of background threads might pile up > ---------------------------------------------- > > Key: OAK-6891 > URL: https://issues.apache.org/jira/browse/OAK-6891 > Project: Jackrabbit Oak > Issue Type: Bug > Components: segment-tar > Reporter: Francesco Mari > Priority: Major > Labels: production > Fix For: 1.9.0, 1.10 > > Attachments: example.txt > > > 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. -- This message was sent by Atlassian JIRA (v7.6.3#76005)